class documentation

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_contexts 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_words Undocumented
Method tokens No summary
Method word_similarity_dict Return a dictionary mapping from words to 'similarity scores,' indicating how often these two words occur in the same context.
Static Method _default_context One left token and one right token, normalized to lowercase
Instance Variable _context_func Undocumented
Instance Variable _context_to_words Undocumented
Instance Variable _key Undocumented
Instance Variable _tokens Undocumented
Instance Variable _word_to_contexts Undocumented
def __init__(self, tokens, context_func=None, filter=None, key=(lambda x: x)): (source)

Undocumented

def common_contexts(self, words, fail_on_unknown=False): (source)

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:strThe words used to seed the similarity search
fail_on_unknownIf true, then raise a value error if any of the given words do not occur at all in the index.
def similar_words(self, word, n=20): (source)

Undocumented

def tokens(self): (source)
Returns
list(str)The document that this context index was created from.
def word_similarity_dict(self, word): (source)

Return a dictionary mapping from words to 'similarity scores,' indicating how often these two words occur in the same context.

@staticmethod
def _default_context(tokens, i): (source)

One left token and one right token, normalized to lowercase

_context_func = (source)

Undocumented

_context_to_words = (source)

Undocumented

Undocumented

Undocumented

_word_to_contexts = (source)

Undocumented