def test_table_with_multiple_occurance(self):
     rules = list(RuleGenerator.compute_rules(test_data2))
     assert Rule(31, 5107, 373, 1, 1.0, "item") in rules
     assert Rule(373, None, 31, 1, 1.0, "item") in rules
 def test_table_with_qualifier_and_references(self):
     rules = list(RuleGenerator.compute_rules(test_data3))
     assert Rule(31, None, 12, 1, 1.0, "qualifier") in rules
     assert Rule(31, None, 13, 1, 1.0, "qualifier") in rules
     assert Rule(31, None, 22, 1, 1.0, "reference") in rules
     assert Rule(31, None, 23, 1, 1.0, "reference") in rules
Пример #3
0
 def test_table_with_qualifier_and_references(self):
     rules = list(RuleGenerator.compute_rules(test_data3))
     self.assertThat(rules, ContainsAll([Rule(31, None, 12, 1, 1.0, "qualifier"),
                                         Rule(31, None, 13, 1, 1.0, "qualifier"),
                                         Rule(31, None, 22, 1, 1.0, "reference"),
                                         Rule(31, None, 23, 1, 1.0, "reference")]))
 def test_table_generator(self):
     rules = list(RuleGenerator.compute_rules(test_data1))
     assert Rule(31, 5107, 373, 1, 0.5, "item") in rules
     assert Rule(373, None, 31, 1, 1.0, "item") in rules
Пример #5
0
 def test_table_generator(self):
     rules = list(RuleGenerator.compute_rules(test_data1))
     self.assertThat(rules, ContainsAll([Rule(31, 5107, 373, 1, 0.5, "item"), Rule(373, None, 31, 1, 1.0, "item")]))
Пример #6
0
 def test_table_with_multiple_occurance(self):
     rules = list(RuleGenerator.compute_rules(test_data2))
     self.assertThat(rules, ContainsAll([Rule(31, 5107, 373, 1, 1.0, "item"), Rule(373, None, 31, 1, 1.0, "item")]))
Пример #7
0
import time

from propertysuggester.analyzer import CsvGenerator, RuleGenerator
from propertysuggester.parser import CsvReader
from propertysuggester.utils.CompressedFileType import CompressedFileType

if __name__ == "__main__":
    logging.basicConfig(level=20)  # Print logging.info

    parser = argparse.ArgumentParser(
        description="this program generates a correlation-table from "
        "the csv-dump")
    parser.add_argument("input",
                        help="The CSV input file (wikidata triple)",
                        type=CompressedFileType('rb'))
    parser.add_argument("output",
                        help="The CSV output file (default=sys.stdout)",
                        default=sys.stdout,
                        nargs='?',
                        type=CompressedFileType('wb'))
    args = parser.parse_args()

    start = time.time()
    logging.info("computing table")
    rules = RuleGenerator.compute_rules(CsvReader.read_csv(args.input))
    logging.info("writing csv")
    CsvGenerator.create_pair_csv(rules, args.output)
    logging.info("done - {0:.2f}s".format(time.time() - start))
    logging.info("now import this csv file with "
                 "PropertySuggester/maintenance/UpdateTable.php")
Пример #8
0
import logging
import argparse
import sys
import time

from propertysuggester.analyzer import CsvGenerator, RuleGenerator
from propertysuggester.parser import CsvReader
from propertysuggester.utils.CompressedFileType import CompressedFileType

if __name__ == "__main__":
    logging.basicConfig(level=20) # Print logging.info

    parser = argparse.ArgumentParser(description="this program generates a correlation-table from the csv-dump")
    parser.add_argument("input", help="The CSV input file (wikidata triple)", type=CompressedFileType('rb'))
    parser.add_argument("output", help="The CSV output file (default=sys.stdout)", default=sys.stdout, nargs='?',
                        type=CompressedFileType('wb'))
    args = parser.parse_args()

    start = time.time()
    logging.info("computing table")
    rules = RuleGenerator.compute_rules(CsvReader.read_csv(args.input))
    logging.info("writing csv")
    CsvGenerator.create_pair_csv(rules, args.output)
    logging.info("done - {0:.2f}s".format(time.time()-start))
    logging.info("now import this csv file with PropertySuggester/maintenance/UpdateTable.php")
 def test_table_with_qualifier_and_references(self):
     rules = list(RuleGenerator.compute_rules(test_data3))
     assert Rule(31, None, 12, 1, 1.0, "qualifier") in rules
     assert Rule(31, None, 13, 1, 1.0, "qualifier") in rules
     assert Rule(31, None, 22, 1, 1.0, "reference") in rules
     assert Rule(31, None, 23, 1, 1.0, "reference") in rules
 def test_table_with_multiple_occurance(self):
     rules = list(RuleGenerator.compute_rules(test_data2))
     assert Rule(31, 5107, 373, 1, 1.0, "item") in rules
     assert Rule(373, None, 31, 1, 1.0, "item") in rules
 def test_table_generator(self):
     rules = list(RuleGenerator.compute_rules(test_data1))
     assert Rule(31, 5107, 373, 1, 0.5, "item") in rules
     assert Rule(373, None, 31, 1, 1.0, "item") in rules