Created
June 17, 2012 13:31
-
-
Save sarim/2944571 to your computer and use it in GitHub Desktop.
Converting raw dict text to json object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//This script will convert the avro autocorrect dict to json. Rifat bro already did it using textmate manually, but my approach is artistic :D | |
//Get the raw dict from github | |
$raw = file_get_contents("https://raw.github.com/omicronlab/Avro-Keyboard/master/Keyboard%20and%20Spell%20checker/autodict.dct"); | |
//breaking the lines | |
$lines = explode("\n",$raw); | |
$arr = array(); | |
//looping the lines | |
foreach ($lines as $line) { | |
//ignoring the comments (on top) | |
if (substr($line,0,1) != '/') { | |
list($search_word,$replace_word) = explode(" ",$line); | |
$arr[$search_word] = $replace_word; | |
} | |
} | |
//finally echoing json object | |
echo(json_encode($arr)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment