Beispiel #1
0
    def readTestAttributesFromFile(self):
        dom_doc = xml_util.get_dom_from_xml("data/RTE2_test.preprocessed.xml")
        pair_nodes = xml_util.get_pair_nodes(dom_doc)

        entailment_values = [0 for _ in range(800 + 1)]
        document = xml_util.get_dom_from_xml("data/RTE2_test.annotated.xml")
        pair_nodes2 = xml_util.get_pair_nodes(document)
        pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes2)
        for i in range(len(pair_attributes)):
            t, h, id_num, e = pair_attributes[i]
            id_num = int(id_num)
            entailment_values[id_num] = 0

        def get_attributes_from_preprocessed_pair_nodes(pair_nodes):
            pairs = []
            for pair in pair_nodes:
                text = pair.getElementsByTagName("text")[0].childNodes
                hypothesis = pair.getElementsByTagName(
                    "hypothesis")[0].childNodes
                id_number = pair.getAttributeNode("id").value
                #entailment = pair.getAttributeNode("entailment").value
                entailment = entailment_values[int(id_number)]
                task = pair.getAttributeNode("task").value
                pairs.append((text, hypothesis, id_number, entailment, task))
            return pairs

        pair_attributes = get_attributes_from_preprocessed_pair_nodes(
            pair_nodes)
        return pair_attributes
    def readTestAttributesFromFile(self):
            dom_doc = xml_util.get_dom_from_xml("data/RTE2_test.preprocessed.xml")
            pair_nodes = xml_util.get_pair_nodes(dom_doc)

            entailment_values = [0 for _ in range(800+1)]
            document = xml_util.get_dom_from_xml("data/RTE2_test.annotated.xml")
            pair_nodes2 = xml_util.get_pair_nodes(document)
            pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes2)
            for i in range(len(pair_attributes)):
                t,h,id_num,e = pair_attributes[i]
                id_num = int(id_num)
                entailment_values[id_num] = 0


            def get_attributes_from_preprocessed_pair_nodes(pair_nodes):
                pairs = []
                for pair in pair_nodes:
                    text = pair.getElementsByTagName("text")[0].childNodes
                    hypothesis = pair.getElementsByTagName("hypothesis")[0].childNodes
                    id_number = pair.getAttributeNode("id").value
                    #entailment = pair.getAttributeNode("entailment").value
                    entailment = entailment_values[int(id_number)]
                    task = pair.getAttributeNode("task").value
                    pairs.append((text,hypothesis,id_number,entailment,task))
                return pairs

            pair_attributes = get_attributes_from_preprocessed_pair_nodes(pair_nodes)
            return pair_attributes
Beispiel #3
0
def threshold_iterator(threshold):
    document = xml_util.get_dom_from_xml("data/RTE2_dev.xml")
    pair_nodes = xml_util.get_pair_nodes(document)
    pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            word_matching(threshold, pair_attributes)
    else:
        word_matching(threshold,pair_attributes)
def threshold_iterator(threshold):
    document = xml_util.get_dom_from_xml("data/RTE2_dev.xml")
    pair_nodes = xml_util.get_pair_nodes(document)
    pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            word_matching(threshold, pair_attributes)
    else:
        word_matching(threshold, pair_attributes)
Beispiel #5
0
 def readAttributesFromFile(self):
     document = xml_util.get_dom_from_xml("data/RTE2_dev.xml")
     pair_nodes = xml_util.get_pair_nodes(document)
     pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes)
     return pair_attributes
 def readAttributesFromFile(self):
     document = xml_util.get_dom_from_xml("data/RTE2_dev.xml")
     pair_nodes = xml_util.get_pair_nodes(document)
     pair_attributes = xml_util.get_attributes_from_pair_nodes(pair_nodes)
     return pair_attributes