Exemplo n.º 1
0
def mentionEntityVocabularyForTest():
    train_entity_friendlyname = files_handle.read_set(
        "..\\data\\entity\\graphquestions.training.entityFriendlyname")


#test_questions_entity_friendlyname()
#mentionEntityVocabularyForTest()
Exemplo n.º 2
0
def test_questions_entity_friendlyname():
    test_entity_friendlyname = files_handle.read_set(
        "..\\data\\entity\\graphquestions.testing.entityFriendlyname")
    train_entity_friendlyname = files_handle.read_set(
        "..\\data\\entity\\graphquestions.training.entityFriendlyname")
    test_entity_friendlyname_remain = test_entity_friendlyname - train_entity_friendlyname
    print(len(test_entity_friendlyname_remain))
    #  print(test_entity_friendlyname_remain)
    test_entity_friname = entity_friendlyname(test_entity_friendlyname_remain)
    miss_after_alias = graphentityalias_miss(test_entity_friname)
    test_entity_friname_miss_after_alias = entity_friendlyname(
        miss_after_alias)
    miss_after_alias_name = graphentitynamemiss(
        test_entity_friname_miss_after_alias)
    test_entity_friname_miss_after_alias_name = entity_friendlyname(
        miss_after_alias_name)
    miss_after_alias_name_clueweb = cluewebmiss(
        test_entity_friname_miss_after_alias_name)
    files_handle.write_set(
        miss_after_alias_name_clueweb,
        "..\\data\\entity\\graphquestions.testing.entityFriendlynamemiss")
Exemplo n.º 3
0
def compare_NP_mention():
    position_question_posword = test_easy_mention_position()
    np_mention_indexrange = read_dict_mention_indexrange(
        "..\\data\\test\\test.easy.ques.np.index.range")
    not_in_np_ques_mention_pos_indexrange = dict()
    not_in_np_ques_mention_pos = dict()
    for position in position_question_posword:
        for question_posword in position_question_posword[position]:
            mention_indexranges = np_mention_indexrange[question_posword.split(
                "###")[0]]
            if position not in mention_indexranges:
                not_in_np_ques_mention_pos_indexrange[
                    question_posword.split("###")
                    [0]] = position + "###" + "###".join(mention_indexranges)
                not_in_np_ques_mention_pos[question_posword.split("###")
                                           [0]] = position
            #  print("not in\t"+question_posword.split("###")[0])
    ques_position_pos_equal = train_mention_pos_equal_position()
    questions_unhittes = read_set("../data/test/test.easy.ques.np_not_hit")
    for ques in questions_unhittes:
        position_right = not_in_np_ques_mention_pos[ques]
        if ques in ques_position_pos_equal:
            if position_right in ques_position_pos_equal[ques]:
                print("in:\t" + ques)

    ques_frname_in_position = train_frname_in_test_position()
    for ques in questions_unhittes:
        position_right = not_in_np_ques_mention_pos[ques]
        if ques in ques_frname_in_position:
            if position_right in ques_frname_in_position[ques]:
                print("in:\t" + ques)

# write_dict_str(not_in_np_ques_mention_pos_indexrange,"..\\data\\test\\test.easy.ques.not_in_np_ques_mention_pos_indexrange")
    range_num = dict()
    # for question in not_in_np_ques_mention_pos_indexrange:
    #     position=not_in_np_ques_mention_pos_indexrange[question].split("###")[0]
    #  #   print(position)
    #     range_position=0
    #     if "\t" in position:
    #         position_start=position.split("\t")[0]
    #         position_end=position.split("\t")[1]
    #         range_position=int(position_end)-int(position_start)+1
    #     else:
    #         range_position=1
    #     if range_position in range_num:
    #         range_num[range_position]=range_num[range_position]+1
    #     else:
    #         range_num[range_position] =  1
    # print(range_num)
    return not_in_np_ques_mention_pos_indexrange
Exemplo n.º 4
0
def friendlyname_entity():
    train_entity_friendlyname = files_handle.read_set(
        "..\\data\\entity\\graphquestions.training.entityFriendlyname")
    train_friendlyname_entity = friendlyname_entity_exchange(
        train_entity_friendlyname)
    return train_friendlyname_entity
Exemplo n.º 5
0
import time

from entity_linker.files_handle import read_posques_posword, write_dict_dict_dict, read_set
from entity_linker.name_entity_files_handle import friendlyname_entity, alias_entity, name_entity, clueweb_name_entity
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
train_friendlyname_entity = friendlyname_entity()
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
graphq_alias_entity = alias_entity()
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
graph_nameentity = name_entity()
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
name_entitygraphq_pro_clueweb = clueweb_name_entity()
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
train_pos_combine = read_set(
    "../data/test/intersect.train.test.easy.mention.pos.composition")
print(train_pos_combine)


def posword_wordlist(posword):
    word_list = list()
    for pos_word in posword:
        word = pos_word.split("\t")[1].lower()
        word_list.append(word)
    return word_list


def posword_poslist(posword):
    pos_list = list()
    for pos_word in posword:
        pos = pos_word.split("\t")[0].lower()
        pos_list.append(pos)