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).

1  
!7
2  
3  
static new L<Map> data;
4  
5  
p {
6  
  S text = loadSnippet(#1008407);
7  
  data.clear();
8  
  new HashSet<S> paragraphSet;
9  
  for (S line : toLinesFullTrim(text)) {
10  
    if (line.startsWith("#")) continue;
11  
    if (!paragraphSet.add(line)) continue;
12  
    //print(line);
13  
    L<S> split = splitIntoSentences_v1(line);
14  
    printWithRisingIndent(split);
15  
    S sp;
16  
    if (l(split) == 1 && eq(first(split), line))
17  
      sp = "-";
18  
    else
19  
      //sp = htmlEncode_nlToBr(lines(split));
20  
      sp = ul(htmlEncodeAll(split));
21  
      
22  
    data.add(litorderedmap(
23  
      "Original Paragraph" := htmlencode(line),
24  
      "Split" := sp,
25  
      "OK" := hcheckbox(lstr(data), false, "class" := "chkbox")));
26  
  }
27  
  data = sortByCalculatedField(data, func(Map m) {
28  
    comparableList(
29  
      neq(m.get("Split"), "-"),
30  
      m.get("Original Paragraph"))
31  
  });
32  
  serveHttpOpenBrowser(4000);
33  
}
34  
35  
static NanoHTTPD.Response serve(S uri, NanoHTTPD.Method method,
36  
  Map<S,S> header, Map<S,S> parms, Map<S,S> files) {
37  
  
38  
  S title = "Splitting paragraphs into sentences";
39  
  
40  
  ret serveHTML(hhtml(
41  
      hhead(htitle(title)
42  
        + loadJQuery()
43  
        + hCheckBoxMultiSelect())
44  
    + hbody(h3(title)
45  
      + hform(htable_noEncode(data)
46  
      + p(hsubmit())))));
47  
}

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: 482 / 576
Version history: 16 change(s)
Referenced in: [show references]