| 380 | #--- TAXONOMY CLASSIFIER --------------------------------------------------------------------------- |
| 381 | |
| 382 | class Classifier(object): |
| 383 | |
| 384 | def __init__(self, parents=lambda term: [], children=lambda term: [], value=lambda term: None): |
| 385 | """ A classifier uses a rule-based approach to enrich the taxonomy, for example: |
| 386 | c = Classifier(parents=lambda term: term.endswith("ness") and ["quality"] or []) |
| 387 | taxonomy.classifiers.append(c) |
| 388 | This tags any word ending in -ness as "quality". |
| 389 | This is much shorter than manually adding "roughness", "sharpness", ... |
| 390 | Other examples of useful classifiers: calling en.wordnet.Synset.hyponyms() or en.number(). |
| 391 | """ |
| 392 | self.parents = parents |
| 393 | self.children = children |
| 394 | self.value = value |
| 395 | |
| 396 | # Classifier(parents=lambda word: word.endswith("ness") and ["quality"] or []) |
| 397 | # Classifier(parents=lambda word, chunk=None: chunk=="VP" and [ACTION] or []) |
no outgoing calls
searching dependent graphs…