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

关于单词的形变 #9

Open
einverne opened this issue Nov 8, 2018 · 4 comments · May be fixed by erjun/mdx-server#1
Open

关于单词的形变 #9

einverne opened this issue Nov 8, 2018 · 4 comments · May be fixed by erjun/mdx-server#1

Comments

@einverne
Copy link
Contributor

einverne commented Nov 8, 2018

我看到了 #2 关于单词大小写的讨论,一个项目专注于一件事情本来是非常正确的事。

我经过一些调研,GoldenDict 通过 "构词法规则库"(Morphology)可以轻松的实现,但是 mdx-server 则不那么容易实现。Python 中我看到可以通过 nltk 这个库来去除单词的形变,是否可以考虑将单词去除形变作为一个可选项整合到 mdx-server 中,如果可以我提交 pull-request。

另外请问下作者有其他单词形变相关的 lib 吗?

@ninja33
Copy link
Owner

ninja33 commented Nov 8, 2018

消除变形一般有stemming和lemmatization两种方式。比较精确的方式是lemmatization,毕竟stemming后会产生一些无意义的单词。python的nltk库,能lemmatizing的语言只有英语。所以这个选项也只对英语有效(我想你要PR的也是英语吧)。但是MDX词典文件,不仅仅是针对英语的,比如拉丁字符语言集而言,还有西,德,意,法等语言。其实最好的lemmatization的方式,是暴力列表。就是把所有可能性都列出来。比如像这个repo里列出的那样
https://github.com/michmech/lemmatization-lists/

你可以fork一个针对英语使用ntlk的,我可以在readme里放上你的链接。但是我自己不认为mdx-server能实现全功能全语言去除变形,毕竟这个对于一个小小的mdx转换工具来说,太重了。

@einverne
Copy link
Contributor Author

einverne commented Nov 8, 2018

好的先谢谢,确实是我考虑不周,没有考虑到西、德、意等语种类。我刚也检索了一番,nltk 库确实只能够解决英语部分的问题。

另外一个问题就是我注意到 GoldenDict 使用了下面的规则库,其中也支持其他很多语言,如果能够复用这些规则应该也能够解决部分问题,只是目前我还没有找到相关材料去分析他用到的这些规则。

https://sourceforge.net/projects/goldendict/files/better%20morphologies/1.0/ 这里的。

另外我拉一个分支先解决下英语部分的问题吧,稍后更新上。

einverne added a commit to einverne/mdx-server that referenced this issue Nov 27, 2018
@einverne
Copy link
Contributor Author

更新到了一个分支 https://github.com/einverne/mdx-server/tree/morphology 借助了 ECDICT 项目中词性还原的部分代码,简单的实现了英语的词形还原。

@lwl5219
Copy link

lwl5219 commented Dec 21, 2023

发现了另外一个库来处理词形的变化 https://github.com/stanfordnlp/stanza/,

import stanza

nlp = stanza.Pipeline('en', processors='tokenize,lemma', download_method=None)

nlp("knives")

输出

[
  [
    {
      "id": 1,
      "text": "knives",
      "lemma": "knife",
      "start_char": 0,
      "end_char": 6
    }
  ]
]

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

Successfully merging a pull request may close this issue.

3 participants