Example #1
0
def buildNounPhraseDict(taggedReviews,
                        applyFn=sentenceSumSentiment):
    nounPhraseDict = defaultdict(lambda: 0)
    for taggedReview in taggedReviews:
        for taggedSentence in taggedReview:
            for np in extract_noun_phrases(taggedSentence.sentence):
                nounPhraseDict[np] += applyFn(taggedSentence)
    return normalize(nounPhraseDict)
def make_noun_phrase(reviews, prune):
    sent_noun = []
    for (words, score) in reviews:
        nouns = noun_phrases_extraction.extract_noun_phrases(words)
        if(prune):
            token_nouns = [noun for noun in nouns if len(word_tokenize(noun))>=2 ]
        else:
            token_nouns = nouns

        if(score > 0):
            rate = "pos"
        elif(score < 0):
            rate = "neg"
        else:
            rate = "neu"
        sent_noun.append((token_nouns, rate))
    return sent_noun