Commit 69e3a63f authored by Tags's avatar Tags

Fix load external dictionary procedure.

parent c2bc75b4
import os
import pkg_resources
# from _mysql import OperationalError
# from pprint import pprint
import nltk
......@@ -23,9 +24,14 @@ class Classifier:
return
# load external dictionary
directory = os.path.dirname(os.path.abspath(__file__))
file_name_dictionary = directory + '/large.txt'
file_dict = open(file_name_dictionary, "r")
try:
directory = os.path.dirname(os.path.abspath(__file__))
file_name_dictionary = directory + '/large.txt'
file_dict = open(file_name_dictionary, "r")
except NotADirectoryError as e:
resource_package = __name__
resource_path = '/large.txt'
file_dict = pkg_resources.resource_stream(resource_package, resource_path)
self.correct_words = set()
for word in file_dict:
self.correct_words.add(word[:-1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment