コード例 #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
コード例 #2
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
コード例 #3
0
 def readProcessedAttributesFromFile(self):
     # Be aware that it takes quite some time to read the preprocessed xml file
     dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
     pair_nodes = xml_util.get_pair_nodes(dom_doc)
     pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(
         pair_nodes)
     return pair_attributes
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
def threshold_iterator(threshold):
    dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
    pair_nodes = xml_util.get_pair_nodes(dom_doc)
    pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            idf_weighting(threshold, pair_attributes)
    else:
        idf_weighting(threshold, pair_attributes)
コード例 #7
0
def threshold_iterator(threshold):
    dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
    pair_nodes = xml_util.get_pair_nodes(dom_doc)
    pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(
        pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            idf_weighting(threshold, pair_attributes)
    else:
        idf_weighting(threshold, pair_attributes)
コード例 #8
0
ファイル: bleu.py プロジェクト: metareven/AI.Prog-dop---lsd
def threshold_iterator(threshold):
    # Be aware that it takes quite some time to read the preprocessed xml file
    dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
    pair_nodes = xml_util.get_pair_nodes(dom_doc)
    pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            bleu_matching(threshold, pair_attributes)
    else:
        bleu_matching(threshold, pair_attributes)
コード例 #9
0
ファイル: pos.py プロジェクト: datagangchen/AI.Prog-dop---lsd
def threshold_iterator(threshold):
    # Be aware that it takes quite some time to read the preprocessed xml file
    dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
    pair_nodes = xml_util.get_pair_nodes(dom_doc)
    pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(
        pair_nodes)
    if threshold == -1:
        for i in range(100):
            threshold = 1.0 - (0.01 * i)
            lemma_matching(threshold, pair_attributes)
    else:
        lemma_matching(threshold, pair_attributes)
コード例 #10
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
コード例 #11
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
コード例 #12
0
 def readProcessedAttributesFromFile(self):
         # Be aware that it takes quite some time to read the preprocessed xml file
         dom_doc = xml_util.get_dom_from_xml("data/RTE2_dev.preprocessed.xml")
         pair_nodes = xml_util.get_pair_nodes(dom_doc)
         pair_attributes = xml_util.get_attributes_from_preprocessed_pair_nodes(pair_nodes)
         return pair_attributes