| 216 | raise StopIteration |
| 217 | |
| 218 | class Lexicon(lazydict): |
| 219 | |
| 220 | def __init__(self, path="", morphology=None, context=None, entities=None, NNP="NNP", language=None): |
| 221 | """ A dictionary of words and their part-of-speech tags. |
| 222 | For unknown words, rules for word morphology, context and named entities can be used. |
| 223 | """ |
| 224 | self._path = path |
| 225 | self._language = language |
| 226 | self.morphology = Morphology(self, path=morphology) |
| 227 | self.context = Context(self, path=context) |
| 228 | self.entities = Entities(self, path=entities, tag=NNP) |
| 229 | |
| 230 | def load(self): |
| 231 | # Arnold NNP x |
| 232 | dict.update(self, (x.split(" ")[:2] for x in _read(self._path))) |
| 233 | |
| 234 | @property |
| 235 | def path(self): |
| 236 | return self._path |
| 237 | |
| 238 | @property |
| 239 | def language(self): |
| 240 | return self._language |
| 241 | |
| 242 | #--- MORPHOLOGICAL RULES --------------------------------------------------------------------------- |
| 243 | # Brill's algorithm generates lexical (i.e., morphological) rules in the following format: |
no outgoing calls
no test coverage detected
searching dependent graphs…