generativepoetry.lexigen.contextually_linked_word(input_word: str, datamuse_api_max: Optional[int] = 10) → Optional[str]

Return a random word that frequently appear within the same document as a given word if at least one can be found using the Datamuse API.

Parameters
  • input_word – the word which this function is looking up a contextually linked words to

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar sounding (according to a numeric score provided by Datamuse).

generativepoetry.lexigen.contextually_linked_words(input_val: str_or_list_of_str, sample_size: Optional[int] = 6, datamuse_api_max: Optional[int] = 20) → list

Return a list of words that frequently appear within the same document as a given word, in randomized order, if at least one can be found using the Datamuse API.

Parameters
  • input_val – the word or words in relation to which this function is looking up contextually linked words

  • sample_size – If provided, return a random sample of this many elements. If this number is greater than the length of the API results, then just return a shuffled copy of the filtered API results.

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least frequently coappearing (according to a numeric score provided by Datamuse), hence by using both parameters, one can control the size of both the sample pool and the sample size.

generativepoetry.lexigen.extract_sample(word_list: list, sample_size: Optional[int] = None) → list

Returns a random sample from the word list or a shuffled copy of the word list.

Parameters
  • word_list – the list of words to extract the random sample of k

  • sample_size – If this number is greater than the length of the word list, then just return a shuffled copy of the word list.

generativepoetry.lexigen.frequently_following_word(input_word, datamuse_api_max=10) → Optional[str]

Return a random word that frequently follows the given word if at least one can be found using the Datamuse API.

Parameters
  • input_word – the word which this function is looking up a frequently following word of

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar sounding (according to a numeric score provided by Datamuse).

generativepoetry.lexigen.frequently_following_words(input_val: str_or_list_of_str, sample_size: Optional[int] = 8, datamuse_api_max: Optional[int] = None) → list

Return a list of words that frequently follow the given word, in randomized order, if at least one can be found using the Datamuse API.

Parameters
  • input_val – the word or words in relation to which this function is looking up frequently following words

  • sample_size – If provided, return a random sample of this many elements. If this number is greater than the length of the API results, then just return a shuffled copy of the filtered API results.

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least frequently coappearing (according to a numeric score provided by Datamuse), hence by using both parameters, one can control the size of both the sample pool and the sample size.

Returns a list of rhymes and similar sounding words to a word or list of words.

Parameters
  • input_val – the word or words in relation to which this function is looking up phonetically related words

  • sample_size – If provided, pass this argument to the functions rhymes and similar_sounding_words so that twice this number of elements are returned by this function. If not provided, the function will return all rhymes plus however many API results similar_sounding_words.

  • datamuse_api_max – specifies how many API results can be returned by the API client when fetching similar meaning words.

generativepoetry.lexigen.related_rare_word(input_word: str, rare_word_population_max: int = 10) → Optional[str]

Return a random rare related word to a given word. The word can be related phonetically, contextually, or by meaning).

Parameters
  • input_word – the word which this function is looking up related rare words to

  • rare_word_population_max – specifies the maximum number of related words to subsample from. The rare word population is sorted from rarest to most common.

generativepoetry.lexigen.related_rare_words(input_val: str_or_list_of_str, sample_size: Optional[int] = 8, rare_word_population_max: int = 20) → list

Return a random sample of rare related words to a given word. The words can be related phonetically, contextually, or by meaning).

Parameters
  • input_val – the word or words in relation to which this function is looking up related rare words

  • sample_size – If provided, return a random sample of this many elements. If this number is greater than the length of rare word population size, then just return a shuffled copy of that.

  • rare_word_population_max – specifies the maximum number of related words to subsample from per word.

` The rare word population is sorted from rarest to most common. If sample_size is

null, the max results returned by this function is 2 times this number.

generativepoetry.lexigen.rhyme(input_word: str) → Optional[str]

Return a random rhyme for a given word if at least one can be found using the pronouncing module (which uses the CMU rhyming dictionary).

Parameters

input_word – the word which this function is looking up a rhyme of

generativepoetry.lexigen.rhymes(input_val: str_or_list_of_str, sample_size=None) → List[str]

Return a list of rhymes in randomized order for a given word if at least one can be found using the pronouncing module (which uses the CMU rhyming dictionary).

Parameters
  • input_val – the word or words in relation to which this function is looking up rhymes

  • size (sample) – If provided, return a random sample of this many elements. If this number is greater than the length of the rhyme list, then just return a shuffled copy of the rhyme list.

generativepoetry.lexigen.similar_meaning_word(input_word: str, datamuse_api_max: Optional[int] = 10) → Optional[str]

Return a random similar meaning word for a given word if at least one can be found using the Datamuse API.

Parameters
  • input_word – the word which this function is looking up a similar meaning words of

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar meaning (according to a numeric score provided by Datamuse).

generativepoetry.lexigen.similar_meaning_words(input_val: str_or_list_of_str, sample_size: Optional[int] = 6, datamuse_api_max: Optional[int] = 20) → list

Return a list of similar meaning words to a given word, in randomized order, if at least one can be found using Datamuse API.

Parameters
  • input_val – the word or words in relation to which this function is looking up similar meaning words

  • sample_size – If provided, return a random sample of this many elements. If this number is greater than the length of the API results, then just return a shuffled copy of the filtered API results.

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar meaning (according to a numeric score provided by Datamuse), hence by using both parameters, one can control the size of both the sample pool and the sample size.

generativepoetry.lexigen.similar_sounding_word(input_word: str, datamuse_api_max: Optional[int] = 20) → Optional[str]

Return a random similar sounding word for a given word if at least one can be found using the Datamuse API.

Parameters
  • input_word – the word which this function is looking up a similar sounding words of

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar sounding (according to a numeric score provided by Datamuse).

generativepoetry.lexigen.similar_sounding_words(input_val: str_or_list_of_str, sample_size: Optional[int] = 6, datamuse_api_max: Optional[int] = 50) → list

Return a list of similar sounding words to a given word, in randomized order, if at least one can be found using Datamuse API.

Parameters
  • input_val – the word or words in relation to which this function is looking up similar sounding words

  • sample_size – If provided, return a random sample of this many elements. If this number is greater than the length of the API results, then just return a shuffled copy of the filtered API results.

  • datamuse_api_max – specifies the maximum number of results returned by the API. The API client’s results are always sorted from most to least similar sounding (according to a numeric score provided by Datamuse), hence by using both parameters, one can control the size of both the sample pool and the sample size.