Esempio n. 1
0
def get_as_txt(cursor, accession_number):
    # cursor, string -> Optional[str]
    report, meta_data = _load(cursor, accession_number)
    if report:
        return rtf_to_text(report), meta_data
    else:
        return None, meta_data
Esempio n. 2
0
def q(cursor, day: datetime, parse_report: bool):
    rows = query_report(cursor, day)
    for row in rows:
        text = rtf_to_text(row['rtf'])
        row['txt'] = text
        if parse_report:
            parsed = parse(text.splitlines())
            row.update(parsed)
    return rows
Esempio n. 3
0
def diffs(row) -> Tuple[Dict[str, str], Dict[str, str], Dict[str, int], str]:
    s = time.time()
    befund_s = rtf_to_text(row['befund_s']) \
        if row['befund_s'] is not None else ''
    befund_g = rtf_to_text(row['befund_g']) \
        if row['befund_g'] is not None else ''
    befund_f = rtf_to_text(row['befund_f']) \
        if row['befund_f'] is not None else ''
    befund_s = _extract_section(befund_s)
    befund_g = _extract_section(befund_g)
    befund_f = _extract_section(befund_f)
    compare_s_f = _diff(befund_s, befund_f)
    compare_g_f = _diff(befund_g, befund_f)
    total_lengths = {'total_words_s': _total_length(befund_s),
                     'total_words_g': _total_length(befund_g),
                     'total_words_f': _total_length(befund_f)}
    e = time.time()
    logging.debug('Single row diff calculation took %s', e - s)
    return compare_s_f, compare_g_f, total_lengths, row['unters_schluessel']
Esempio n. 4
0
File: app.py Progetto: joshy/review
def diff(id):
    con = get_review_db()
    row = query_review_report(con.cursor(), id)
    cases = ["befund_s", "befund_g", "befund_f"]
    for c in cases:
        if c in row:
            field = c + "_text"
            v = row[c]
            if v:
                row[field] = rtf_to_text(v)
    return render_template("diff.html", row=row, version=version)
Esempio n. 5
0
File: app.py Progetto: joshy/review
def diff_by_accession():
    con = get_review_db()
    acc = request.args.get("accession_number", -1)
    row = query_review_report_by_acc(con.cursor(), acc)
    cases = ["befund_s", "befund_g", "befund_f"]
    for c in cases:
        if c in row:
            field = c + "_text"
            v = row[c]
            if v:
                row[field] = rtf_to_text(v)
    return render_template("diff.html", row=row, version=version)