Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data


< > BotCompany Repo | #1004402 // singular - try to get singular of a word

JavaX fragment (include)

static SS singular_specials = litmap(
  "children", "child", "images", "image", "chess", "chess");
static Set<S> singular_specials2 = litciset("time", "machine", "line", "rule");

static S singular(S s) {
  if (s == null) null;
  try answer singular_specials.get(s);
  //try answer hippoSingulars().get(lower(s));
  if (singular_specials2.contains(dropSuffix("s", afterLastSpace(s))))
    ret dropSuffix("s", s);
  if (s.endsWith("ness")) ret s;
  if (s.endsWith("ges")) ret dropSuffix("s", s);
  if (endsWith(s, "bases")) ret dropLast(s);
  s = dropSuffix("es", s);
  s = dropSuffix("s", s);
  ret s;

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004402
Snippet name: singular - try to get singular of a word
Eternal ID of this version: #1004402/9
Text MD5: 12aec2e4169d99ad74e6bd56402c8c56
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-20 19:06:09
Source code size: 623 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 593 / 588
Version history: 8 change(s)
Referenced in: [show references]