def test_values_no_value(self):
     struct = "TestcaseStructureNoValue.json"
     val = "ValuesNoValue.json"
     json_parse(struct, val)
     with open("StructureWithValues.json", "r") as output_file:
         output = json.load(output_file)
     with open(struct, "r") as sample_file:
         sample = json.load(sample_file)
     self.assertDictEqual(
         output, sample,
         "Если у параметра с id из Values.json, в массиве values нет объекта с id равным value, то считаем, что такого значения нет и оставляем поле value пустым."
     )
 def test_values_no_param(self):
     struct = "TestcaseStructure.json"
     val = "ValuesNoParam.json"
     json_parse(struct, val)
     with open("StructureWithValues.json", "r") as output_file:
         output = json.load(output_file)
     with open(struct, "r") as sample_file:
         sample = json.load(sample_file)
     self.assertDictEqual(
         output, sample,
         "Если мы не можем найти параметр с id из файла Values.json, то считаем, что такого параметра нет и значение подставлять некуда"
     )
Beispiel #3
0
def main():
    case_dict = defaultdict(list)
    abbreviations = {'std': 'standard', 'cut': 'cutter'}
    with open('machine_model-Case.json', 'r') as record:
        for data in json_parse(record, "\n"):
            standardize_manufacturer(data, case_dict, abbreviations)

    pprint(dict(case_dict))

    with open('machine_model-Caterpillar.json', 'r') as record:
        for data in json_parse(record, "\n"):
            standardize(data, "140h")
 def test_to_json(self):
     self.assertEqual(json.dumps(b), json_parse().to_json(b))
     self.assertEqual(json.dumps(data_list), json_parse().to_json(data_list))
     self.assertEqual(json.dumps(data_dict), json_parse().to_json(data_dict))
     self.assertEqual(json.dumps(data_str), json_parse().to_json(data_str))
     self.assertEqual(json.dumps(data_int), json_parse().to_json(data_int))
     self.assertEqual(json.dumps(data_tuple), json_parse().to_json(data_tuple))
Beispiel #5
0
def main():
    total_urls = json_parse("WEBPAGES_RAW/bookkeeping.json")
    if not os.path.isfile("index.txt"):
        html_extraction.iterate_files()

    if not os.path.isfile("tf_idf_index.txt"):
        tf_idf_calculation.loop_thru_file()

    while True:
        query = raw_input("search: ").lower()
        if query == "q":
            break
        docs = search(query)
        count = 1
        for d, w in docs:
            print(str(count) + ". " + total_urls.get_url(d))
            count += 1
        if not docs:
            print("UNABLE TO FIND QUERY")
        print("\nINPUT Q TO STOP SEARCHING")
 def test_loads(self):
     data = json.dumps(data_list)
     self.assertEqual(json.loads(data), json_parse().loads(data))
     data = json.dumps(data_dict)
     self.assertEqual(json.loads(data), json_parse().loads(data))
     data = json.dumps(data_str)
     self.assertEqual(json.loads(data), json_parse().loads(data))
     data = json.dumps(data_int)
     self.assertEqual(json.loads(data), json_parse().loads(data))
     data = json.dumps(data_tuple)
     self.assertEqual(json.loads(data), json_parse().loads(data))
     try:
         a = json.loads(data_erorr)
     except BaseException:
         a = None
     self.assertEqual(a, json_parse().loads(data_erorr))
Beispiel #7
0
from json_parse import json_parse
import html_extraction, sys, os.path, tf_idf_calculation, operator
from flask import Flask, render_template, request

app = Flask(__name__)
total_urls = json_parse("WEBPAGES_RAW/bookkeeping.json")

formHtml = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Search</title>
</head>
<body>
    <form action = "http://localhost:5000/result" method = "POST">
         <p>Search <input type = "text" name = "Search" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
</body>
</html>
"""


def main():
    total_urls = json_parse("WEBPAGES_RAW/bookkeeping.json")
    if not os.path.isfile("index.txt"):
        html_extraction.iterate_files()

    if not os.path.isfile("tf_idf_index.txt"):
        tf_idf_calculation.loop_thru_file()