Browse Source

add 天猫

master
Yener 6 years ago
parent
commit
bd9c9da0b3
2 changed files with 7 additions and 5 deletions
  1. +2
    -1
      jiagu/segment/dict/user.dict
  2. +5
    -4
      jiagu/segment/nroute.py

+ 2
- 1
jiagu/segment/dict/user.dict View File

@@ -1,2 +1,3 @@
思知

天猫
知识图谱

+ 5
- 4
jiagu/segment/nroute.py View File

@@ -15,8 +15,9 @@ class Segment:
self.total_freq = 0
self.initialized = False

def init(self, vocab_path='dict/jiagu.dict'):
def init(self, vocab_path='dict/jiagu.dict', user_vocab='dict/user.dict'):
self.load_vocab(os.path.join(os.path.dirname(__file__), vocab_path))
self.load_vocab(os.path.join(os.path.dirname(__file__), user_vocab))
self.initialized = True
def load_vocab(self, vocab_path):
@@ -179,9 +180,9 @@ if __name__=='__main__':
s = Segment()
# sg.load_userdict('dict/user.dict')
s.load_userdict(['知识图谱'])
# s.load_userdict(['知识图谱'])

text = '知识图谱机器人hello\nworld¥¥'
text = '这一天猫小黑盒'
words = s.seg(text)
print(words)
@@ -191,4 +192,4 @@ if __name__=='__main__':

Loading…
Cancel
Save