def-gthill / lexurgy

A high-powered sound change applier
GNU General Public License v3.0
42 stars 5 forks source link

Lexurgy Server Mode #68

Closed neta-elad closed 1 year ago

neta-elad commented 1 year ago

Adds a server mode to Lexurgy, where requested and responses are formatted as JSON and sent via stdin and stdout (respectively). Request format:

{"words": ["word1", "word2"], "startAt": "rule1", "stopBefore": "rule2", "traceWords": ["word2"], "romanize": false}

All fields other than "words" are optional.

Response format is either a successful change:

{"type": "changed", "words": ["word1 changed", "word2 changed"], "intermediates": {"intermediate1": ["word1 interim", "word2 interim"]}, "traceLines": ["Tracing word1", "Applied rule1: word1 -> word1 interim"]}

Or an error:

{"type": "error", "message": "Rule application failed...", "stackTrace": [...]}

I tested this in my own project and saw speed-ups of ~20x per query.