doutan1637 2017-05-01 11:13
浏览 43

在“ golang.org/x/text”中出现复数软件包

I am doing some tests with the golang.org/x/text package and particularly with the feature/plural sub package and its MatchDigits method. Here is what I am doing :

package main

import (
    "fmt"

    "golang.org/x/text/feature/plural"
    "golang.org/x/text/language"
)

func main() {
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1}, 1, 0)) // "1" -> should print 2 (One) but prints 0 (Other)
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{2}, 1, 0)) // "2" -> prints 0 (Other) the correct value
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1, 0}, 2, 0)) // "10" -> prints 0 (Other) the correct value
}

And here is where I get the expected results from : http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#fr

I also tried with another language with more complex plural rules like Czech and the output was not correct.

Am I missing something ? I can not find a lot of examples on this package.

Thanks !

EDIT:

After some more tests, I found the good result for "1", using 0 as both the exp and scale parameters :

fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1}, 0, 0)) // prints 2 (One), the correct value

But it does not follow what the documentation says, and does not work when I try for 1,5 with the same logic :

fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1, 5}, 0, 1)) // prints 0 (Other), should print 2 (One)
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大