| |
Methods defined here:
- __getitem__(self, item)
- Shortcut for Get(self,item,None)
:param item: target word.
:return:(List) candidates HowNet annotation, if the target word does not exist, return an empty list.
- __init__(self, use_sim=False)
- Initialize HowNetDict
:param use_sim: "lazy" option for loading similarity computation file.
- __len__(self)
- __str__(self)
- Return str(self).
- calculate_word_similarity(self, word0, word1)
- calculate the word similarity between two words via sememes
:param word0: target word #0
:param word1: target word #1
:return: (Float) the word similarity calculated via sememes.
If word0 or word1 does not exist in HowNet annotation, it will return 0.0
If the initialization method of word similarity calculation has not been called yet, it will also return 0.0 and print corresponding error message.
- get(self, word, language=None)
- Common word search API, you can specify the language of the target word to boost the search performance
:param word: target word
:param language: target language, default: None
(The func will search both in English and Chinese, which will consume a lot of time.)
:return:(List) candidates HowNet annotation, if the target word does not exist, return an empty list.
- get_all_sememes(self)
- Get the complete sememe list in HowNet
:return: (List) a list of sememes
- get_ch_words(self)
- Get all Chinese words annotated in HowNet
:return: (list) All annotated Chinese words in HowNet.
- get_en_words(self)
- Get all English words annotated in HowNet
:return: (list) All annotated English words in HowNet.
- get_nearest_words_via_sememes(self, word, K=10)
- Get the topK nearest words of the given word, the word similarity is calculated based on HowNet annotation.
If the given word does not exist in HowNet annotations, this function will return an empty list.
:param word: target word
:param K: specify the number of the nearest words you want to retrieve.
:return: (List) a list of the nearest K words.
If the given word does not exist in HowNet annotations, this function will return an empty list.
If the initialization method of word similarity calculation has not been called yet, it will also return an empty list and print corresponding error message.
- get_sememes_by_word(self, word, structured=False, lang='zh', merge=False, expanded_layer=-1)
- Given specific word, you can get corresponding HowNet annotation.
:param word: (str)specific word(en/zh/id) you want to search in HowNet.
You can use "I WANT ALL" or "*" to specify that you need annotations of all words.
:param structured: (bool)whether you want to retrieve structured sememe trees
:param lang: (str)only works when structured == False. You can determine the language of the name of every sememe node in the retrieved tree.
There are two options("en"/"zh") for this param.
:param merge: (boolean)only works when structured == False. Decide whether to merge multi-sense word query results into one
:param expanded_layer: (int)only works when structured == False. Continously expand k layer
By default, it will be set to -1 (expand full layers)
:return: list of converted sememe trees in accordance with requirements specified by the params
- has(self, item, language=None)
- Check that whether certain word(English Word/Chinese Word/ID) exist in HowNet
Only perform exact match because HowNet is case-sensitive
By default, it will search the target word in both the English vocabulary and the Chinese vocabulary
:param item: target word to be searched in HowNet
:param language: specify the language of the target search word
:return:(Boolean) whether the word exists in HowNet annotation
- initialize_sememe_similarity_calculation(self)
- Initialize the word similarity calculation via sememes.
Implementation is contributed by Jun Yan, which is based on the paper :
"Jiangming Liu, Jinan Xu, Yujie Zhang. An Approach of Hybrid Hierarchical Structure for Word Similarity Computing by HowNet. In Proceedings of IJCNLP"
:return: (Boolean) whether the initialization succeed.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- name_choices = ['name_en', 'name_ch', 'all']
|