Skip to content

Commit

Permalink
Merge 3c570fe into 137fe5f
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatsuya committed Jun 3, 2019
2 parents 137fe5f + 3c570fe commit c04a561
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shogi/KIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ParserException(Exception):
pass

class Parser:
MOVE_RE = re.compile(r'\A[ 0-9]{4} (\u4e2d\u65ad|\u6295\u4e86|\u6301\u5c06\u68cb|\u5148\u65e5\u624b|\u8a70\u307f|\u5207\u308c\u8ca0\u3051|\u53cd\u5247\u52dd\u3061|\u53cd\u5247\u8ca0\u3051|(([\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19])([\u96f6\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d])|\u540c\u3000)([\u6b69\u9999\u6842\u9280\u91d1\u89d2\u98db\u7389\u3068\u674f\u572d\u5168\u99ac\u9f8d])(\u6253|(\u6210?)\(([0-9])([0-9])\)))\s*(\([ /:0-9]+\))?\s*\Z')
MOVE_RE = re.compile(r'\A *[0-9]+ (\u4e2d\u65ad|\u6295\u4e86|\u6301\u5c06\u68cb|\u5148\u65e5\u624b|\u8a70\u307f|\u5207\u308c\u8ca0\u3051|\u53cd\u5247\u52dd\u3061|\u53cd\u5247\u8ca0\u3051|(([\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19])([\u96f6\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d])|\u540c\u3000)([\u6b69\u9999\u6842\u9280\u91d1\u89d2\u98db\u7389\u3068\u674f\u572d\u5168\u99ac\u9f8d])(\u6253|(\u6210?)\(([0-9])([0-9])\)))\s*(\([ /:0-9]+\))?\s*\Z')

HANDYCAP_SFENS = {
'\u5e73\u624b': shogi.STARTING_SFEN,
Expand All @@ -51,7 +51,8 @@ class Parser:

@staticmethod
def parse_file(path):
with codecs.open(path, 'r', 'cp932') as f:
enc = 'utf-8' if path.rsplit('.', 1)[1] == 'kifu' else 'cp932'
with codecs.open(path, 'r', enc) as f:
return Parser.parse_str(f.read())

@staticmethod
Expand Down

0 comments on commit c04a561

Please sign in to comment.