How to turn plural words singular?

前端 未结 13 1819
旧时难觅i
旧时难觅i 2020-12-24 14:06

I\'m preparing some table names for an ORM, and I want to turn plural table names into single entity names. My only problem is finding an algorithm that does it reliably. He

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 14:19

    I'm sure you can google to find plenty of libs that do this.

    But if you feel like coding, you could try the reverse process: start with singular words of dictionary (download free ones, used by aspell or whatever), use pluralization rule; collect mappings and switch the direction. For "type" you would pluralize to "types", and reverse mapping would work as expected. While there are exceptions here too it is slightly easier to reliably pluralize things. I did this a while back (in mid 90s... :-) ), for an online game (a MUD), where descriptions for multiple identical items were concatenatd, and automatic pluralization was needed.

    Also: given that it's finite number of tables you could just use simplest algorithm, get raw output, eyeball it and fix error cases manually. :-)

提交回复
热议问题