Esempio n. 1
0
from common import globals_args
from method_sp.grounding import grounding_utils
import os
from common import hand_files

q_mode = globals_args.argument_parser.q_mode

# 2.2 args
if q_mode == 'cwq':
    oracle_file_root = globals_args.fn_cwq_file.grounded_graph_file + 'result/'
    oracle_all_files_path_names = os.listdir(oracle_file_root)
    literal_to_id_map = grounding_utils.read_literal_to_id_map(
        file_root=globals_args.fn_cwq_file.grounded_graph_file)
    kb_relations = hand_files.read_set(
        globals_args.kb_freebase_latest_file.freebase_relations_file)

    mediators_instances_set = hand_files.read_set(
        globals_args.kb_freebase_latest_file.mediators_instances_file)
    schema_lines_list = hand_files.read_list(
        globals_args.kb_freebase_latest_file.schema_file)
    property_reverse_dict = hand_files.read_dict(
        globals_args.kb_freebase_latest_file.freebase_reverse_property)
    literal_property_dict = hand_files.read_dict(
        globals_args.kb_freebase_latest_file.freebase_literal_property)

elif q_mode == 'graphq':
    oracle_file_root = globals_args.fn_graph_file.grounded_graph_file + 'result/'
    oracle_all_files_path_names = os.listdir(oracle_file_root)
    literal_to_id_map = grounding_utils.read_literal_to_id_map(
        file_root=globals_args.fn_graph_file.grounded_graph_file)
    kb_relations = hand_files.read_set(
Esempio n. 2
0
from common.hand_files import read_set

if __name__ == "__main__":

    # names = kb_interface.get_names('m.04ygk0')
    # print (names)
    # sparqlquery = 'SELECT DISTINCT ?s WHERE { ?s ?p ?o } limit 10 '
    # query_answers_id_set = freebase_kb_interface.execute_sparql(sparqlquery)
    # print (query_answers_id_set)

    # import sys
    # from unit_test.logger_test import Logger
    # sys.stdout = Logger('./2019.07.05_denotation_names.log', sys.stdout)

    # instance_str = 'en.jamarcus_russell'
    union_all_denotations = read_set('./uniondenotation.txt')
    for i, denotation in enumerate(union_all_denotations):
        labels = get_names(instance_str=denotation)
        # name = ''
        # if len(labels) > 0:
        #     name = labels.pop()
        print(('%d\t%s\t%s') % (i, denotation, str(labels)))

    # import sys
    # from parsing.logger_test import Logger
    # sys.stdout = Logger('./2019.05.13_class_name.txt', sys.stdout)

    # kb_interface.get_all_reverse_properties()

    # kb_interface.get_all_classes()
Esempio n. 3
0
from common.bert_args import BertArgs
from sutime import SUTime
from parsing.nltk_nlp_utils import NLTK_NLP
from common import globals_args
from common import hand_files

parser_mode = globals_args.parser_mode
wh_words_set = {
    "what", "which", "whom", "who", "when", "where", "why", "how", "how many",
    "how large", "how big"
}
bert_args = BertArgs(globals_args.root, globals_args.q_mode)
nltk_nlp = NLTK_NLP(globals_args.argument_parser.ip_port)
sutime = SUTime(jars=globals_args.argument_parser.sutime_jar_files,
                mark_time_ranges=True)
unimportantwords = hand_files.read_set(
    globals_args.argument_parser.unimportantwords)
unimportantphrases = hand_files.read_list(
    globals_args.argument_parser.unimportantphrases)
stopwords_dict = hand_files.read_set(
    globals_args.argument_parser.stopwords_dir)
ordinal_lines_dict = hand_files.read_ordinal_file(
    globals_args.argument_parser.ordinal_fengli
)  #2 {'second', '2ndis_equal_wh_word'}

count_phrases = [
    'Count', 'How many', 'how many', 'the number of', 'the count of',
    'the amount of', 'total number of', 'count'
]
count_ner_tags = ['count']
dayu_phrases = [
    'more', 'more than', 'greater', 'higher', 'longer than', 'taller than'