示例#1
0
def get_inquirer_vec(relation, Arg, parse_dict):
    inquirer = Non_Explicit_dict().inquirer
    inquirer_stem = Non_Explicit_dict().inquirer_stem

    list = [0] * 42
    verb_tag = ["MD", "VB", "VBD", "VBG", "VBN", "VBP", "VBZ"]

    # ["NN/dog" ,"NNS/joks]
    word_list = _get_Arg_word_pos_list(relation, Arg, parse_dict)

    for item in word_list:
        if item == "":
            continue
        tag, word = item.split("/")[:2]
        if tag not in verb_tag:
            continue
        word = word.lower()
        if word in inquirer.keys():
            list = _merge(list, inquirer[word])
        else:
            stem = util.stem_string(word)
            if stem in inquirer.keys():
                list = _merge(list, inquirer[stem])
            elif stem in inquirer_stem.keys():
                list = _merge(list, inquirer_stem[stem])

    return list
def get_inquirer_vec(relation, Arg, parse_dict):
    inquirer = Non_Explicit_dict().inquirer
    inquirer_stem = Non_Explicit_dict().inquirer_stem

    list = [0] * 42
    verb_tag= ["MD", "VB", "VBD", "VBG", "VBN", "VBP", "VBZ"]

    # ["NN/dog" ,"NNS/joks]
    word_list = _get_Arg_word_pos_list(relation, Arg, parse_dict)

    for item in word_list:
        if item == "":
            continue
        tag, word = item.split("/")[:2]
        if tag not in verb_tag:
            continue
        word = word.lower()
        if word in inquirer.keys():
            list = _merge(list, inquirer[word])
        else:
            stem = util.stem_string(word)
            if stem in inquirer.keys():
                list = _merge(list, inquirer[stem])
            elif stem in inquirer_stem.keys():
                list = _merge(list, inquirer_stem[stem])

    return list
示例#3
0
    def get_polarity(self):
        polarity = {}
        polarity_stem = {}
        for line in open(config.POLARITY_WORD_PATH):
            word, pol = line.strip().split("\t")
            polarity[word] = pol
            polarity_stem[util.stem_string(word)] = pol

        return polarity, polarity_stem
示例#4
0
 def get_negate_word(self):
     fin = open(config.NEGATE_WORDS_PATH)
     negate = []
     negate_stem = []
     for line in fin:
         word = line.strip()
         negate.append(word)
         negate_stem.append(util.stem_string(word))
     return negate, negate_stem
    def get_polarity(self):
        polarity = {}
        polarity_stem= {}
        for line in open(config.POLARITY_WORD_PATH):
            word, pol = line.strip().split("\t")
            polarity[word] = pol
            polarity_stem[util.stem_string(word)] = pol

        return polarity, polarity_stem
 def get_negate_word(self):
     fin = open(config.NEGATE_WORDS_PATH)
     negate = []
     negate_stem = []
     for line in fin:
         word = line.strip()
         negate.append(word)
         negate_stem.append(util.stem_string(word))
     return negate, negate_stem
示例#7
0
 def get_inquirer(self):
     inquirer = {}
     inquirer_stem = {}
     fin = open(config.INQUIRER_WORD_PATH)
     for line in fin:
         key, value = line.strip().split("\t")
         inquirer[key] = value.split("|")
         inquirer_stem[util.stem_string(key)] = value.split("|")
     fin.close()
     return inquirer, inquirer_stem
 def get_inquirer(self):
     inquirer = {}
     inquirer_stem = {}
     fin = open(config.INQUIRER_WORD_PATH)
     for line in fin:
         key, value = line.strip().split("\t")
         inquirer[key] = value.split("|")
         inquirer_stem[util.stem_string(key)] = value.split("|")
     fin.close()
     return inquirer, inquirer_stem
def is_negate(wordlist):
    negate = Non_Explicit_dict().negate
    negate_stem = Non_Explicit_dict().negate_stem

    for word in wordlist:
        if word in negate:
            return True
        else:
            stem = util.stem_string(word)
            if stem in negate or stem in negate_stem:
                return True
    return False
示例#10
0
def is_negate(wordlist):
    negate = Non_Explicit_dict().negate
    negate_stem = Non_Explicit_dict().negate_stem

    for word in wordlist:
        if word in negate:
            return True
        else:
            stem = util.stem_string(word)
            if stem in negate or stem in negate_stem:
                return True
    return False
def get_polarity(word):
    polarity = Non_Explicit_dict().polarity
    polarity_stem = Non_Explicit_dict().polarity_stem

    pol = ""
    if word in polarity:
        pol = polarity[word]
    else:
        stem = util.stem_string(word)
        if stem in polarity:
            pol = polarity[stem]
        if stem in polarity_stem:
            pol = polarity_stem[stem]
    if pol == "":
        return []
    else:
        return pol.split("|")
示例#12
0
def get_polarity(word):
    polarity = Non_Explicit_dict().polarity
    polarity_stem = Non_Explicit_dict().polarity_stem

    pol = ""
    if word in polarity:
        pol = polarity[word]
    else:
        stem = util.stem_string(word)
        if stem in polarity:
            pol = polarity[stem]
        if stem in polarity_stem:
            pol = polarity_stem[stem]
    if pol == "":
        return []
    else:
        return pol.split("|")
def get_word_MPQA_polarity(word_pos_tuple):
    n_stemmed_word_pos_dict = Non_Explicit_dict().n_stemmed_word_pos_dict
    y_stemmed_word_pos_dict = Non_Explicit_dict().y_stemmed_word_pos_dict

    word, pos = word_pos_tuple

    if word_pos_tuple in n_stemmed_word_pos_dict:
        return n_stemmed_word_pos_dict[word_pos_tuple]
    elif (word, "anypos") in n_stemmed_word_pos_dict:
        return n_stemmed_word_pos_dict[(word, "anypos")]

    # stem
    word = util.stem_string(word)
    if (word, pos) in y_stemmed_word_pos_dict:
        return y_stemmed_word_pos_dict[(word, pos)]
    elif (word, "anypos") in y_stemmed_word_pos_dict:
        return y_stemmed_word_pos_dict[(word, "anypos")]

    # no match
    return ("NULL", "NULL")
示例#14
0
def get_word_MPQA_polarity(word_pos_tuple):
    n_stemmed_word_pos_dict = Non_Explicit_dict().n_stemmed_word_pos_dict
    y_stemmed_word_pos_dict = Non_Explicit_dict().y_stemmed_word_pos_dict

    word, pos = word_pos_tuple

    if word_pos_tuple in n_stemmed_word_pos_dict:
        return n_stemmed_word_pos_dict[word_pos_tuple]
    elif (word, "anypos") in n_stemmed_word_pos_dict:
        return n_stemmed_word_pos_dict[(word, "anypos")]

    # stem
    word = util.stem_string(word)
    if (word, pos) in y_stemmed_word_pos_dict:
        return y_stemmed_word_pos_dict[(word, pos)]
    elif (word, "anypos") in y_stemmed_word_pos_dict:
        return y_stemmed_word_pos_dict[(word, "anypos")]

    # no match
    return ("NULL", "NULL")