def test_category_detection_slice(self):
        categorizer = CategoryDetectionCommand(source_file=rel_path_to_file("../files/in/complete_top_pg_entities.json",
                                                                            __file__),
                                               out_file=rel_path_to_file(
                                                   "../files/out/categorized_top_pg_entities.json",
                                                   __file__))
        result = categorizer._exec_command(string_return=True)
        result = json.loads(result)

        print "------"

        # print result

        self.assertEqual(4, len(result))
        self.assertIn("no_taxon", result)
        self.assertIn("both", result)
        self.assertIn("is_instance", result)
        self.assertIn("have_instances", result)


        self.assertEqual(0, len(result["no_taxon"]))
        self.assertEqual(6, len(result["is_instance"]))
        self.assertEqual(18, len(result["both"]))
        self.assertEqual(0, len(result["have_instances"]))

        an_entity = result["is_instance"][0]

        self.assertEqual(5, len(an_entity))
        self.assertEqual("Q148", an_entity["id"])
        self.assertEqual("state in East Asia", an_entity["description"])
        self.assertEqual("People's Republic of China", an_entity["label"])
        self.assertEqual("0.014571185387097224", an_entity["pg_score"])
        self.assertEqual(4, len(an_entity["aliases"]))
    def test_aliases_slice(self):
        aliases_tracker = AliasesPropertiesCommand(out_file=rel_path_to_file("../files/out/complete_with_alias.txt",
                                                                             __file__),
                                                   source_file=rel_path_to_file("../files/in/complete.txt",
                                                                                __file__))

        result = aliases_tracker.exec_command(string_return=True)
        result_json = json.loads(result)
        self.assertEqual(50, len(result_json))


        self.assertEqual(4, len(result_json[0]))
        self.assertEqual(4, len(result_json[1]))
        self.assertEqual(4, len(result_json[2]))
        self.assertEqual(4, len(result_json[49]))


        self.assertEqual('P31', result_json[0]["id"])
        self.assertEqual("P17", result_json[1]["id"])
        self.assertEqual("P21", result_json[2]["id"])
        self.assertEqual("P685", result_json[49]["id"])

        self.assertEqual("instance of", result_json[0]["label"])
        self.assertEqual("country", result_json[1]["label"])
        self.assertEqual("sex or gender", result_json[2]["label"])
        self.assertEqual("NCBI Taxonomy ID", result_json[49]["label"])
示例#3
0
    def test_category_detection_slice(self):
        categorizer = CategoryDetectionCommand(
            source_file=rel_path_to_file(
                "../files/in/complete_top_pg_entities.json", __file__),
            out_file=rel_path_to_file(
                "../files/out/categorized_top_pg_entities.json", __file__))
        result = categorizer._exec_command(string_return=True)
        result = json.loads(result)

        print "------"

        # print result

        self.assertEqual(4, len(result))
        self.assertIn("no_taxon", result)
        self.assertIn("both", result)
        self.assertIn("is_instance", result)
        self.assertIn("have_instances", result)
示例#4
0
    def test_aliases_slice(self):
        aliases_tracker = AliasesPropertiesCommand(
            out_file=rel_path_to_file("../files/out/complete_with_alias.txt",
                                      __file__),
            source_file=rel_path_to_file("../files/in/complete.txt", __file__))

        result = aliases_tracker.exec_command(string_return=True)
        result_json = json.loads(result)
        self.assertEqual(50, len(result_json))

        self.assertEqual(4, len(result_json[0]))
        self.assertEqual(4, len(result_json[1]))
        self.assertEqual(4, len(result_json[2]))
        self.assertEqual(4, len(result_json[49]))

        self.assertEqual('P31', result_json[0]["id"])
        self.assertEqual("P17", result_json[1]["id"])
        self.assertEqual("P21", result_json[2]["id"])
        self.assertEqual("P685", result_json[49]["id"])

        self.assertEqual("instance of", result_json[0]["label"])
        self.assertEqual("country", result_json[1]["label"])
        self.assertEqual("sex or gender", result_json[2]["label"])
        self.assertEqual("NCBI Taxonomy ID", result_json[49]["label"])