Source code for pythainlp.corpus.wordnet

# -*- coding: utf-8 -*-
"""
NLTK WordNet wrapper

API here is exactly the same as NLTK API,
except that lang (language) argument will be "tha" (Thai) by default.
"""
import nltk

try:
    nltk.data.find("corpora/omw")
except LookupError:
    nltk.download("omw")

try:
    nltk.data.find("corpora/wordnet")
except LookupError:
    nltk.download("wordnet")

from nltk.corpus import wordnet


[docs]def synsets(word: str, pos: str = None, lang: str = "tha"): return wordnet.synsets(lemma=word, pos=pos, lang=lang)
[docs]def synset(name_synsets): return wordnet.synset(name_synsets)
[docs]def all_lemma_names(pos: str = None, lang: str = "tha"): return wordnet.all_lemma_names(pos=pos, lang=lang)
[docs]def all_synsets(pos: str = None): return wordnet.all_synsets(pos=pos)
[docs]def langs(): return wordnet.langs()
[docs]def lemmas(word: str, pos: str = None, lang: str = "tha"): return wordnet.lemmas(word, pos=pos, lang=lang)
[docs]def lemma(name_synsets): return wordnet.lemma(name_synsets)
[docs]def lemma_from_key(key): return wordnet.lemma_from_key(key)
[docs]def path_similarity(synsets1, synsets2): return wordnet.path_similarity(synsets1, synsets2)
[docs]def lch_similarity(synsets1, synsets2): return wordnet.lch_similarity(synsets1, synsets2)
[docs]def wup_similarity(synsets1, synsets2): return wordnet.wup_similarity(synsets1, synsets2)
[docs]def morphy(form, pos: str = None): return wordnet.morphy(form, pos=None)
[docs]def custom_lemmas(tab_file, lang: str): return wordnet.custom_lemmas(tab_file, lang)