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

15
LINES

< > BotCompany Repo | #1011041 // getSingularFromWordHippo

JavaX fragment (include)

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

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: 312 / 1006
Version history: 11 change(s)
Referenced in: [show references]