Python Forum
fuzzywuzzy search string in text file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fuzzywuzzy search string in text file
#8
Not a lot of documentation online but you can go to the project page and look at the source.
Quote:def extractOne(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0):
"""Find the single best match above a score in a list of choices.
This is a convenience method which returns the single best choice.
See extract() for the full arguments list.
Args:
query: A string to match against
choices: A list or dictionary of choices, suitable for use with
extract().
processor: Optional function for transforming choices before matching.
See extract().
scorer: Scoring function for extract().
score_cutoff: Optional argument for score threshold. If the best
match is found, but it is not greater than this number, then
return None anyway ("not a good enough match"). Defaults to 0.
Returns:
A tuple containing a single match and its score, if a match
was found that was above score_cutoff. Otherwise, returns None.
"""
best_list = extractWithoutOrder(query, choices, processor, scorer, score_cutoff)
try:
return max(best_list, key=lambda i: i[1])
except ValueError:
return None
According to this, "query" (the word you are looking for) is a string. If you want to look for one of many words I think you need to repeat the extractOne() call once for each query word. You'll have to come up with a "matching calculus" to decide which is the best fit. I'd start with computing the average match score of the query words.
Reply


Messages In This Thread
fuzzywuzzy search string in text file - by marfer - Aug-02-2021, 01:50 PM
RE: fuzzywuzzy search string in text file - by deanhystad - Aug-02-2021, 07:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 1,027 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  Search Excel File with a list of values huzzug 4 1,291 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Need to replace a string with a file (HTML file) tester_V 1 795 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Search for multiple unknown 3 (2) Byte combinations in a file. lastyle 7 1,432 Aug-14-2023, 02:28 AM
Last Post: deanhystad
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,195 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  search file by regex SamLiu 1 937 Feb-23-2023, 01:19 PM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,154 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  If function is false search next file mattbatt84 2 1,174 Sep-04-2022, 01:56 PM
Last Post: deanhystad
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,730 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Editing text between two string from different lines Paqqno 1 1,333 Apr-06-2022, 10:34 PM
Last Post: BashBedlam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020