Example #1
0
    def store_annotations(self, user_id, data):
        doc_filename = data['doc']
        doc = Document.all().filter("filename =", doc_filename).get()

        doc_annotation = DocumentAnnotation.all().filter(
            "user_id =", user_id).filter("document =", doc.filename).get()
        if not doc_annotation:
            doc_annotation = DocumentAnnotation(user_id=user_id,
                                                document=doc.filename)

        doc_annotation.approved = data["approved"]

        doc_annotation.concepts = [Text(item) for item in data["concepts"]]
        doc_annotation.relations = [Text(item) for item in data["relations"]]
        doc_annotation.arg_units = [Text(item) for item in data["arg_units"]]

        doc_annotation.notes = Text(data['notes'])

        log("Storing annotations " +
            ("[Approved]" if doc_annotation.approved else "") + " for " +
            str(doc.filename) + ": " + str(doc_annotation.arg_units) +
            " - notes: " +
            doc_annotation.notes.encode("utf-8").replace("\n", " NL "))

        db.get(doc_annotation.put())
Example #2
0
    def annotation_from_json(self, annotation_data, doc):
        anno = DocumentAnnotation()
        anno.approved = self.bool_from_string(
            annotation_data["approved"]) if "approved" in annotation_data else False
        anno.user_id = annotation_data["annotator"]

        anno.notes = annotation_data["notes"] if "notes" in annotation_data else ""

        if "arg_units" in annotation_data:
            anno.arg_units = [Text(p) for p in annotation_data["arg_units"]]
        else:
            anno.arg_units = [Text(p) for p in annotation_data["propositions"]]

        if "relations" in annotation_data:
            anno.relations = [Text(p) for p in annotation_data["relations"]]

        if "concepts" in annotation_data:
            anno.concepts = [Text(p) for p in annotation_data["concepts"]]

        self.convert_from_legacy_arg_units(anno)
        anno.document = doc.filename
        return anno
Example #3
0
    def store_annotations(self, user_id, data):
        doc_filename = data['doc']
        doc = Document.all().filter("filename =", doc_filename).get()

        doc_annotation = DocumentAnnotation.all().filter("user_id =", user_id).filter("document =",
                                                                                      doc.filename).get()
        if not doc_annotation:
            doc_annotation = DocumentAnnotation(user_id=user_id, document=doc.filename)

        doc_annotation.approved = data["approved"]

        doc_annotation.concepts = [Text(item) for item in data["concepts"]]
        doc_annotation.relations = [Text(item) for item in data["relations"]]
        doc_annotation.arg_units = [Text(item) for item in data["arg_units"]]

        doc_annotation.notes = Text(data['notes'])

        log("Storing annotations " + (
        "[Approved]" if doc_annotation.approved else "") + " for " + str(doc.filename) + ": " + str(
            doc_annotation.arg_units) + " - notes: " + doc_annotation.notes.encode("utf-8").replace(
            "\n", " NL "))

        db.get(doc_annotation.put())
Example #4
0
    def annotation_from_json(self, annotation_data, doc):
        anno = DocumentAnnotation()
        anno.approved = self.bool_from_string(
            annotation_data["approved"]
        ) if "approved" in annotation_data else False
        anno.user_id = annotation_data["annotator"]

        anno.notes = annotation_data[
            "notes"] if "notes" in annotation_data else ""

        if "arg_units" in annotation_data:
            anno.arg_units = [Text(p) for p in annotation_data["arg_units"]]
        else:
            anno.arg_units = [Text(p) for p in annotation_data["propositions"]]

        if "relations" in annotation_data:
            anno.relations = [Text(p) for p in annotation_data["relations"]]

        if "concepts" in annotation_data:
            anno.concepts = [Text(p) for p in annotation_data["concepts"]]

        self.convert_from_legacy_arg_units(anno)
        anno.document = doc.filename
        return anno