Linking Word and Text using python and NLP

I have a word according to which I want to find out if the text is associated with this word or not using python and nltk .

For example, I have a word called phosphorous . I would like to know if a particular text file is associated with this word or not ?

I can’t use the word pack in nltk since I have only one word and no learning data.

Any suggestions?

Thanks at Advance.

+5
source share
2 answers

Not without a body, no.

Look at it like this: can you, a rational being, say whether 光 is related to 部屋 に 入 っ た 時 電 気 を つ け ま し し た without asking someone or something that really knows Japanese (assuming that you don’t know Japanese; if you do, try with "svjetlo" and "Kad je ušao u sobu, upalio je lampu"). If you cannot, how do you expect the computer to do this?

And one more experiment - can you, a rational being, give me an algorithm with which you can teach a non-English-speaking person that “light” is connected with “When he entered the room, he turned on the lamp” ,? Again, no.

tl; dr: you need training data if you do not significantly limit the meaning of “siblings” (for example, “contains”).

+5
source

You can use nltk wordnet to calculate the similarity between a word and words in another text and evaluate the heuristic based on this indicator:

from nltk.corpus import wordnet as wn hit = wn.synset('hit.v.01') slap = wn.synset('slap.v.01') wn.path_similarity(hit, slap)

The following is an example of using nltk word-net: http://www.nltk.org/howto/wordnet.html

+2
source

Source: https://habr.com/ru/post/1201696/


All Articles