yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
827 stars 139 forks source link

Constituent parsing with Chinese #66

Closed Fantabulous-J closed 3 years ago

Fantabulous-J commented 3 years ago

Hi! Can you show me an example of how to do constituent parsing over Chinese sentences with gold word segmentation available?

yzhangcs commented 3 years ago

@Fantabulous-J Hi, here is a toy example (electra model is available at dev branch now):

>>> parser = Parser.load('crf-con-electra-zh')
>>> parser.predict([['上海', '浦东', '开发', '与', '法制', '建设', '同步']],verbose=False,lang=None).sentences[0]
( (IP (NP (NP (_ 上海) (_ 浦东)) (NP (_ 开发))) (_ 与) (NP (_ 法制) (_ 建设)) (VP (_ 同步))))
Fantabulous-J commented 3 years ago

Figured it out yesterday. But anyway, thanks a lot!