Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers.
(self, term, **kwargs)
| 298 | self._values[term] = value |
| 299 | |
| 300 | def classify(self, term, **kwargs): |
| 301 | """ Returns the (most recently added) semantic type for the given term ("many" => "quantity"). |
| 302 | If the term is not in the dictionary, try Taxonomy.classifiers. |
| 303 | """ |
| 304 | term = self._normalize(term) |
| 305 | if dict.__contains__(self, term): |
| 306 | return self[term][0].keys()[-1] |
| 307 | # If the term is not in the dictionary, check the classifiers. |
| 308 | # Returns the first term in the list returned by a classifier. |
| 309 | for classifier in self.classifiers: |
| 310 | # **kwargs are useful if the classifier requests extra information, |
| 311 | # for example the part-of-speech tag. |
| 312 | v = classifier.parents(term, **kwargs) |
| 313 | if v: |
| 314 | return v[0] |
| 315 | |
| 316 | def parents(self, term, recursive=False, **kwargs): |
| 317 | """ Returns a list of all semantic types for the given term. |