class documentation
class ContextIndex(object): (source)
Constructor: ContextIndex(tokens, context_func, filter, key)
A bidirectional index between words and their 'contexts' in a text. The context of a word is usually defined to be the words that occur in a fixed window around the word; but other definitions may also be used by providing a custom context function.
Method | __init__ |
Undocumented |
Method | common |
Find contexts where the specified words can all appear; and return a frequency distribution mapping each context to the number of times that context was used. |
Method | similar |
Undocumented |
Method | tokens |
No summary |
Method | word |
Return a dictionary mapping from words to 'similarity scores,' indicating how often these two words occur in the same context. |
Static Method | _default |
One left token and one right token, normalized to lowercase |
Instance Variable | _context |
Undocumented |
Instance Variable | _context |
Undocumented |
Instance Variable | _key |
Undocumented |
Instance Variable | _tokens |
Undocumented |
Instance Variable | _word |
Undocumented |
Find contexts where the specified words can all appear; and return a frequency distribution mapping each context to the number of times that context was used.
Parameters | |
words:str | The words used to seed the similarity search |
fail | If true, then raise a value error if any of the given words do not occur at all in the index. |
Return a dictionary mapping from words to 'similarity scores,' indicating how often these two words occur in the same context.