Exemple #1
0
    def test_calculate_distances_2(self):
        input = "Havinga et al systematically changed n from 3.00 to 4.00 by synthesizing LaTl 3. " \
                "T c = 1.6 K is then found in LaPb 3."

        spans = [("LaTl 3", "<material>"), ("T c", "<tc>"), ("1.6 K", "<tcValue>"),
                 ("LaPb 3", "<material>")]

        doc = prepare_doc(input, spans)

        materials = [entity for entity in filter(lambda w: w.ent_type_ in ['<material>'], doc)]
        tc_values = [entity for entity in filter(lambda w: w.ent_type_ in ['<tcValue>'], doc)]

        target = VicinityResolutionResolver()

        distances = target.calculate_distances(materials, tc_values, doc)

        assert len(distances) == 2
        assert distances[materials[0]][tc_values[0]] == 27.0
        assert distances[materials[1]][tc_values[0]] == 23.5
Exemple #2
0
    def test_calculate_distances(self):
        input = "Havinga et al systematically changed n from 3.00 to 4.00 by synthesizing LaTl 3" \
                " (n=3.00, T c =1.6 K), LaPb 3 (n=3.75, T c =4.1 K), and " \
                "ThPb 3 with T c =5.6 K and the solid solutions " \
                "La (Tl 1−x Pb x ) 3 and (La 1−x Th x )Pb 3 ."

        spans = [("LaTl 3", "<material>"), ("T c", "<tc>"), ("1.6 K", "<tcValue>"),
                 ("LaPb 3", "<material>"), ("T c", "<tc>"), ("4.1 K", "<tcValue>"),
                 ("ThPb 3", "<material>"), ("T c", "<tc>"), ("5.6 K", "<tcValue>"),
                 ("La (Tl 1−x Pb x ) 3", "<material>"), ("(La 1−x Th x )Pb 3", "<material>")]

        doc = prepare_doc(input, spans)

        materials = [entity for entity in filter(lambda w: w.ent_type_ in ['<material>'], doc)]
        tc_values = [entity for entity in filter(lambda w: w.ent_type_ in ['<tcValue>'], doc)]

        target = VicinityResolutionResolver()

        distances = target.calculate_distances(materials, tc_values, doc)

        assert len(distances) == 5
        assert distances[materials[0]][tc_values[0]] == 7.5
        assert distances[materials[1]][tc_values[1]] == 7.5
        assert distances[materials[2]][tc_values[2]] == 18