wordnet

How do I print out just the word itself in a WordNet synset using Python NLTK?

你离开我真会死。 提交于 2019-12-01 17:12:20
Is there a way in Python 2.7 using NLTK to just get the word and not the extra formatting that includes "synset" and the parentheses and the "n.01" etc? For instance if I do wn.synsets('dog') My results look like: [Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), Synset('cad.n.01'), Synset('frank.n.02'), Synset('pawl.n.01'), Synset('andiron.n.01'), Synset('chase.v.01')] How can I instead get a list like this? dog frump cad frank pawl andiron chase Is there a way to do this using NLTK or do I have to use regular expressions ? Can I use regular expressions within a python script? If

Semantic Relatedness Algorithms - python [closed]

寵の児 提交于 2019-12-01 14:54:25
I want to find relatedness between two synsets and I came across many algorithms like resnik,lin,wu palmer,path algorithm,leacock chodorow etc. Can somebody tell me which one is most efficient among these algorithms? From a "show me an example" perspective, here's an example to show how you can use semantic similarity to perform WSD: from nltk.corpus import wordnet as wn from nltk.tokenize import word_tokenize def max_wupa(context_sentence, ambiguous_word): """ WSD by Maximizing Wu-Palmer Similarity. Perform WSD by maximizing the sum of maximum Wu-Palmer score between possible synsets of all

wordnet getDict() could not find Wordnet dictionary

本小妞迷上赌 提交于 2019-12-01 11:50:41
when using the following code to use the Lemmatizer algorithm from WordNet > initDict("C:/Program Files (x86)/WordNet/2.1/dict") [1] TRUE if(initDict("C:/Program Files (x86)/WordNet/2.1/dict")) getDict() I have the following error when trying to get the dictionary: Error in getDict() : could not find Wordnet dictionary Thanks! Carlos Gomes The problem is that the package is looking for the environment variable WNHOME Try this: > setDict("C:/Program Files (x86)/WordNet/2.1/dict") - getDict() [1] "Java-Object{com.nexagis.jawbone.Dictionary@46993aaa}" EDIT Adding OSX version brew install wordnet

Wordnet query to return example sentences

柔情痞子 提交于 2019-12-01 09:03:32
问题 I have a use case where I have a word and I need to know the following things: Synonyms for the word (just the synonyms are sufficient) All senses of the word, where each sense contains - the synonyms matching that word in that sense, example sentences in that sense (if there), the part of speech for that sense. Example - this query link. Screenshot for the word carry : For each 'sense', we have the part of speech (like V ), synonyms matching that sense, (like transport in the first sense,

sentiment analysis - wordNet , sentiWordNet lexicon

為{幸葍}努か 提交于 2019-12-01 05:17:19
I need a list of positive and negative words with the weights assigned to words according to how strong and week they are. I have got : 1.) WordNet - It gives a + or - score for every word. 2.) SentiWordNet - Giving positive and negative values in the range [0,1]. I checked these on few words, love - wordNet is giving 0.0 for both noun and verb, I dont know why i think it should be positive by at least some factor. repress - wordNet gives -9.93 - SentiWordNet gives - 0.0 for both pos and neg. (should be negative) repose - wordNet - 2.488 - SentiWordNet - { pos - 0.125, neg - 0.5 } (should be

sentiment analysis - wordNet , sentiWordNet lexicon

和自甴很熟 提交于 2019-12-01 02:13:40
问题 I need a list of positive and negative words with the weights assigned to words according to how strong and week they are. I have got : 1.) WordNet - It gives a + or - score for every word. 2.) SentiWordNet - Giving positive and negative values in the range [0,1]. I checked these on few words, love - wordNet is giving 0.0 for both noun and verb, I dont know why i think it should be positive by at least some factor. repress - wordNet gives -9.93 - SentiWordNet gives - 0.0 for both pos and neg.

Not getting the required output using Wordnet Synset's definition method

こ雲淡風輕ζ 提交于 2019-11-30 22:23:43
from nltk.corpus import wordnet syn=wordnet.synsets('cookbook')[0] print syn.definition Expected Output: 'a book of recipes and cooking directions' Actual Output: bound method Synset.definition of Synset('cookbook.n.01') I am unable to pinpoint the error in my code which is causing the difference between the actual output and the expected output. >>> from nltk.corpus import wordnet as wn >>> wn.synsets('dog')[0] Synset('dog.n.01') >>> wn.synsets('dog')[0].definition <bound method Synset.definition of Synset('dog.n.01')> >>> wn.synsets('dog')[0].definition() u'a member of the genus Canis

How to use word Net with php

爱⌒轻易说出口 提交于 2019-11-30 21:28:43
how to use word Net with php is there is any interface or any class for it..... i need to use wordnet for my dictionary purpose.... On the download page there's a download available with a command line tool. You could use this from php if you have exec enabled. http://wordnet.princeton.edu/wordnet/download/ This page links to this PHP API for WordNet. yea I can't get it work - I have Windows though, looks to be UNIX favored - you also must download the old version of Wordnet. Might be easier to just use WordNet's command line. 来源: https://stackoverflow.com/questions/2882217/how-to-use-word-net

split sentence without space in python (nltk?)

倾然丶 夕夏残阳落幕 提交于 2019-11-30 21:23:32
I have a set of concatenated word and i want to split them into arrays For example : split_word("acquirecustomerdata") => ['acquire', 'customer', 'data'] I found pyenchant , but it's not available for 64bit windows. Then i tried to split each string into sub string and then compare them to wordnet to find a equivalent word. For example : from nltk import wordnet as wn def split_word(self, word): result = list() while(len(word) > 2): i = 1 found = True while(found): i = i + 1 synsets = wn.synsets(word[:i]) for s in synsets: if edit_distance(s.name().split('.')[0], word[:i]) == 0: found = False

Generating the plural form of a noun

拈花ヽ惹草 提交于 2019-11-30 20:28:42
Given a word, which may or may not be a singular-form noun, how would you generate its plural form? Based on this NLTK tutorial and this informal list on pluralization rules, I wrote this simple function: def plural(word): """ Converts a word to its plural form. """ if word in c.PLURALE_TANTUMS: # defective nouns, fish, deer, etc return word elif word in c.IRREGULAR_NOUNS: # foot->feet, person->people, etc return c.IRREGULAR_NOUNS[word] elif word.endswith('fe'): # wolf -> wolves return word[:-2] + 'ves' elif word.endswith('f'): # knife -> knives return word[:-1] + 'ves' elif word.endswith('o')