<jupyter_start><jupyter_text>install package<jupyter_code>!pip install -q https://github.com/howl-anderson/Chinese_models_for_SpaCy/releases/download/v2.0.3/zh_core_web_sm-2.0.3.tar.gz
!pip install -q pandas
!pip install -q jieba
!pip install -q tabulate<jupyter_output>Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting jieba
Installing collected packages: jieba
Successfully installed jieba-0.39
[33mYou are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.[0m<jupyter_text>import packages<jupyter_code>from spacy import displacy
from tabulate import tabulate
import pandas as pd

import zh_core_web_sm<jupyter_output><empty_output><jupyter_text>load models<jupyter_code>nlp = zh_core_web_sm.load()<jupyter_output><empty_output><jupyter_text>parse doc<jupyter_code>doc = nlp("王小明在北京的清华大学读书")<jupyter_output>Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.588 seconds.
Prefix dict has been built succesfully.<jupyter_text>print doc's attributes<jupyter_code>headers = ['text', 'lemma_', 'pos_', 'tag_', 'dep_',
           'shape_', 'is_alpha', 'is_stop', 'has_vector',
           'ent_iob_', 'ent_type_',
           'vector_norm', 'is_oov']

doc_data = []

for token in doc:
    token_data = [token.text, token.lemma_, token.pos_, token.tag_, token.dep_,
                  token.shape_, token.is_alpha, token.is_stop, token.has_vector,
                  token.ent_iob_, token.ent_type_,
                  token.vector_norm, token.is_oov]
    doc_data.append(token_data)

pd.DataFrame(doc_data, columns=headers)<jupyter_output><empty_output><jupyter_text>draw dependency graph<jupyter_code>displacy.render(doc, jupyter=True)
displacy.render(doc, jupyter=True, style='ent')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11282597126130921, 'fraction_numerical': 0.012240553485896753, 'mean_word_length': 5.184210526315789, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '180230', 'license': 'MIT', 'n_tokens_mistral': 710, 'n_tokens_neox': 682, 'n_words': 134, 'path': 'notebooks/demo.ipynb', 'repo_name': 'wuxiaobo/Chinese_models_for_SpaCy', 'size': '1879'}