Created
February 24, 2013 08:02
-
-
Save neofreko/5023065 to your computer and use it in GitHub Desktop.
weather grammar for my poor man's nlp
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
| start | |
| = left:weather blank right:location {return [left, right]} | |
| expr | |
| = & blank* left:(primitive / compound)+ blank* | |
| compounds | |
| = left:compound+ {return left} | |
| compound | |
| = left:primitive blank right:primitive {return left+right} | |
| primitive | |
| = word:word left:lexhint right:("," lexhint)* {return {word: word, lexhint: left + String(right).replace(/,+/g, ',') }} | |
| word "word" | |
| = str:(!"/" c:. {return c})+ "/" {return str.join("")} | |
| lexhint | |
| = str:('adj.pert' | |
| / 'adj.all' | |
| / 'noun.Tops' | |
| / 'noun.act' | |
| / 'noun.animal' | |
| / 'noun.artifact' | |
| / 'noun.attribute' | |
| / 'noun.body' | |
| / 'noun.cognition' | |
| / 'noun.communication' | |
| / 'noun.event' | |
| / 'noun.feeling' | |
| / 'noun.food' | |
| / 'noun.group' | |
| / 'noun.location' | |
| / 'noun.motive' | |
| / 'noun.object' | |
| / 'noun.person' | |
| / 'noun.phenomenon' | |
| / 'noun.plant' | |
| / 'noun.possession' | |
| / 'noun.process' | |
| / 'noun.quantity' | |
| / 'noun.relation' | |
| / 'noun.shape' | |
| / 'noun.state' | |
| / 'noun.substance' | |
| / 'noun.time' | |
| / 'verb.body' | |
| / 'verb.change' | |
| / 'verb.cognition' | |
| / 'verb.communication' | |
| / 'verb.competition' | |
| / 'verb.consumption' | |
| / 'verb.contact' | |
| / 'verb.creation' | |
| / 'verb.emotion' | |
| / 'verb.motion' | |
| / 'verb.perception' | |
| / 'verb.possession' | |
| / 'verb.social' | |
| / 'verb.stative' | |
| / 'verb.weather' | |
| / 'adj.ppl') { return str } | |
| lexhint_location | |
| = str:"noun.location" {return str} | |
| location | |
| = word:word str:(! lexhint_location c:. )* hint:lexhint_location {return {word: word, lexhint: hint } } | |
| lexhint_weather | |
| = str:"noun.phenomenon" {return str} | |
| weather | |
| = word:word str:(! lexhint_weather c:. )* hint:lexhint_weather {return {word: word, lexhint: hint } } | |
| blank "blank" | |
| = " "+ {return " "} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment