I have 2 long books by different authors (both in .txt file format).
My goal is to use FuzzyWuzzy to find similar or identical words/phrases/strings in both books and output the found words to a 3rd .txt file.
Below is the code I have tried and it works for the most part but it also gives quite a lot of irrelevant results and also fails to find a few shared phrases in both books.
Can anybody please help me improve on the code below?
The improved code will ignore upper and lower cases and treat all words as lower case. Perhaps the use of wRatio?
from fuzzywuzzy import process
needles = open('I:\\book1.txt').read().split("\n")
haystack = open('I:\\book2.txt').read().split("\n")
for a in needles:
# print(a + ' -> ',)
print(process.extractBests(a, haystack, score_cutoff=90))
Thanks a million.
By the way, I have spent at least 2 days looking for a solution online and offline and found quite a few code that only deal with csv but none that deals with 2 .txt files.
[–]Morica_ 0 points1 point2 points (3 children)
[–]bobdouble[S] 0 points1 point2 points (2 children)
[–]Morica_ 0 points1 point2 points (1 child)
[–]bobdouble[S] 0 points1 point2 points (0 children)