def get_wordnet_pos(pos_tag): if pos_tag.startswith('J'): return 'a' elif pos_tag.startswith('V'): return 'v' elif pos_tag.startswith('R'): return 'r' # adverb else: return 'n'
def penn_to_wn_tags(pos_tag): if pos_tag.startswith('J'): return wn.ADJ elif pos_tag.startswith('V'): return wn.VERB elif pos_tag.startswith('N'): return wn.NOUN elif pos_tag.startswith('R'): return wn.ADV else: return None
def get_wordnet_pos(pos_tag): if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def convert_tags(pos_tag): if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return None
def pos_to_wordnet(pos_tag): # print(pos_tag) if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('R'): return wordnet.ADJ else: return wordnet.NOUN
def pos_to_wordnet(self, pos_tag): if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('V'): return wordnet.VERB # elif pos_tag.startswith('M'): # return wordnet.MODAL # elif pos_tag.startswith('R'): # return wordnet.ADVERB else: return wordnet.NOUN
def wordnet_pos(pos_tag): '''Tags for the words in articles ''' '''Used for lemmatizer ''' if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def get_wordnet_pos( pos_tag ): #POS tags are used in corpus searches and in text analysis tools and algorithms if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def penn_to_wn_tags(pos_tag): """Translates Penn treebanks tags into Wordnet abbreviations for POS""" if pos_tag.startswith('J'): return wn.ADJ elif pos_tag.startswith('V'): return wn.VERB elif pos_tag.startswith('N'): return wn.NOUN elif pos_tag.startswith('R'): return wn.ADV else: return None
def get_wordnet_pos(pos_tag): ''' returns the wordnet object value corresponding to the POS tag ''' if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def get_wordnet_pos(pos_tag): """ Returns the wordnet object value corresponding to the POS tag """ #nltk.download('wordnet') if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('V'): return wordnet.VERB elif pos_tag.startswith('N'): return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def get_wordnet_pos(pos_tag): """ Parameters: pos_tag: Word POS tag Returns: wordnet pos tag(for example, 'n','r','j') """ if pos_tag.startswith('J'): return wordnet.ADJ elif pos_tag.startswith('R'): return wordnet.ADV else: return wordnet.NOUN
def stopword_(text): tag_list = pos_tag(nltk.word_tokenize(text), tagset=None) stop = stopwords.words('english') lema = wordnet.WordNetLemmatizer() lema_word = [] for token, pos_tag in tag_list: if token in stop: continue elif pos_tag.startswith('V'): pos_val = "v" elif pos_tag.startswith("J"): pos_val = "a" elif pos_tag.startswith("R"): pos_val = "r" else: pos_val = 'n' lema_token = lema.lemmatize(token, pos_tag) lema_word.append(lema_token) return "".join(lema_word)
def get_wordnet_pos(pos_tag): # if pos tag starts with 'J' if pos_tag.startswith('J'): # return wordnet tag "ADJ" return wordnet.ADJ # if pos tag starts with 'V' elif pos_tag.startswith('V'): # return wordnet tag "VERB" return wordnet.VERB # if pos tag starts with 'N' elif pos_tag.startswith('N'): # return wordnet tag "NOUN" return wordnet.NOUN elif pos_tag.startswith('R'): return wordnet.ADV else: # be default, return wordnet tag "NOUN" return wordnet.NOUN
def filter_for_wordnet(tagged_sentence): return [(word, pos_tag) for (word, pos_tag) in tagged_sentence if pos_tag.startswith('NN') or pos_tag.startswith('VB') or pos_tag.startswith('RB') or pos_tag.startswith('JJ')]