Skip to content

Commit

Permalink
added docs for fuzzy finder
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Feb 22, 2018
1 parent e744a41 commit 2daeb2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ ProcessRankings(<array of result filenames>, 'Splatoon')

# Calculate the rankings and write to csv file
WriteCSVRankings('Splatoon', <ranking_filename>)

# optional step, checks for duplicates and outputs possible matches to console
# cutoff of 0 returns all possible matches, 100 would return only exact matches
FuzzyMatch(<ranking_filename>, cutoff=80)
```

**Example:**
Expand Down
14 changes: 9 additions & 5 deletions RankingFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,23 +1139,27 @@ def ProcessFolder(path):
currentFile = os.path.join(path, file)
ProcessRankings([currentFile[0:-4]], 'Melee');

def FuzzyMatch(filename, cutoff=80):
def FuzzyMatch(filename, cutoff=0):
"""Use this to find duplicates."""
# get list of team names
f = open(AddCsv(filename), encoding='utf-8')
next(f, None)
next(f, None) # skip first header row
dataDict = csv.DictReader(f)
teamList = [row['Tag'].lower() for row in dataDict]
output = {teamName: process.extractWithoutOrder(teamName, teamList, score_cutoff=cutoff) for teamName in teamList[:-1]}
duplicatesFound = False
for team in output:
matches = []
firstMatch = False
for match in output[team]:
if (match[0] != team):
if (match[0] == team and not firstMatch):
firstMatch = True
else:
matches.append(match)

if len(matches) > 0:
duplicatesFound = True
if not duplicatesFound:
duplicatesFound = True
print('Duplicates found:')
print(team + ': ' + str(matches))

if (not duplicatesFound):
Expand Down
2 changes: 1 addition & 1 deletion Season2-INT.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#ShowRankings('Melee')
WriteCSVRankings('Splatoon','Test3')
FuzzyMatch('Test3', cutoff=80)
FuzzyMatch('Test3', cutoff=50)
#PersonRankings('Ink Soup')
print('Done.')

Expand Down

0 comments on commit 2daeb2b

Please sign in to comment.