Exemplo n.º 1
0
def check_tag(pipeline, sentence, tag, o1, o2):
    """Return True if sentence has tag between offsets o1 and o2."""
    # NOTE: apart from the options this is the same function as in unittests.py
    td = tarsqi.process_string(sentence, pipeline=pipeline, loglevel='1')
    tags = td.tags.find_tags(tag)
    for t in tags:
        if t.begin == o1 and t.end == o2:
            return True
    return False, tags
Exemplo n.º 2
0
def parse_text(text):
    doc = tarsqi.process_string(text, pipeline='PREPROCESSOR,EVITA,GUTIME')
    doc.sourcedoc.lif = lif.LIF(json_object={
        "text": {
            "@value": text
        },
        "views": []
    })
    doc.sourcedoc.lif.add_tarsqi_view(doc)
    purge_metadata(doc.sourcedoc.lif.views[0].metadata)
    return doc
Exemplo n.º 3
0
def run_pipeline(pipeline, sentence):
    """Run the sentence through the pipeline and return the resulting
    TarsqiDocument. The process_string method does not trap errors."""
    return tarsqi.process_string(sentence, pipeline=pipeline, loglevel=1)
Exemplo n.º 4
0

def print_summary():
    print "\nSUMMARY:\n"
    print "   %-15s    %-10s  %-10s  %s" % ('', ' PASS', ' FAIL',  'ERROR')
    for module, p, f, e in SUMMARY:
        print "   %-15s    %5s       %5s       %5s" % (module, p, f, e)
    print
    if f or e:
        print "   THERE WERE FAILURES OR ERRORS\n"


if __name__ == '__main__':

    # a dummy run just to get the tagger messages out of the way
    tarsqi.process_string("Fido barks.")

    run_gutime_tests = False
    run_evita_tests = False
    run_slinket_tests = False
    run_s2t_tests = False
    run_blinker_tests = False
    run_sputlink_tests = False

    components = ['evita', 'gutime', 'slinket', 's2t', 'blinker', 'sputlink']
    opts, args = getopt.getopt(sys.argv[1:], '', components + ['show-errors'])
    for opt, val in opts:
        if opt == '--show-errors': SHOW_ERRORS = True
        if opt == '--evita': run_evita_tests = True
        if opt == '--gutime': run_gutime_tests = True
        if opt == '--slinket': run_slinket_tests = True
Exemplo n.º 5
0
def run_pipeline(pipeline, sentence):
    """Run the sentence through the pipeline and return the resulting
    TarsqiDocument. The process_string method does not trap errors."""
    return tarsqi.process_string(sentence, pipeline=pipeline, loglevel=1)
Exemplo n.º 6
0

def print_summary():
    print "\nSUMMARY:\n"
    print "   %-15s    %-10s  %-10s  %s" % ('', ' PASS', ' FAIL', 'ERROR')
    for module, p, f, e in SUMMARY:
        print "   %-15s    %5s       %5s       %5s" % (module, p, f, e)
    print
    if f or e:
        print "   THERE WERE FAILURES OR ERRORS\n"


if __name__ == '__main__':

    # a dummy run just to get the tagger messages out of the way
    tarsqi.process_string("Fido barks.")

    run_gutime_tests = False
    run_evita_tests = False
    run_slinket_tests = False
    run_s2t_tests = False
    run_blinker_tests = False
    run_sputlink_tests = False

    components = ['evita', 'gutime', 'slinket', 's2t', 'blinker', 'sputlink']
    opts, args = getopt.getopt(sys.argv[1:], '', components + ['show-errors'])
    for opt, val in opts:
        if opt == '--show-errors': SHOW_ERRORS = True
        if opt == '--evita': run_evita_tests = True
        if opt == '--gutime': run_gutime_tests = True
        if opt == '--slinket': run_slinket_tests = True
Exemplo n.º 7
0
def load_tagger():
    # a dummy run just to get the tagger messages out of the way
    #tarsqi.process_string("Fido barks.", [('--pipeline', 'PREPROCESSOR')])
    tarsqi.process_string("Fido barks.", pipeline='PREPROCESSOR')