Skip to content

Commit

Permalink
#4 update exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Dacihi Fukui committed Jul 11, 2019
1 parent 82c6e48 commit 20ab3b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/text
Original file line number Diff line number Diff line change
@@ -1 +1 @@
昨日のなでしこは負けてしまって残念でした

9 changes: 7 additions & 2 deletions extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
try:
text = open('data/text',encoding='utf-8',mode='r').read()
except FileNotFoundError:
print ("INFO: data/text not found. Create empty data/keyword...")
file = open('data/text',encoding='utf-8',mode='w')
file.write('')
file.close()
file_keyword = open('data/keyword','w')
file_keyword.write('')
file_keyword.close()
end = time.time()
print ("INFO: data/text not found. Wait for 15 seconds...")
time.sleep(15-(end-start))
continue

if len(text) == 0:
if len(text) == 0 or text == '\n' or text == ' ':
print ("INFO: data/text empty. Create empty keyword file...")
file = open('data/keyword','w')
file.write('')
Expand Down

0 comments on commit 20ab3b9

Please sign in to comment.