foley.index.taxonomy.text#
The UCS term index: every row’s terms, with the vocabulary’s inflections.
Matching runs over a closed vocabulary: the words of the table’s subcategories,
category names and synonyms. Instead of stemming the query (which mangles words:
golden -> gold, news -> new), the index lists the regular inflections
of every vocabulary word (inflections(): -s/-es/-ies, -ing,
-ed, with the final e dropped and a final consonant doubled where English
does), so a query word is only lowercased and looked up: "rattling" meets the
rattle synonym, "screens" the screen one, and "chicken" never meets
chick. Vocabulary words that are inflections of each other (door and
doors, the DOORS category) share one lemma, so either spelling meets both.
Module Attributes
Shorter vocabulary words are not inflected ( |
|
Vocabulary words that look like a regular inflection of another but are not ( |
Functions
|
Index the subcategory, synonyms and category name of each |
|
|
|
The regular inflections of |
Classes
|
One matchable term of a UCS row: its words, their lemmas, and where it came from. |
|
A table's terms keyed by lemma, the surface-form lexicon, and term sharing. |
- foley.index.taxonomy.text.MIN_INFLECTED_LENGTH = 3#
Shorter vocabulary words are not inflected (
be+disbed).
- foley.index.taxonomy.text.NOT_INFLECTIONS: frozenset = frozenset({'bearing', 'casing', 'copses', 'earing', 'lemming', 'news', 'rugged', 'seed', 'singed', 'thing', 'tired', 'weed', 'wicked', 'winding'})#
Vocabulary words that look like a regular inflection of another but are not (
newsis not the plural ofnew,thingnotthe+-ing, awindingroad not theWIND): never linked to that other word.
- class foley.index.taxonomy.text.Term(catid, words, lemmas, kind)[source]#
Bases:
objectOne matchable term of a UCS row: its words, their lemmas, and where it came from.
kindis"subcategory","synonym"or"category".
- class foley.index.taxonomy.text.TermIndex(by_lemma, lexicon, row_count)[source]#
Bases:
objectA table’s terms keyed by lemma, the surface-form lexicon, and term sharing.
- lexicon#
surface word (a vocabulary word or an inflection of one) -> its lemmas.
- row_count#
a term’s lemmas -> in how many rows it appears, whatever its kind.
- foley.index.taxonomy.text.build_term_index(rows, *, inflect=<function inflections>, not_inflections=frozenset({'bearing', 'casing', 'copses', 'earing', 'lemming', 'news', 'rugged', 'seed', 'singed', 'thing', 'tired', 'weed', 'wicked', 'winding'}))[source]#
Index the subcategory, synonyms and category name of each
UcsRowinrows.A row lists a term once per kind, so a word that is both its category name and one of its synonyms counts as both. A category name is one term, on the category’s representative row (
category_rows()); a matcher lends it to the category’s other rows.inflectgives a word’s inflections (defaultinflections());not_inflectionsare words never read as an inflection (defaultNOT_INFLECTIONS).- Return type:
- foley.index.taxonomy.text.category_rows(rows)[source]#
category -> CatIDof the row a category name alone lands on: its first generic (GENERAL/MISC) row, else its first row.
- foley.index.taxonomy.text.inflections(word)[source]#
The regular inflections of
word(worditself excluded).>>> sorted(inflections("rattle")) ['rattled', 'rattles', 'rattling'] >>> sorted(inflections("drip")), sorted(inflections("buzz")) (['dripped', 'dripping', 'drips'], ['buzzed', 'buzzes', 'buzzing']) >>> sorted(inflections("cry")), sorted(inflections("open")) (['cried', 'cries', 'crying'], ['opened', 'opening', 'opens']) >>> inflections("up") frozenset()