示例#1
0
def get_Nouns(idea, unigram_tagger):
    nounlist = []
    taggedWords = nltk.pos_tag(stringHelper.getwordlist(idea))
    for word in taggedWords:
        if word[1] is not None and "NN" in word[1] and word[0].lower(
        ) not in nounlist:
            nounlist.append(word[0].lower())
    taggedWords = unigram_tagger.tag(stringHelper.getwordlist(idea))
    nonoun = True
    for word in taggedWords:
        if word[1] is not None and "NN" in word[1] and word[0].lower(
        ) not in nounlist:
            nounlist.append(word[0].lower())
    return nounlist
示例#2
0
def isduplicate(wordlist, idea):
    # update matrix and return new matrix and wordlist, if there are new words in the idea
    ideawords = [word.lower() for word in stringHelper.getwordlist(idea)]
    cond = True
    duplicate = False
    for word in ideawords:
        wordlist[word] = wordlist.get(word, [])
        if wordlist[word] == []:
            cond = False
            wordlist[word] = [0] * len(list(wordlist.values())[0])

    if cond:
        i = 0
        while not duplicate and i < len(list(wordlist.values())[0]):
            for word in wordlist:
                if wordlist[word][i] is not ideawords.count(word):
                    duplicate = False
                    break
                else:
                    duplicate = True
            i += 1
    if not duplicate:
        for word in wordlist:
            wordlist[word].append(ideawords.count(word))

    return duplicate, wordlist
def withoutnoun(idea):
    taggedWords = nltk.pos_tag(stringHelper.getwordlist(idea))
    nonoun = True
    for word in taggedWords:
        if "NN" in word[1]:
            return False
        elif "None" in word[1]:
            nonoun = False
    return nonoun
def withoutnoununigram(idea, tagger):
    taggedWords = tagger.tag(stringHelper.getwordlist(idea))
    nonoun = True
    for word in taggedWords:
        if word[1] is None:
            nonoun = False
        elif "NN" in word[1]:
            return False
    return nonoun
def withoutadjectiveunigram(idea, tagger):
    taggedWords = tagger.tag(stringHelper.getwordlist(idea))
    for word in taggedWords:
        if word[1] is not None and "JJ" in word[1]:
            return False
    return True
def withoutverbunigram(idea, tagger):
    taggedWords = tagger.tag(stringHelper.getwordlist(idea))
    for word in taggedWords:
        if word[1] is not None and ("VB" in word[1] or "MD" in word[1] or "BE" in word[1]):
            return False
    return True
def withoutadjective(idea):
    taggedWords = nltk.pos_tag(stringHelper.getwordlist(idea))
    for word in taggedWords:
        if "JJ" in word[1]:
            return False
    return True