Package: guwencombo
GuwenCOMBOTokenizer, POS-Tagger, and Dependency-Parser for Classical Chinese Texts (漢文/文言文), working withCOMBO-pytorch.Basic usage>>>importguwencombo>>>lzh=guwencombo.load()>>>s=lzh("不入虎穴不得虎子")>>>print(s)# text = 不入虎穴不得虎子1不不ADVv,副詞,否定,無界Polarity=Neg2advmod_Gloss=not|SpaceAfter=No2入入VERBv,動詞,行為,移動_0root_Gloss=enter|SpaceAfter=No3虎虎NOUNn,名詞,主体,動物_4nmod_Gloss=tiger|SpaceAfter=No4穴穴NOUNn,名詞,固定物,地形Case=Loc2obj_Gloss=cave|SpaceAfter=No5不不ADVv,副詞,否定,無界Polarity=Neg6advmod_Gloss=not|SpaceAfter=No6得得VERBv,動詞,行為,得失_2parataxis_Gloss=get|SpaceAfter=No7虎虎NOUNn,名詞,主体,動物_8nmod_Gloss=tiger|SpaceAfter=No8子子NOUNn,名詞,人,関係_6obj_Gloss=child|SpaceAfter=No>>>t=s[1]>>>print(t.id,t.form,t.lemma,t.upos,t.xpos,t.feats,t.head.id,t.deprel,t.deps,t.misc)1不不ADVv,副詞,否定,無界Polarity=Neg2advmod_Gloss=not|SpaceAfter=No>>>print(s.to_tree())不<════╗advmod入═══╗═╝═╗root虎<╗║║nmod穴═╝<╝║obj不<════╗║advmod得═══╗═╝<╝parataxis虎<╗║nmod子═╝<╝obj>>>f=open("trial.svg","w")>>>f.write(s.to_svg())>>>f.close()guwencombo.load()has two optionsguwencombo.load(BERT="guwenbert-base",Danku=False). With the optionBERT="guwenbert-large"the pipeline utilizesGuwenBERT-large. With the optionDanku=Truethe pipeline tries to segment sentences automatically.to_tree()andto_svg()are borrowed from those ofUD-Kanbun.Kundoku usage>>>importguwencombo>>>lzh=guwencombo.load()>>>s=lzh("不入虎穴不得虎子")>>>t=guwencombo.translate(s)>>>print(t)# text = 虎の穴に入らずして虎の子を得ず1虎虎NOUNn,名詞,主体,動物_3nmod_Gloss=tiger|SpaceAfter=No2の_ADP__1case_SpaceAfter=No3穴穴NOUNn,名詞,固定物,地形Case=Loc5obj_Gloss=cave|SpaceAfter=No4に_ADP__3case_SpaceAfter=No5入ら入VERBv,動詞,行為,移動_0root_Gloss=enter|SpaceAfter=No6ずして不AUXv,副詞,否定,無界Polarity=Neg5advmod_Gloss=not|SpaceAfter=No7虎虎NOUNn,名詞,主体,動物_9nmod_Gloss=tiger|SpaceAfter=No8の_ADP__7case_SpaceAfter=No9子子NOUNn,名詞,人,関係_11obj_Gloss=child|SpaceAfter=No10を_ADP__9case_SpaceAfter=No11得得VERBv,動詞,行為,得失_5parataxis_Gloss=get|SpaceAfter=No12ず不AUXv,副詞,否定,無界Polarity=Neg11advmod_Gloss=not|SpaceAfter=No>>>print(t.sentence())虎の穴に入らずして虎の子を得ず>>>print(s.kaeriten())不㆑入㆓虎穴㆒不㆑得㆓虎子㆒>>>print(t.to_tree())虎═╗<╗nmod(体言による連体修飾語)の<╝║case(格表示)穴═╗═╝<╗obj(目的語)に<╝║case(格表示)入═╗═══╝═╗root(親)ら║║ず<╝║advmod(連用修飾語)し║て║虎═╗<╗║nmod(体言による連体修飾語)の<╝║║case(格表示)子═╗═╝<╗║obj(目的語)を<╝║║case(格表示)得═╗═══╝<╝parataxis(隣接表現)ず<╝advmod(連用修飾語)translate()andreorder()are borrowed from those ofUD-Kundoku.Installation for Linuxpip3installguwencomboInstallation for Cygwin64Make sure to getpython37-develpython37-pippython37-cythonpython37-numpypython37-cffigcc-g++mingw64-x86_64-gcc-g++gcc-fortrangitcurlmakecmakelibopenblasliblapack-devellibhdf5-devellibfreetype-devellibuv-develpackages, and then:curl-Lhttps://raw.githubusercontent.com/KoichiYasuoka/UniDic-COMBO/master/cygwin64.sh|sh
pip3.7installguwencomboInstallation for macOSg++--version
pip3installguwencombo--user
python3-mspacydownloaden_core_web_sm--userIf you fail to installJsonnet, try below before installing GuwenCOMBO:(echo'#! /bin/sh';echo'exec gcc `echo $* | sed "s/-arch [^ ]*//g"`')>/tmp/clang
chmod755/tmp/clang
envPATH="/tmp:$PATH"pip3installjsonnet--userIf you fail to installfugashi, try to installMeCabbefore installing GuwenCOMBO:cd/tmp
gitclone--depth=1https://github.com/taku910/mecabcdmecab/mecab
./configure--with-charset=UTF8
make&&sudomakeinstallReference安岡孝一:TransformersのBERTは共通テスト『国語』を係り受け解析する夢を見るか, 東洋学へのコンピュータ利用, 第33回研究セミナー (2021年3月5日), pp.3-34.