コード例 #1
0
 def __init__(self, name):
     print("Starting new Tensorflow session...")
     self.session = tf.Session()
     print("Loading pipeline modules...")
     self.tokenizer = segmenter.load_model(name)
     self.tagger_pos = pos_tagger.load_model(name)  # class tagger_pos
     self.tagger_ner = ner_tagger.load_model(name)  # class tagger_ner
コード例 #2
0
ファイル: test_install.py プロジェクト: Sandy4321/deepnlp-1
deepnlp.download(module='segment', name='zh_entertainment')
deepnlp.download(module='pos', name='en')
deepnlp.download(module='ner', name='zh_o2o')

# Download module
deepnlp.download('segment')
deepnlp.download('pos')
deepnlp.download('ner')
deepnlp.download('parse')

# deepnlp.download()

## 测试 load model
from deepnlp import segmenter
try:
    tokenizer = segmenter.load_model(name='zh')
    tokenizer = segmenter.load_model(name='zh_o2o')
    tokenizer = segmenter.load_model(name='zh_entertainment')
except Exception as e:
    print("DEBUG: ERROR Found...")
    print(e)

## pos
from deepnlp import pos_tagger
try:
    tagger = pos_tagger.load_model(
        name='en')  # Loading English model, lang code 'en'
    tagger = pos_tagger.load_model(
        name='zh')  # Loading English model, lang code 'en'
except Exception as e:
    print("DEBUG: ERROR Found...")
コード例 #3
0
ファイル: test_pos_zh.py プロジェクト: Sandy4321/deepnlp-1
#coding:utf-8
from __future__ import unicode_literals  # compatible with python3 unicode

from deepnlp import segmenter
from deepnlp import pos_tagger

# Load Model
tokenizer = segmenter.load_model(name='zh')
tagger = pos_tagger.load_model(name='zh')

#Segmentation
text = "我爱吃北京烤鸭"  # unicode coding, py2 and py3 compatible
words = tokenizer.seg(text)
print(" ".join(words))

#POS Tagging
tagging = tagger.predict(words)
for (w, t) in tagging:
    pair = w + "/" + t
    print(pair)

#Results
#我/r
#爱/v
#吃/v
#北京/ns
#烤鸭/n
コード例 #4
0
#!/usr/bin/python
# -*- coding:utf-8 -*-

import deepnlp

from deepnlp import segmenter
try:
    deepnlp.download("segment", "zh_finance")
except Exception as e:
    print (e)

deepnlp.register_model("segment", "zh_finance")
deepnlp.download("segment", "zh_finance")
try:
    seg_tagger = segmenter.load_model("zh_finance")
except Exception as e:
    print (e)

from deepnlp import pos_tagger
try:
    deepnlp.download("pos", "zh_finance")
except Exception as e:
    print (e)

deepnlp.register_model("pos", "zh_finance")
deepnlp.download("pos", "zh_finance")
try:
    pos_tagger.load_model("zh_finance")
except Exception as e:
    print (e)