A list of rules based on context (preceding and following words).
(self, lexicon={}, path="")
| 313 | class Context(lazylist, Rules): |
| 314 | |
| 315 | def __init__(self, lexicon={}, path=""): |
| 316 | """ A list of rules based on context (preceding and following words). |
| 317 | """ |
| 318 | cmd = ("prevtag", # Preceding word is tagged x. |
| 319 | "nexttag", # Following word is tagged x. |
| 320 | "prev2tag", # Word 2 before is tagged x. |
| 321 | "next2tag", # Word 2 after is tagged x. |
| 322 | "prev1or2tag", # One of 2 preceding words is tagged x. |
| 323 | "next1or2tag", # One of 2 following words is tagged x. |
| 324 | "prev1or2or3tag", # One of 3 preceding words is tagged x. |
| 325 | "next1or2or3tag", # One of 3 following words is tagged x. |
| 326 | "surroundtag", # Preceding word is tagged x and following word is tagged y. |
| 327 | "curwd", # Current word is x. |
| 328 | "prevwd", # Preceding word is x. |
| 329 | "nextwd", # Following word is x. |
| 330 | "prev1or2wd", # One of 2 preceding words is x. |
| 331 | "next1or2wd", # One of 2 following words is x. |
| 332 | "next1or2or3wd", # One of 3 preceding words is x. |
| 333 | "prev1or2or3wd", # One of 3 following words is x. |
| 334 | "prevwdtag", # Preceding word is x and tagged y. |
| 335 | "nextwdtag", # Following word is x and tagged y. |
| 336 | "wdprevtag", # Current word is y and preceding word is tagged x. |
| 337 | "wdnexttag", # Current word is x and following word is tagged y. |
| 338 | "wdand2aft", # Current word is x and word 2 after is y. |
| 339 | "wdand2tagbfr", # Current word is y and word 2 before is tagged x. |
| 340 | "wdand2tagaft", # Current word is x and word 2 after is tagged y. |
| 341 | "lbigram", # Current word is y and word before is x. |
| 342 | "rbigram", # Current word is x and word after is y. |
| 343 | "prevbigram", # Preceding word is tagged x and word before is tagged y. |
| 344 | "nextbigram", # Following word is tagged x and word after is tagged y. |
| 345 | ) |
| 346 | Rules.__init__(self, lexicon, dict.fromkeys(cmd, True)) |
| 347 | self._path = path |
| 348 | |
| 349 | @property |
| 350 | def path(self): |