コード例 #1
0
def right_subgraph_2_entity_generation(current_uid: int, question_template: Dict[str, Any], generated_questions: List[Dict[str, Any]],
old_entities_ids: List[str] = None, old_entities: List[str] = None) -> Dict[str, Any]:
    generated_template = deepcopy(question_template)
    if old_entities_ids is None:
        sparql_query = generated_template['sparql_wikidata']
        old_entities_ids = questions_generator.get_elements_from_query(sparql_query, [0])
    questions_generator.entity_generation_common_part(current_uid, generated_template, generated_questions, old_entities_ids, old_entities)
    right_subgraph_2_nnqt_question_construction(generated_template)
    return generated_template
コード例 #2
0
def statement_property_entity_generation(current_uid: int, question_template: Dict[str, Any], generated_questions: List[Dict[str, Any]],
old_entities_ids: List[str] = None, old_entities: List[str] = None) -> Dict[str, Any]:
    generated_template = deepcopy(question_template)
    if old_entities_ids is None:
        sparql_query = generated_template['sparql_wikidata']
        # Check if there is a filter: if not so the last element is an entity
        if 'filter' in sparql_query.lower():
            old_entities_ids = questions_generator.get_elements_from_query(sparql_query, [0])
        else:
            old_entities_ids = questions_generator.get_elements_from_query(sparql_query, [0, 1])
    questions_generator.entity_generation_common_part(current_uid, generated_template, generated_questions, old_entities_ids, old_entities)
    statement_property_nnqt_question_construction(generated_template)
    return generated_template
def string_matching_type_relation_contains_word_entity_generation(
        current_uid: int,
        question_template: Dict[str, Any],
        generated_questions: List[Dict[str, Any]],
        old_entities_ids: List[str] = None,
        old_entities: List[str] = None) -> Dict[str, Any]:
    generated_template = deepcopy(question_template)
    if old_entities_ids is None:
        sparql_query = generated_template['sparql_wikidata']
        old_entities_ids = questions_generator.get_elements_from_query(
            sparql_query, [0, 1])
    questions_generator.entity_generation_common_part(current_uid,
                                                      generated_template,
                                                      generated_questions,
                                                      old_entities_ids,
                                                      old_entities)
    string_matching_type_relation_contains_word_nnqt_question_construction(
        generated_template)
    return generated_template