了解hunspell的茎,为什么要复数和奇异的词根相同?

发布于 2025-01-26 19:41:11 字数 1900 浏览 1 评论 0 原文

我们正在使用Elasticsearch中的Hunspell来帮助我们制止不规则名词,但并没有真正给我们带来预期的结果。

FX“ Gulerod”(胡萝卜)与“Gulerødder”(胡萝卜)分别为“ Gulerod”(单词root)和“Gulerødder”。

我尝试使用 https://www.npmjs.com/package/nodehun 以及相同的结果,这使我认为这是一个饥饿/词典问题。

我尝试了几个不同的 da_dk nb_no fx。来自 https://stavekontrolden.dk/?dictionaries=1 )第一个版本。

一个小的测试案例

    const {Nodehun} = require('nodehun');
    const fs = require('fs');

    const affix = fs.readFileSync(
        `./elasticsearch/dictionaries/hunspell/yy_YY/yy_YY.aff`
    );
    const dictionary = fs.readFileSync(
        `./elasticsearch/dictionaries/hunspell/yy_YY/yy_YY.dic`
    );
    const nodehun = new Nodehun(affix, dictionary);

    const words = [
        'gulerod',
        'gulerødder',
        'mand',
        'mænd',
        'mønster',
        'mønstre'
    ];

    for (let word of words) {
        const stems = await nodehun.stem(word);
        console.dir({word, stems});
    }

{ word: 'gulerod', stems: [ 'gulerod' ] }
{ word: 'gulerødder', stems: [ 'gulerødder' ] }
{ word: 'mand', stems: [ 'mand', 'mande' ] }
{ word: 'mænd', stems: [ 'mænd' ] }
{ word: 'mønster', stems: [ 'mønster' ] }
{ word: 'mønstre', stems: [ 'mønstre', 'mønster' ] }

,您可以看到它的输出mønster/mønstre>正确,但是在这里,不规则性不与元音有关 - 这可能是一个问题吗

现在的问题:这是由于饥饿而引起的吗?还是字典?我们可以做些什么来解决这个问题?

说明:事实证明,这是如何构建丹麦(以及可能的挪威和瑞典语)词典的原因。 “ gulerod”和“gulerødder”被视为2个不同的单词

We are using hunspell in elasticsearch to help us stem irregular nouns, but it doesn't really give us the expected result.

Fx "gulerod" (carrot) vs "gulerødder" (carrots) are stemmed to "gulerod" (word root) and "gulerødder" respectively.

I have tried stemming the words using https://www.npmjs.com/package/nodehun as well with the same outcome, which leads me to think it is a hunspell/dictionary issue.

I have tried out a couple of different da_DK and nb_NO fx. from https://stavekontrolden.dk/?dictionaries=1, LibreOffice and debian all various (older) versions of the first.

A little test-case

    const {Nodehun} = require('nodehun');
    const fs = require('fs');

    const affix = fs.readFileSync(
        `./elasticsearch/dictionaries/hunspell/yy_YY/yy_YY.aff`
    );
    const dictionary = fs.readFileSync(
        `./elasticsearch/dictionaries/hunspell/yy_YY/yy_YY.dic`
    );
    const nodehun = new Nodehun(affix, dictionary);

    const words = [
        'gulerod',
        'gulerødder',
        'mand',
        'mænd',
        'mønster',
        'mønstre'
    ];

    for (let word of words) {
        const stems = await nodehun.stem(word);
        console.dir({word, stems});
    }

which outputs

{ word: 'gulerod', stems: [ 'gulerod' ] }
{ word: 'gulerødder', stems: [ 'gulerødder' ] }
{ word: 'mand', stems: [ 'mand', 'mande' ] }
{ word: 'mænd', stems: [ 'mænd' ] }
{ word: 'mønster', stems: [ 'mønster' ] }
{ word: 'mønstre', stems: [ 'mønstre', 'mønster' ] }

As you can see it handles mønster/mønstre correctly, but here the irregularity aren't with the vowels - could that be an issue?

Now the question(s): Is this due to hunspell? Or the dictionary? And is there anything we can do to fix this?

Explanation: It turns out it is down how the danish (and possible norwegian and swedish) dictionaries are constructed. "gulerod" and "gulerødder" are treated as 2 distinct words https://github.com/jeppebundsgaard/stavekontrolden/issues/4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文