Exemplo n.º 1
0
def output_reader(verses, backend, language):
    print(backend.preamble(args.typeface, language))

    postponed_book = postponed_chapter = None

    for entry in get_morphgnt(verses):
        if entry[0] == "WORD":
            row = entry[1]
            lexeme = row["lemma"]
            text = strip_textcrit(row["text"])
            if lexeme not in exclusions:
                pos = row["ccat-pos"]
                headword = headwords.get(lexeme, lexeme)
                if glosses:
                    gloss = glosses[lexeme].get(row["bcv"],
                                                glosses[lexeme]["default"])
                else:
                    gloss = None
                if pos in ["V-"]:
                    parse = verb_parse(row["ccat-parse"])
                else:
                    parse = None
                print(backend.word(text, headword, parse, gloss, language))
            else:
                print(backend.word(text))

        elif entry[0] == "VERSE_START":
            if postponed_book:
                print(
                    backend.book_chapter_verse(postponed_book,
                                               postponed_chapter, entry[1]))
                postponed_book = postponed_chapter = None
            elif postponed_chapter:
                print(backend.chapter_verse(postponed_chapter, entry[1]))
                postponed_chapter = None
            else:
                print(backend.verse(entry[1]))
        elif entry[0] == "CHAPTER_START":
            postponed_chapter = entry[1]
        elif entry[0] == "BOOK_START":
            postponed_book = entry[1]
        else:
            print(backend.comment(entry))

    print(backend.postamble())
Exemplo n.º 2
0
def output_reader(verses, backend, language):
    print(backend.preamble(args.typeface, language))

    postponed_book = postponed_chapter = None

    for entry in get_morphgnt(verses):
        if entry[0] == "WORD":
            row = entry[1]
            lexeme = row["lemma"]
            text = strip_textcrit(row["text"])
            if lexeme not in exclusions:
                pos = row["ccat-pos"]
                headword = headwords.get(lexeme, lexeme)
                if glosses:
                    gloss = glosses[lexeme].get(
                        row["bcv"], glosses[lexeme]["default"])
                else:
                    gloss = None
                if pos in ["V-"]:
                    parse = verb_parse(row["ccat-parse"])
                else:
                    parse = None
                print(backend.word(text, headword, parse, gloss, language))
            else:
                print(backend.word(text))

        elif entry[0] == "VERSE_START":
            if postponed_book:
                print(backend.book_chapter_verse(
                    postponed_book, postponed_chapter, entry[1]))
                postponed_book = postponed_chapter = None
            elif postponed_chapter:
                print(backend.chapter_verse(postponed_chapter, entry[1]))
                postponed_chapter = None
            else:
                print(backend.verse(entry[1]))
        elif entry[0] == "CHAPTER_START":
            postponed_chapter = entry[1]
        elif entry[0] == "BOOK_START":
            postponed_book = entry[1]
        else:
            print(backend.comment(entry))

    print(backend.postamble())
Exemplo n.º 3
0
def output_reader(verses, sblgnt_dir, backend):
    print(backend.preamble(args.typeface))

    postponed_chapter = None

    for entry in get_morphgnt(verses, args.sblgnt_dir):
        if entry[0] == "WORD":
            lexeme = entry[8]
            text = strip_textcrit(entry[5])
            if lexeme not in exclusions:
                pos = entry[2]
                headword = headwords.get(lexeme, lexeme)
                if glosses:
                    gloss = glosses[lexeme].get(
                        entry[1], glosses[lexeme]["default"])
                else:
                    gloss = None
                if pos in ["V-"]:
                    parse = verb_parse(entry[3])
                else:
                    parse = None
                print(backend.word(text, headword, parse, gloss))
            else:
                print(backend.word(text))

        elif entry[0] == "VERSE_START":
            if postponed_chapter:
                print(backend.chapter_verse(postponed_chapter, entry[1]))
                postponed_chapter = None
            else:
                print(backend.verse(entry[1]))
        elif entry[0] == "CHAPTER_START":
            postponed_chapter = entry[1]
        else:
            print(backend.comment(entry))

    print(backend.postamble())
Exemplo n.º 4
0
verses = parse_verse_ranges(args.verses)

if args.exclude:
    exclusions = load_wordset(args.exclude)
else:
    exclusions = set()

lexemes = load_yaml(args.lexemes)

if args.headwords:
    headwords = load_yaml(args.headwords)
else:
    headwords = {}


for entry in get_morphgnt(verses, args.sblgnt_dir):
    if entry[0] == "WORD":
        lexeme = entry[8]
        if lexeme not in exclusions and lexeme not in headwords:
            pos = entry[2]
            if pos in ["N-", "A-"]:
                if "full-citation-form" in lexemes[lexeme]:
                    headword = lexemes[lexeme]["full-citation-form"]
                else:
                    headword = lexemes[lexeme]["danker-entry"]
                headwords[lexeme] = headword

for lexeme, headword in sorted_items(headwords):
    print("{}: {}".format(lexeme, headword))
Exemplo n.º 5
0
    help="path to lexemes file "
    "(defaults to lexemes.yaml)")

args = argparser.parse_args()

verses = parse_verse_ranges(args.verses)

if args.exclude:
    exclusions = load_wordset(args.exclude)
else:
    exclusions = set()

lexemes = load_yaml(args.lexemes)

if args.headwords:
    headwords = load_yaml(args.headwords)
else:
    headwords = {}


for entry in get_morphgnt(verses):
    if entry[0] == "WORD":
        lemma = entry[1]["lemma"]
        if lemma not in exclusions and lemma not in headwords:
            pos = entry[1]["ccat-pos"]
            if pos in ["N-", "A-"]:
                headwords[lemma] = lexemes[lemma]["headword"]

for lemma, headword in sorted_items(headwords):
    print("{}: {}".format(lemma, headword))