Skip to content

Commit

Permalink
Updated holyregex con un altra toppa
Browse files Browse the repository at this point in the history
  • Loading branch information
avivace committed Feb 22, 2020
1 parent 847f362 commit adf9c9a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Ignore scrapes
*.html

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node
Expand Down
2 changes: 1 addition & 1 deletion data/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
from bs4 import BeautifulSoup

SOUP_INGREDIENTS = "pup/htmldumps/akuma.html"
SOUP_INGREDIENTS = "pup/htmldumps/ryu.html"


def main():
Expand Down
28 changes: 17 additions & 11 deletions discord/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
vs2_aliases = ["V-Skill 2", "vs2", "vskill2", "v-skill2"]
# -> [VS2]

other = {
ryuexact = {
# CHARACTER: RYU
# V-TRIGGER 1
"Collarbone Breaker": ["f+MP", "f+mp", "f.mp", "fmp", "overhead"],
Expand Down Expand Up @@ -132,13 +132,20 @@ def moveRegex(movestring):
# [0] is the first group matched
return m.groups(0)[0].upper() + " Jodan Sokutou Geri"

return "notmatched"
return ""

def matchExact(text, data):
for move in data:
for alias in data[move]:
if text == alias:
return move

def resolveMoveName(userstring):
logging.info("userstring is %s")

outer = "(ryu|nash)\s(\w+|\w+\.\w+|\w+\s\w+|\w+\+\w+)\s*(vt1|vt2){0,1}$"
m = re.search(outer, userstring, re.IGNORECASE)
# product of dennitopolino typing blind:
holyregex = "(ryu|nash)\s(\w+|\w+\.\w+|\w+\s\w+|\w+\+\w+|\w+\s\w+\s\w+)\s*(vt1|vt2){0,1}$"
# ye, don't ask
m = re.search(holyregex, userstring, re.IGNORECASE)
if m:
char = m.groups(0)[0]
move = m.groups(0)[1]
Expand All @@ -152,7 +159,11 @@ def resolveMoveName(userstring):
logging.info("move:\t%s", move)
logging.info("vt:\t%s", vt)

result = moveRegex(move)
result = matchExact(move, ryuexact)
if not result:
result = moveRegex(move)
if not result:
result = move

logging.info("translated movename:%s", result)

Expand All @@ -175,8 +186,3 @@ def resolveMoveName(userstring):
return resultdict


def findAlias(text):
for move in aliasdict:
for alias in aliasdict[move]:
if text == alias:
return movestring, aliasdict[move][0]

0 comments on commit adf9c9a

Please sign in to comment.