How can I get the possessive form of a noun?

Here's an algorithm for adding an apostrophe to a given input noun.

How would you describe a line to show ownership?

/** * apostrophizes the string properly * <pre> * curtis = curtis' * shaun = shaun's * </pre> * * @param input string to apostrophize * @return apostrophized string or empty string if the input was empty or null. */ public static String apostrophize(String input) { if (isEmpty(input)) return ""; if ("s".equalsIgnoreCase(StringUtils.right(input,1))) { return input + "'"; } else { return input + "'s"; } } 
+4
source share
3 answers

How do you build a string to display ownership?

Alternatives:

  • Avoid the problem by avoiding the need to create a possessive for any arbitrary word or name. This is what I would do ... if I did not feel like a masochist.

  • Do a simple job that will ( inevitably ) lead to the fact that in English it will not be possible to conduct a "good style" test in some cases. And be prepared to dismiss complaints from an endless stream of dingbats who have nothing better in their time than complaining about bad style / grammar.

  • Spend a long time building infrastructure that is able to analyze words in a single / plural, regular noun / own noun, etc. etc. Then implement the style rules according to the parsing / semantic analysis of the text you are generating. (And then repeat the whole process for every natural language that your website ... or any other ... should support.)

+4
source

No, this is not grammatically correct. Curtis is the right way to say that something belongs to Curtis, because Curtis is the only one. If the noun is plural, you would use the back apostrophe to indicate possessive.

Edit: Sean, in my most humble opinion, as a person with experience as a writer and editor of English, as well as a programmer, I don’t feel that there is a simple answer to this problem. I don’t feel it is correct to write Curtis to express possessive, and I also feel that there is a widespread, though not universal, agreement on this issue.

The real work of any algorithmic approach to solving this problem is to determine whether the noun is exceptional or plural, and this is an extremely difficult task to solve, which goes beyond the answer of StackOverflow. Good luck to you.

+2
source

The reverse form is more stable

  String.Format("The {1} of {0}", owner, item); 
+1
source

Source: https://habr.com/ru/post/1299358/


All Articles