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

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个回答



您要查找的内容称为变形</ strong>。 基本上,这是确定单词各种形式(特别是从复数形式还是相反形式的单数形式)的妖术。</ p>

有很多为此目的提供的库,它们的灵感主要来自Ruby On Rails ActiveSupport :: Inflector </ code>系统,请参见例如 https://github.com/jinzhu/inflection 。</ p>

另请参见 http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html 中有关英语多元算法的有趣读物。</ p>
< / DIV>

展开原文

原文

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.

dongshuo8756
dongshuo8756 感谢您分享链接。 第二个链接将我设置在正确的轨道上。
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐