Skip to content

Commit

Permalink
Merge pull request #30 from mizo0203/add_function_to_convert_station
Browse files Browse the repository at this point in the history
辞書変換ツールを駅名データに対応
  • Loading branch information
hayatedayon committed Oct 27, 2018
2 parents 7e62378 + a192f34 commit c969c0c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tool/make_json_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import argparse
import csv
import json
import sys

Expand Down Expand Up @@ -76,6 +77,7 @@ def kana_judge(c):
parser.add_argument('-b', '--biology', action='store_true', help=u'生物学の学名と和名の対応ファイルの読み込み時に使用')
parser.add_argument('-n', '--naistdic', action='store_true', help=u'NAIST Japanese Dictionaryの読み込み時に使用')
parser.add_argument('-p', '--pokemon', action='store_true', help=u'kotofurumiya/pokemon_dataの読み込み時に使用')
parser.add_argument('-s', '--station', action='store_true', help=u'geonlp_japan_stationの読み込み時に使用')
parser.add_argument('inputfile', type=argparse.FileType('r'))
parser.add_argument('outputfile', type=argparse.FileType('w'))
args = parser.parse_args()
Expand Down Expand Up @@ -103,6 +105,16 @@ def kana_judge(c):
else:
yomi += v
inputData[yomi] = [name]
elif args.station:
obj = csv.reader(f)
for line in obj:
org = line[2]
key = line[3]
if key in inputData:
if org not in inputData[key]:
inputData[key].append(org)
else:
inputData[key] = [org]
elif args.biology:
for line in f:
word = line.rstrip().split('\t')[1]
Expand Down

0 comments on commit c969c0c

Please sign in to comment.