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

20
LINES

< > BotCompany Repo | #1023879 // wordNet - download & parse a WordNet entry [OK]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5720L/39K).

static L<WordNet> wordNet(S word, O... _) {
  optPar bool verbose;
  new L<WordNet> out;
  for (LS li : html_contentsOfLIs(wordNet_rawPage(word))) {
    new WordNet w;
    w.word = htmlDecode(stringContentsOfFirstContainerTag(li, "b"));
    w.wordType = deRoundBracket(trimJoin(contentsOfContainerTag(first(findContainerTagWithParams(li, "a", class := "pos")))));
    w.examples = htmlDecode(deRoundBracket(trim(stringContentsOfFirstContainerTag(li, "i"))));
    S raw = join(dropContainerTags(cloneList(li)));
    w.description = htmlDecode(deRoundBracket(dropLeadingCommas(trim(raw))));
    w.synonyms = new L;
    for (LS a : findContainerTag(li, "a"))
      if (nempty(tagParam(a, "href")))
        addUnlessEqualTo(w.synonyms, htmlDecode(trimJoin(contentsOfContainerTag(a))), "S:");
    
    if (verbose) print(w);
    out.add(w);
  }
  ret out;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1023879
Snippet name: wordNet - download & parse a WordNet entry [OK]
Eternal ID of this version: #1023879/10
Text MD5: b58322467a365e5a715a9ee9388470f9
Transpilation MD5: ca752b113cf985b16cb3577aff0fe74c
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-11 16:40:45
Source code size: 871 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 397
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)