का उपयोग करके समानार्थी, परिभाषाएं और उदाहरण वाक्य खोजने के लिए मुझे एक शब्द के साथ एक इनपुट टेक्स्ट फ़ाइल लेने की आवश्यकता है। इसके बाद मुझे wordnet का उपयोग करके शब्द के synset के lemma_names, परिभाषा और उदाहरण खोजने की आवश्यकता है। मैं पुस्तक के माध्यम से गया हूं: "इस दिशा में मेरी सहायता के लिए" एनएलटीके 2.0 कुकबुक के साथ पायथन टेक्स्ट प्रोसेसिंग "और" एनएलटीके का उपयोग करके प्राकृतिक भाषा प्रसंस्करण "भी। हालांकि मुझे समझ में आया है कि यह टर्मिनल का उपयोग करके कैसे किया जा सकता है, मैं टेक्स्ट एडिटर का उपयोग करके ऐसा करने में सक्षम नहीं हूं।वर्डनेट
उदाहरण के लिए, यदि इनपुट पाठ शब्द "हैरत में डाला हुआ" है, उत्पादन इस फैशन में होने की जरूरत है:
हैरत में डाला हुआ (क्रिया) हैरत में डालना, संदेह, पर कटोरा - विस्मय के साथ काबू पाने; "यह दिमाग को चकमा देता है!" (विशेषण) डंबफॉल्ड, डमफॉल्ड, फ्लैबबर्गस्टेड, बेवकूफ, थंडरस्ट्रक, डंबस्ट्रुक, डंबस्ट्रिकन - जैसे कि आश्चर्य और आश्चर्य के साथ गूंगा मारा; "दुर्घटना को देखने से इनकार करने से पुलिस का एक चक्र डूब गया था"; "flabbergasted aldermen भाषणहीन थे"; "उनके पदोन्नति की खबरों से आंधी थी"
synsets, परिभाषाएं और उदाहरण वाक्यों को WordNet से सीधे प्राप्त किया जाता है!
मैं कोड का निम्न भाग:
from __future__ import division
import nltk
from nltk.corpus import wordnet as wn
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
fp = open("inpsyn.txt")
data = fp.read()
#to tokenize input text into sentences
print '\n-----\n'.join(tokenizer.tokenize(data))# splits text into sentences
#to tokenize the tokenized sentences into words
tokens = nltk.wordpunct_tokenize(data)
text = nltk.Text(tokens)
words = [w.lower() for w in text]
print words #to print the tokens
for a in words:
print a
syns = wn.synsets(a)
print "synsets:", syns
for s in syns:
for l in s.lemmas:
print l.name
print s.definition
print s.examples
मैं निम्नलिखित उत्पादन:
flabbergasted
['flabbergasted']
flabbergasted
synsets: [Synset('flabbergast.v.01'), Synset('dumbfounded.s.01')]
flabbergast
boggle
bowl_over
overcome with amazement
['This boggles the mind!']
dumbfounded
dumfounded
flabbergasted
stupefied
thunderstruck
dumbstruck
dumbstricken
as if struck dumb with astonishment and surprise
['a circle of policement stood dumbfounded by her denial of having seen the accident', 'the flabbergasted aldermen were speechless', 'was thunderstruck by the news of his promotion']
वहाँ लेम्मा नामों में से समूह के साथ भाषण का भाग प्राप्त करने के लिए एक तरीका है?
तुम वापस में करने के लिए हां, तो आप एंड्री के स्वीकार करना चाहिए लॉग इन करते हैं जवाब, esp। चूंकि उन्होंने न केवल उत्तर दिया, बल्कि आपकी मदद करने के लिए आपकी टिप्पणियों का भी जवाब दिया। –