Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按照语法规则分词以省去大多标示变量的「」 #659

Open
nobodxbodon opened this issue Oct 13, 2021 · 0 comments
Open

按照语法规则分词以省去大多标示变量的「」 #659

nobodxbodon opened this issue Oct 13, 2021 · 0 comments

Comments

@nobodxbodon
Copy link

不久前 作了个技术验证md文档),按六条语法规则对“创建读者表,编号为整数,出生年为文本”进行分词。
想起当前文言需要 「」 标示变量,再看了一下语法,感觉应该也可以用类似方法分词以省去大多 「」。根据此两条语法规则

表达式 : 除 标识符 以 标识符 | 乘 标识符 以 标识符

作了简单演示(源码在此,运行python docs/演示/文言分词.py即可),对如下语句分词:

除觚冪以半徑平方
乘移位數以二之對數上
除以下金额以除夕人数
除不以三开头的数以去除末尾零的数
除除夕余额以以上人数

效果如下:

觚冪 / 半徑平方
移位數 * 二之對數上
以下金额 / 除夕人数
不以三开头的数 / 去除末尾零的数
除夕余额以 / 上人数

可见仅最后一项根据语法规则确有歧义的情况分词有误。当然第四项也有歧义,只是因为现在的算法是在找到第一个符合语法规则的分词方式后停止寻找。改进之后应该可以做到在有歧义时列出所有符合语法的分词方法。之后可有几种处理方式,包括提示开发者改名、添加「」,也许也可以同时根据上下文判断。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant