Coder Social home page Coder Social logo

spacy-ltp's Introduction

spaCy-ltp


This repo is inspired by spaCy-stanza

In this repo, we wraps LTP 4(Language Technology Platform) library, so you can use LTP models (including 'cws', 'pos', 'dep' and 'ner') in a spaCy pipline

Using this wrapper, you'll be able to use the following tasks, computed by your pretrained LTP model:

  • Chinese word segmentation (cws): Doc and its tokens
  • Part-of-speech tagging (pos): token.tag_
  • Dependency parsing (dep): token.dep_, token.head
  • Named entity recognition (ner): doc.ents, token.ent_type

Requirements

spacy v3.x
ltp v4.2.x

Usage & Example

from ltp import LTP
import spacy_ltp

# [Optional] Download the LTP model if necessary
LTP('LTP/small')

# Initialize the pipeline
nlp = spacy_ltp.load_pipeline('LTP/small')

doc = nlp("华东师范大学是教育部和上海市人民政府重点共建的综合性研究型全国重点大学。")
for token in doc:
    print(token.text, token.tag_, token.dep_, token.head, token.ent_type_) 
Text TAG DEP HEAD ENT
华东 ns ATT 师范大学 Ni
师范大学 n SBV Ni
v HED
教育部 ni SBV 共建 Ni
c LAD 人民政府
上海市 ns ATT 人民政府 Ni
人民政府 i COO 教育部 Ni
重点 d ADV 共建
共建 v ATT 大学
u RAD 共建
综合性 n ATT 大学 Ni
研究型 b ATT 大学 Ni
全国 n ATT 大学 Ni
重点 n ATT 大学 Ni
大学 n VOB Ni
wp WP
for ent in doc.ents:
    print(ent.text, ent.label_)
ENT TYPE
华东师范大学 Ni
教育部 Ni
上海人民政府 Ni
综合性研究型全国重点大学 Ni

spacy-ltp's People

Contributors

yuto3o avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.