doudi1978 2016-04-03 21:02
浏览 53
已采纳

查找一个单词是否为另一个的复数

I am writing a program in Go to generate a report of crimes in my University. I have run into a roadblock where I need to find if one word is a plural of another. I am making a map of crimes first

crimes := make(map[string]int)

then, adding crimes to the map with the number of occurrences as int

for i := 0; i < len(feed.Items); i++ {
  crimes[feed.Items[i].Title[11:]]++
}

Now, the problem arises when there are entries like, "Armed Robberies (with a count of 1)" and "Armed Robbery (with a count of 2)". I want to check if a word is a plural of another. In this case, I want to make a single entry for "Armed Robbery (with a count of 3)". I could not find a package for doing this. Is there a way to do this?

  • 写回答

1条回答 默认 最新

  • dsjz1119 2016-04-03 21:09
    关注

    What you are looking for is called inflections. Basically, it is the black art of determining the various forms of a word, in particular singular from plural, or the opposite.

    There are libraries for this, mostly inspired from the Ruby On Rails ActiveSupport::Inflector system, see for example https://github.com/jinzhu/inflection.

    Also see http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html for a very interesting read about algorithms for english pluralization.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题