Esempio n. 1
0
def _json_from_ann_and_txt(ann_obj, txt_file_path):
    j_dic = {}
    from document import _enrich_json_with_data, _enrich_json_with_base, _enrich_json_with_text

    _enrich_json_with_base(j_dic)
    _enrich_json_with_text(j_dic, txt_file_path)
    _enrich_json_with_data(j_dic, ann_obj)
    return j_dic
def _json_from_ann(ann_obj):
    # Returns json with ann_obj contents and the relevant text.  Used
    # for saving a round-trip when modifying annotations by attaching
    # the latest annotation data into the response to the edit
    # request.
    j_dic = {}
    txt_file_path = ann_obj.get_document() + '.' + TEXT_FILE_SUFFIX
    from document import (_enrich_json_with_data, _enrich_json_with_base,
            _enrich_json_with_text)
    _enrich_json_with_base(j_dic)
    # avoid reading text file if the given ann_obj already holds it
    try:
        doctext = ann_obj.get_document_text()
    except AttributeError:
        # no such luck
        doctext = None
    _enrich_json_with_text(j_dic, txt_file_path, doctext)
    _enrich_json_with_data(j_dic, ann_obj)
    return j_dic
Esempio n. 3
0
def _json_from_ann(ann_obj):
    # Returns json with ann_obj contents and the relevant text.  Used
    # for saving a round-trip when modifying annotations by attaching
    # the latest annotation data into the response to the edit
    # request.
    j_dic = {}
    txt_file_path = ann_obj.get_document() + '.' + TEXT_FILE_SUFFIX
    from document import (_enrich_json_with_data, _enrich_json_with_base,
                          _enrich_json_with_text)
    _enrich_json_with_base(j_dic)
    # avoid reading text file if the given ann_obj already holds it
    try:
        doctext = ann_obj.get_document_text()
    except AttributeError:
        # no such luck
        doctext = None
    _enrich_json_with_text(j_dic, txt_file_path, doctext)
    _enrich_json_with_data(j_dic, ann_obj)
    return j_dic
Esempio n. 4
0
	from document import (_enrich_json_with_data, _enrich_json_with_base,
		_enrich_json_with_text)
    from ApplicationScope import getAnnObject
    #~ j_dic = getAnnObject("/brat_vb/sentiment","test")
    #~ _enrich_json_with_base(j_dic)
    
    j_dic = {}
    _enrich_json_with_base(j_dic)
    txt_file_path = ann_obj.get_document() + '.' + TEXT_FILE_SUFFIX
    # avoid reading text file if the given ann_obj already holds it
    try:
        doctext = ann_obj.get_document_text()
    except AttributeError:
        # no such luck
        doctext = None
    _enrich_json_with_text(j_dic, txt_file_path, doctext)
    enrich_json_with_data(j_dic, ann_obj)

    return j_dic

from logging import info as log_info
from annotation import TextBoundAnnotation, TextBoundAnnotationWithText
from copy import deepcopy

def _offsets_equal(o1, o2):
    """
    Given two lists of (start, end) integer offset sets, returns
    whether they identify the same sets of characters.
    """
    # TODO: full implementation; current doesn't check for special
    # cases such as dup or overlapping (start, end) pairs in a single