gensim का उपयोग कर कोष मैं कोष से आम वाक्यांश extarct को रंदा था preprocessing, इस के लिए के लिए कोष से वाक्यांशों को निकालने के लिए मैं gensim में उपयोग कर वाक्यांश मॉडल की कोशिश की, मैं नीचे दिए गए कोड की कोशिश की लेकिन यह मुझे वांछित आउटपुट दे रही है नहीं है।कैसे
मेरे कोड
from gensim.models import Phrases
documents = ["the mayor of new york was there", "machine learning can be useful sometimes"]
sentence_stream = [doc.split(" ") for doc in documents]
bigram = Phrases(sentence_stream)
sent = [u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
print(bigram[sent])
आउटपुट
[u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
लेकिन यह आना चाहिए
[u'the', u'mayor', u'of', u'new_york', u'was', u'there']
लेकिन टी जब मैंने कोशिश की के रूप में o ट्रेन डेटा के प्रिंट vocab, मैं bigram देख सकते हैं, लेकिन यह परीक्षण डेटा के साथ काम नहीं कर रहा है, जहां मैं गलत जा रहा हूँ?
print bigram.vocab
defaultdict(<type 'int'>, {'useful': 1, 'was_there': 1, 'learning_can': 1, 'learning': 1, 'of_new': 1, 'can_be': 1, 'mayor': 1, 'there': 1, 'machine': 1, 'new': 1, 'was': 1, 'useful_sometimes': 1, 'be': 1, 'mayor_of': 1, 'york_was': 1, 'york': 1, 'machine_learning': 1, 'the_mayor': 1, 'new_york': 1, 'of': 1, 'sometimes': 1, 'can': 1, 'be_useful': 1, 'the': 1})
आप से है। लेकिन इस उदाहरण में बिग्राम "मशीन", "सीखने" को "machine_learning" के रूप में नहीं पकड़ता है। क्या आप जानते हैं कि ऐसा क्यों होता है? –
यदि आप दो बार प्रशिक्षण से पहले वाक्य में "मशीन लर्निंग" जोड़ते हैं, तो इसे अपने भेजे गए चर में जोड़ें, आपको "machine_learning" मिल जाएगा। अगर वह उस जोड़ी की आवृत्ति नहीं देख पाता है तो यह सहजता से नहीं जा रहा है। – ethanenglish