sinatools.synonyms.synonyms_generator

sinatools.synonyms.synonyms_generator.extend_synonyms(synset, level)

This method receives a set of one or more synonyms and a level number, then extends this set with additional synonyms. The more synonyms in the input, the more accurate in the results. Each synonym in the output is assigned a fuzzy value to indicate how much it is likely to be a synonymy. You can try the demo online. Read the article for more details.

Parameters
  • synset (str) – A set of initial synonyms to be extended (string of synonyms seperated by |).

  • level (int) – The level number indicates the depth of the synonym graph that the method should explore. The level could be 2 or 3. The 3rd level is richer, but the 2nd is faster.

Returns

A list of lists, where each list could be contains:
  • synonym: Synonym related to the given synset (set of synonyms).
  • fuzzy_value: The synonyms strength as a percentage out of 100.

Return type

list (list)

Example:

from sinatools.synonyms.synonyms_generator import extend_synonyms

extend_synonyms('ممر | طريق',2)
[["مَسْلَك","61%"],["سبيل","61%"],["وَجْه","30%"],["نَهْج", "30%"],["نَمَطٌ","30%"],["مِنْهَج","30%"],["مِنهاج", "30%"],["مَوْر","30%"],["مَسَار","30%"],["مَرصَد", "30%"],["مَذْهَبٌ","30%"],["مَدْرَج","30%"],["مَجَاز","30%"]]

Note

The models should be installed using (download_files -f synonyms) command.

sinatools.synonyms.synonyms_generator.evaluate_synonyms(synset, level)

This method receives a set of synonyms and a level number, then evaluates how much each of these input synonyms is really a synonym (i.e., how much it belongs to the set). You can try the demo online.

Parameters
  • synset (str) – A set of initial synonyms to be evaluated (string of synonyms seperated by |).

  • level (int) – The level number indicating the depth of synonym graph that the method will explore, which could be 2 or 3.

Returns

A list of lists, where each list could be contains:
  • synonym: The input synonym.
  • fuzzy_value: The synonyms strength as a percentage out of 100.

Return type

list (list)

Example:

from sinatools.synonyms.synonyms_generator import evaluate_synonyms
  
evaluate_synonyms('ممر | طريق | مَسْلَك | سبيل')
[["مَسْلَك","61%"],["سبيل","60%"],["طريق","40%"],["ممر", "40%"]]