nltkor 1.2.18__cp39-cp39-macosx_10_9_universal2.whl → 1.2.19__cp39-cp39-macosx_10_9_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nltkor/__init__.py CHANGED
@@ -13,4 +13,4 @@ from nltkor import trans
13
13
  from nltkor import Kor_char
14
14
  from nltkor import etc
15
15
 
16
- __version__ = '1.2.18'
16
+ __version__ = '1.2.19'
nltkor/search/__init__.py CHANGED
@@ -8,4 +8,4 @@ from .classical import (
8
8
  )
9
9
  from .faiss_search import FaissSearch
10
10
  from .kobert_tokenizer import KoBERTTokenizer
11
- from .search_dict import SearchDic
11
+ from .trie_search import TRIESearch
nltkor/search/test.py ADDED
@@ -0,0 +1,25 @@
1
+ from trie_search import TRIESearch
2
+
3
+ root = {}
4
+ dict_file = '/Users/chanhyeok/Downloads/lexicon.txt'
5
+ sc = TRIESearch(root)
6
+ with open(dict_file, 'r') as f:
7
+ for line in f:
8
+ if ';;' in line[:2]: continue
9
+ k, v = line.strip().split('\t')
10
+ sc.build_trie_search(k, v)
11
+ # print(root)
12
+ word = '고용 노동부'
13
+ values, value_data = sc.trie_search(word, True)
14
+ print(values, value_data)
15
+
16
+ word = '2시뉴스외전'
17
+ values, value_data = sc.trie_search( word, True)
18
+ print(values, value_data)
19
+ word = '2시 뉴스외전'
20
+ values, value_data = sc.trie_search( word, True)
21
+ print(values, value_data)
22
+
23
+ word = 'gbc'
24
+ values, value_data = sc.trie_search( word, True)
25
+ print(values, value_data)
@@ -4,11 +4,11 @@ import numpy as np
4
4
  import json
5
5
  import argparse
6
6
 
7
- class SearchDic :
7
+ class TRIESearch :
8
8
  def __init__ (self,root) :
9
9
  self.root = root
10
10
 
11
- def build_search_dict(self, word, data) -> dict:
11
+ def build_trie_search(self, word, data) -> dict:
12
12
  current_dict = self.root
13
13
  _end_word_ = '$$'
14
14
  for letter in word:
@@ -19,7 +19,7 @@ class SearchDic :
19
19
 
20
20
 
21
21
 
22
- def search_dict(self, word, space_flag=False):
22
+ def trie_search(self, word, space_flag=False):
23
23
  '''
24
24
  TRIE 탐색
25
25
  space_flag: if True then including space, otherwise do not including space
@@ -69,27 +69,27 @@ class SearchDic :
69
69
  return pickle.load(f)
70
70
  if __name__ == "__main__":
71
71
  root = {}
72
- dict_file = '텍스트파일경로'
73
- sc = SearchDic(root)
72
+ dict_file = '텍스트파일 경로'
73
+ sc = TRIESearch(root)
74
74
  with open(dict_file, 'r') as f:
75
75
  for line in f:
76
76
  if ';;' in line[:2]: continue
77
77
  k, v = line.strip().split('\t')
78
- sc.build_search_dict(k, v)
78
+ sc.build_trie_search(k, v)
79
79
  # print(root)
80
80
  word = '고용 노동부'
81
- values, value_data = sc.search_dict(word, True)
81
+ values, value_data = sc.trie_search(word, True)
82
82
  print(values, value_data)
83
83
 
84
84
  word = '2시뉴스외전'
85
- values, value_data = sc.search_dict( word, True)
85
+ values, value_data = sc.trie_search( word, True)
86
86
  print(values, value_data)
87
87
  word = '2시 뉴스외전'
88
- values, value_data = sc.search_dict( word, True)
88
+ values, value_data = sc.trie_search( word, True)
89
89
  print(values, value_data)
90
90
 
91
91
  word = 'gbc'
92
- values, value_data = sc.search_dict( word, True)
92
+ values, value_data = sc.trie_search( word, True)
93
93
  print(values, value_data)
94
94
 
95
95
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes