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

47
LINES

< > BotCompany Repo | #1008419 // Try segmenting text, show form through webserver [works, but doesn't save user input]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

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

!7

static new L<Map> data;

p {
  S text = loadSnippet(#1008407);
  data.clear();
  new HashSet<S> paragraphSet;
  for (S line : toLinesFullTrim(text)) {
    if (line.startsWith("#")) continue;
    if (!paragraphSet.add(line)) continue;
    //print(line);
    L<S> split = splitIntoSentences_v1(line);
    printWithRisingIndent(split);
    S sp;
    if (l(split) == 1 && eq(first(split), line))
      sp = "-";
    else
      //sp = htmlEncode_nlToBr(lines(split));
      sp = ul(htmlEncodeAll(split));
      
    data.add(litorderedmap(
      "Original Paragraph" := htmlencode(line),
      "Split" := sp,
      "OK" := hcheckbox(lstr(data), false, "class" := "chkbox")));
  }
  data = sortByCalculatedField(data, func(Map m) {
    comparableList(
      neq(m.get("Split"), "-"),
      m.get("Original Paragraph"))
  });
  serveHttpOpenBrowser(4000);
}

static NanoHTTPD.Response serve(S uri, NanoHTTPD.Method method,
  Map<S,S> header, Map<S,S> parms, Map<S,S> files) {
  
  S title = "Splitting paragraphs into sentences";
  
  ret serveHTML(hhtml(
      hhead(htitle(title)
        + loadJQuery()
        + hCheckBoxMultiSelect())
    + hbody(h3(title)
      + hform(htable_noEncode(data)
      + p(hsubmit())))));
}

Author comment

Began life as a copy of #1008408

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008419
Snippet name: Try segmenting text, show form through webserver [works, but doesn't save user input]
Eternal ID of this version: #1008419/17
Text MD5: 163da1be00a4b563fe9f55db361ec03b
Transpilation MD5: ede441d3cc8a7c91b0cc3357cb6be409
Author: stefan
Category: javax / a.i. parsing
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-24 13:15:24
Source code size: 1267 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 477 / 569
Version history: 16 change(s)
Referenced in: [show references]