Print en.verb. This python library is able to conjugate verbs, and recognize whether a word is a verb, noun, or adjective.ĮXAMPLE CODE print en.verb.present("gave") I understand that this doesn't answer your whole question, but it does answer a large part of it. Hope this is able to save someone a little trouble Solution 3 It's unable to switch between adjective and adverb form (my specific goal), but it does give some interesting results in other cases. If l.synset().name().split('.') = to_pos or to_pos in (WN_ADJECTIVE, WN_ADJECTIVE_SATELLITE) and l.synset().name().split('.') in (WN_ADJECTIVE, WN_ADJECTIVE_SATELLITE):Īs you can see below, it doesn't work so great. # filter only the desired pos (consider 'a' and 's' equivalent) If s.name().split('.') = from_pos or from_pos in (WN_ADJECTIVE, WN_ADJECTIVE_SATELLITE) and s.name().split('.') in (WN_ADJECTIVE, WN_ADJECTIVE_SATELLITE):ĭerivationally_related_forms = # Get all lemmas of the word (consider 'a'and 's' equivalent) """ Transform words given from/to POS tags """ Here is a function that is in theory able to convert words between noun/verb/adjective/adverb form that I updated from here (originally written by bogs, I believe) to be compliant with nltk 3.2.5 now that synset.lemmas and sysnset.name are functions. # return all the possibilities sorted by probability # Build the result in the form of a list containing tuples (word, probability) Related_noun_lemmas = Verb_synsets = wn.synsets(verb_word, pos="v")įor l in s.lemmas if s.name.split('.') = 'v']ĭerivationally_related_forms = [(l, l.derivationally_related_forms()) \ """ Transform a verb to the closest noun: die -> death """ From what I've tested works pretty well: from rpus import wordnet as wn It uses the derivationally_related_forms() from wordnet. I have just coded it so appologies for the style. draw (q, wordnet.This is more a heuristic approach. ![]() You can use it to quickly visualise WordNet: wordnet = ximport ( "wordnet" ) from wordnet import explodeįont ( "Georgia-BoldItalic", 10 ) fill ( 0.3 )Įxplode. The NodeBox WordNet library has a small gizmo bundled in called explode (you won't find it in the Linguistics library however). all_nouns ( ) )Īll of the commands shown here for nouns are also available for verbs, adjectives and adverbs, verb_hypernyms("run"), djective_gloss("beautiful") etc. If you want a list of all nouns/verbs/adjectives/adverbs there's the wordnet.all_nouns(), wordnet.all_verbs(). You can use the wordnet.flatten() command to flatten the list: print wordnet. The return value of a WordNet command is usually a list containing other lists of related words. The noun_absurd_gloss() returns an absurd description for the word: print wordnet. noun_antonym ( "black" )įind out what two words have in common: print wordnet. The noun_antonym() returns the semantic opposite of the word: print wordnet. The noun_meronym() command returns the collection in which the given word can be found: print wordnet. > [ 'central processing unit', 'CPU', 'C.P.U.', 'central processor', The noun_holonym() command returns components of the given word: print wordnet. I am confused about these nouns, like decision and suggestion. But I also find that not all the nouns related to verbs are formed by adding -ing to them. For example: read reading interest interesting talk talking. Notice how returned values become more and more abstract: print wordnet. I was told that if I put an -ing to the end of a verb, the verb could become an adjective or a noun. You can also execute a deep query with noun_hypernyms() and noun_hyponyms(). The noun_hypernym() command returns abstractions of the given word: print wordnet. The noun_hyponym() command returns examples of the given word: print wordnet. The noun_lexname() command returns a categorization for the given word: print wordnet. > a figure that branches from a single root "genealogical tree" > bound together ) "I am reading a good book on economics"Ī word can have multiple senses, for example "tree" can mean a tree in a forest but also a tree diagram, or a person named Sir Herbert Beerbohm Tree. > a written work or composition that has been published (printed on pages The noun_gloss() command returns the dictionary description of a word: print wordnet. WordNet describes semantic relations between synonym sets. You can also put it in ~/Library/Application Support/NodeBox/ so all scripts can find it. Put the wordnet library folder in the same folder as your script so NodeBox can find the library. If you need more linguistical power we recommend trying out that library. This library is part of the NodeBox Linguistics library. ![]() Wordnet knows that black is the opposite of white, that birds are animals. WordNet is a dictionary of nouns, verbs, adverbs, adjectives, and their lexical relations: definition, different interpretations, category, and examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |