Ejemplo n.º 1
0
                        return {"feedback": True}
                    elif s == "n":
                        return {"feedback": False}

            elif feedback_request["message"] == "give-examples":
                attribute = feedback_request["attribute"]

                sys.stdout.flush()
                sys.stderr.flush()
                print("Provide examples for '{}', leave empty to continue:".format(attribute.name))

                examples = []
                while True:
                    s = input("- ")
                    if s == "":
                        return {"examples": examples}
                    else:
                        examples.append(s)
            else:
                assert False, f"Unknown message '{feedback_request['message']}'!"


        matching_phase(document_base, feedback_fn, status_function, statistics["matching"])

        # store the result
        with open("cache/matched-document-base.bson", "wb") as file:
            file.write(document_base.to_bson())

    with open("cache/statistics.json", "w") as file:
        json.dump(statistics.to_serializable(), file, indent=4)
Ejemplo n.º 2
0
                    results["f1_score"] = (
                        2 * results["precision"] * results["recall"] /
                        (results["precision"] + results["recall"]))

        # compute the results as the median
        for attribute in dataset.ATTRIBUTES:
            for score in ["recall", "precision", "f1_score"]:
                values = [
                    res["results"][attribute][score]
                    for res in statistics["matching"]["runs"].all_values()
                ]
                statistics["matching"]["results"][attribute][
                    score] = np.median(values)

        ################################################################################################################
        # store the results
        ################################################################################################################
        if not os.path.isdir(
                os.path.join(os.path.dirname(__file__), "..", "results",
                             f"{dataset.NAME}")):
            os.makedirs(
                os.path.join(os.path.dirname(__file__), "..", "results",
                             f"{dataset.NAME}"),
                exist_ok=True,
            )
        with open(
                os.path.join(os.path.dirname(__file__), "results",
                             f"{dataset.NAME}", "aset-stanza-ranking.json"),
                "w") as file:
            json.dump(statistics.to_serializable(), file)