Issue #8, convert hunspell output to spellchecker JSON format - #9
Issue #8, convert hunspell output to spellchecker JSON format#9teners wants to merge 22 commits into
Conversation
| done | ||
| shift $((OPTIND-1)) | ||
|
|
||
| if [ "$#" != 1 ] |
There was a problem hiding this comment.
any sense to surround 1 with double-quotes, to compare string and string?
fixed hunspell options to interpret input as latex file
| INFILE=$1 | ||
|
|
||
| JSON=$( | ||
| cat $INFILE | |
There was a problem hiding this comment.
Enquote $INFILE, otherwise you're going have troubles with spaces in the path
|
One interesting question is duplicate keys: This script will produce JSON with three equals keys. I suggest filtering duplicates with |
| options_number=split(split_string[2], options, ", "); | ||
|
|
||
| for (i = 1; i <= options_number; i++) | ||
| {print "\t\t\""options[i]"\","} |
There was a problem hiding this comment.
Comma after the last element of the array produces invalid JSON, at least from jq perspective.The same applies to the commma after the last entry
removed "pretty-printing efforts"
fixed it with an additional variable in awk
|
|
||
| echo $JSON | ||
| echo "$JSON" | | ||
| sed ':a;N;$!ba;s/,\n}/\n}/g' |
There was a problem hiding this comment.
This can probably be better solved by introducing a global variable which is empty in the beginning and "," after the first use. Use it like a prefix of the serialized array:
print $2 + PREFIX + [
There was a problem hiding this comment.
Heck, that's a really good point. Shame on me for such a dummy solution.
Merge branch 'tkt_8_convert_hunspell_to_json' of https://github.com/bardsoftware/papeeria into tkt_8_convert_hunspell_to_json
| } | ||
|
|
||
| message Suggestions { | ||
| string json = 1; |
There was a problem hiding this comment.
one of the purposes of protocol buffers is to provide typed interface for data exchange between servers. Please replace this json with typed interface, like map<string, Replacements> suggestions, use it in the spellchecker and remove your own json-serialization
| # note: these fields' names doesn't start with "_" since deleting of this | ||
| # object isn't so straightforward -- for some reason interpreter destroys | ||
| # these "private" fields before __del__ is invoked. | ||
| self.parser_lib_ = cdll.LoadLibrary("../libparser/build/libparser.so") |
There was a problem hiding this comment.
what's the purpose of the trailing underscores?
There was a problem hiding this comment.
also, please parameterize this class with the path to the shared library
There was a problem hiding this comment.
Oh, I thought I removed them.
Yep, that's what I forgot to do.
No description provided.