algorithm - How to turn plural words singular? -


I am preparing some table names for an ORM, and I want to convert plural table names into single entity names . My only problem is finding an algorithm that does it reliably with a word ending with -ize , then I end up with -y I replace it: li>

  • If a word ends with -es , then I terminate it. It does not always work though - for example, with type Typ
  • Otherwise, I only have the last -s
  • Does anyone detect a better algorithm?

    These are all general rules (and good people) but English is not a language for the unconscious heart : -).

    There will be a conversion engine with a set of changes in my own preferences (surprisingly enough to do the actual work.

    Regular expression will be an ideal approach due to their expression. An example rule set:

      1. If the word is fish, then return fish 2. If words If the word is "radius", then return "radius" 4. If the word is "type", then return "type" 5. If the word "ii" ends in " Ii "with" we "(octopia, viri). ::::: 97. If a word is terminated, then instead of ending with '-98, I take the place. Ends with, I end it. 99. Otherwise, I only followed -  

    Note that the rules The entry in the earlier version could not have been number 4. However, when we changed the problem with "type" in the form of "type" in 98, we made <4p>

    As such, you need to update this change table, as you discover all those amazing exceptions that English has created.


    The other possibility is not to waste your time with a general rule as the names of tables are relatively limited, just another table (or some type of data structure) should be singulars , which maps to all relevant plural table names ( employees ) for the singular object name ( employee ).

    Then a table is added every time, to add an entry in singular "table" so you can make it unique.

    / div>

    Comments

    Popular posts from this blog

    python - Overriding the save method in Django ModelForm -

    html - CSS autoheight, but fit content to height of div -

    qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -