import re

from ftfy import fix_encoding


def try_fix_encoding():
    with open("./bible_fr.txt", encoding='utf-8') as f:
        for line in f.readlines():
            print(fix_encoding(line))


def extract_lines():
    keywords = [
        "word",
        "voice",
        "breath"
    ]
    with open("./james.txt", "r") as fin:
        with open("./data.txt", "w") as fout:
            for line in fin.readlines():
                if len(line) == 1:
                    print("Skipping empty line")
                    continue
                print("Line:", line)
                if any(re.search("\\b%s\\b" % word, line) for word in keywords):
                    print("Match: %s" % line)
                    fout.write(line)


if __name__ == '__main__':
    # extract_lines()
    try_fix_encoding()
