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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题