plural

Matching plurals using regex in C#

僤鯓⒐⒋嵵緔 提交于 2019-12-08 16:58:57
问题 I'm looking to use regex in C# to search for terms and I want to include the plurals of those terms in the search. For example if the user wants to search for 'pipe' then I want to return results for 'pipes' as well. So I can do this... string s ="\\b" + term + "s*\\b"; if (Regex.IsMatch(bigtext, s) { /* do stuff */ } How would I modify the above to allow me to match, say, 'stresses' when the user enters 'stress' and still work for 'pipe'/'pipes'? 回答1: Here's a regex created to remove the

geting error/warning for plurals : “The quantity 'one' matches more than one specific number…”

你。 提交于 2019-12-04 18:55:20
问题 Background I work on an app that has many translations inside it. I have the next English plural strings: <plurals name="something"> <item quantity="one">added photo</item> <item quantity="other">added %d photos</item> </plurals> and the French translation: <plurals name="something"> <item quantity="one">a ajouté une photo</item> <item quantity="other">a ajouté %d photos</item> </plurals> The problem For both the French and Russian, I get the next warning: The quantity 'one' matches more than

Java internationalization (i18n) with proper plurals

旧时模样 提交于 2019-12-04 07:41:36
问题 I was going to use Java's standard i18n system with the ChoiceFormat class for plurals, but then realized that it doesn't handle the complex plural rules of some languages (e.g. Polish). If it only handles languages that resemble English, then it seems a little pointless. What options are there to achieve correct plural forms? What are the pros and cons of using them? 回答1: Well, you already tagged the question correctly, so I assume you know thing or two about ICU. With ICU you have two

geting error/warning for plurals : “The quantity 'one' matches more than one specific number…”

旧巷老猫 提交于 2019-12-03 12:34:49
Background I work on an app that has many translations inside it. I have the next English plural strings: <plurals name="something"> <item quantity="one">added photo</item> <item quantity="other">added %d photos</item> </plurals> and the French translation: <plurals name="something"> <item quantity="one">a ajouté une photo</item> <item quantity="other">a ajouté %d photos</item> </plurals> The problem For both the French and Russian, I get the next warning: The quantity 'one' matches more than one specific number in this locale, but the message did not include a formatting argument (such as %d)

Quantity “two” not working in Android Strings-Resources Plural

本小妞迷上赌 提交于 2019-12-03 11:38:21
Android allows translators to define Plurals . The following example works for me with locale 'en': <plurals name="numberOfSongsAvailable"> <item quantity="one">One song found.</item> <item quantity="other">%d songs found.</item> </plurals> But adding a special value for two does not work, still the other version is taken. Is the usage of two dependent upon the locale? So does Android only take the two version if the locale explicitly specifies that there should be a two version? The SO Question Android plurals treatment of “zero” spots the same mistake when using zero in English which is also

How to use Android quantity strings (plurals)?

自闭症网瘾萝莉.ら 提交于 2019-12-03 09:40:24
I am trying to use getQuantityString method in Resources to retrieve Quantity Strings (Plurals) based on android developer guidelines Quantity String (Plurals) The error I am getting is Error:(604) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(604) Found tag </item> where </plurals> is expected when I set up plurals as below <plurals name="productCount"> <item quantity="one" formatted="true">%1$d of %2$d product</item> <item quantity="other" formatted="true">%1$d of %2$d products</item> </plurals> and trying to read it as

Java internationalization (i18n) with proper plurals

我们两清 提交于 2019-12-02 15:48:43
I was going to use Java's standard i18n system with the ChoiceFormat class for plurals, but then realized that it doesn't handle the complex plural rules of some languages (e.g. Polish). If it only handles languages that resemble English, then it seems a little pointless. What options are there to achieve correct plural forms? What are the pros and cons of using them? Paweł Dyda Well, you already tagged the question correctly, so I assume you know thing or two about ICU . With ICU you have two choices for proper handling of plural forms: PluralRules , which gives you the rules for given Locale

.NET EF 6 Pluralization with prefix in table names

久未见 提交于 2019-12-02 06:41:51
Plural table names are default convention in EF. but when I have added the prefix I can not make names anymore plural unfortunately. Any ideas? protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Types() .Configure(entity => entity.ToTable("MyPrefix_" + entity.ClrType.Name)); modelBuilder.Conventions.Add<PluralizingTableNameConvention>(); base.OnModelCreating(modelBuilder); } The PluralizingTableNameConvention uses a PluralizationService that can be used anywhere. So you can go ahead and use it in your configuration code. Here is an example using a Model "Person

Converting plural to singular in a text file with Python

可紊 提交于 2019-11-30 20:09:11
I have txt files that look like this: word, 23 Words, 2 test, 1 tests, 4 And I want them to look like this: word, 23 word, 2 test, 1 test, 4 I want to be able to take a txt file in Python and convert plural words to singular. Here's my code: import nltk f = raw_input("Please enter a filename: ") def openfile(f): with open(f,'r') as a: a = a.read() a = a.lower() return a def stem(a): p = nltk.PorterStemmer() [p.stem(word) for word in a] return a def returnfile(f, a): with open(f,'w') as d: d = d.write(a) #d.close() print openfile(f) print stem(openfile(f)) print returnfile(f, stem(openfile(f)))

Javascript pluralize a string

做~自己de王妃 提交于 2019-11-30 10:56:56
问题 In PHP, I use Kuwamoto's class to pluralize nouns in my strings. I didn't find something as good as this script in javascript except for some plugins. So, it would be great to have a javascript function based on Kuwamoto's class. http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/ 回答1: Simple version (ES6): const maybePluralize = (count, noun, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`; Usage: maybePluralize(0, 'turtle'); // 0 turtles