CKIP E-HowNet Tools¶
Author¶
Mu Yang <https://muyang.pro>
Requirements¶
Python 3.6+
PLY (Python Lex-Yacc) 3.11+
TreeLib 1.5.5+
wcwidth 0.1.7+
Installation¶
pip install -U ehownet
Usage¶
See https://ehownet.readthedocs.io/en/latest/main/grammar.html for E-HowNet grammar.
See https://ehownet.readthedocs.io/en/latest/main/parse_node.html for E-HowNet parsing nodes usage.
E-HowNet Parser¶
CLI¶
# Usage
ehn-parser <text> [<text> ...]
# Example
ehn-parser \
"{MusicTool|樂器_x:predication={own|有:possession={按鈕|PushingButton:whole={x}}}}" \
"{InstitutePlace|場所:telic={or({experiment|實驗:location={~}},{research|研究:location={~}})}}" \
"TimePoint={},manner={urgent|急}"
Output:
#1
[Entity $x] MusicTool|樂器
└── [Feature] predication
└── [Entity] own|有
└── [Feature] possession
└── [Entity] 按鈕|PushingButton
└── [Feature] whole
└── $x
#2
[Entity] InstitutePlace|場所
└── [Feature] telic
└── [FunctionEntity]
└── [Function] or
├── [Entity] experiment|實驗
│ └── [Feature] location
│ └── [TildeEntity]
└── [Entity] research|研究
└── [Feature] location
└── [TildeEntity]
#3
[Root]
├── [Feature] TimePoint
│ └── [AnyEntity]
└── [Feature] manner
└── [Entity] urgent|急
Python API¶
from ehn.parse import EhnParser
text = '{MusicTool|樂器_x:predication={own|有:possession={按鈕|PushingButton:whole={x}}}}'
parser = EhnParser()
ress = parser(text, debug=False)
for res in ress:
res.tree().show()
Output:
[Entity $x] MusicTool|樂器
└── [Feature] predication
└── [Entity] own|有
└── [Feature] possession
└── [Entity] 按鈕|PushingButton
└── [Feature] whole
└── $x