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

15
LINES

< > BotCompany Repo | #1011041 // getSingularFromWordHippo

JavaX fragment (include)

static S getSingularFromWordHippo(S word) {
  word = tolower(word);
  SS hippoSingulars = pairsToMap((L<Pair<S>>) scanStructureLog(#1011041, "singulars"));
  try answer hippoSingulars.get(word);
  S html = loadPage("https://www.wordhippo.com/what-is/the-singular-of/" + urlencode(word) + ".html");
  S pat = "The singular form of " + word + " is";
  int i = indexOfIC(html, pat);
  if (i < 0) { print("no singular: " + html); null; }
  i += l(pat);
  int j = indexOf(html, "</b>", i);
  if (j < 0) null;
  S singular = trim(dropTags(substring(html, i, j)));
  logStructure(#1011041, "singulars", pair(word, singular));
  ret singular;
}

Author comment

Began life as a copy of #1006546

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011041
Snippet name: getSingularFromWordHippo
Eternal ID of this version: #1011041/12
Text MD5: 4868987352d5f33c1972728f126d3f7d
Author: stefan
Category: eleu / nl
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-11 22:38:13
Source code size: 650 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 307 / 1001
Version history: 11 change(s)
Referenced in: [show references]