Libraryless. Click here for Pure Java version (4885L/30K).
static NLABlock nla_parse(S text) { ret nla_parse(new NLABlock(text)); } // fills and returns original object static NLABlock nla_parse(NLABlock nla) { // parse into lines (or sentences, both is OK) if (nla.lines == null) nla.lines = sentencesOrLines(nla.text); // parse lines into fragments & define entities if (nla.parsedLines == null) { new Matches m; nla.entities = linkedHashSet(); nla.parsedLines = new L; MapSO wordTree = wordTree(); for (int i = 0; i < l(nla.lines); i++) { S s = nla.lines.get(i); NLABlock.Line line = nla.new Line; line.text = s; line.proposition = parseToFragmentsUsingWordTree(s, wordTree); // define entity & extend word tree if "There is...|there are..." { S name = m.rest(); NLABlock.Entity e = new(name, line); if (matchX2("a...|an...", name, m)) e.addSynonym("the " + m.rest()); nla.entities.add(e); addToWordTree_multi(wordTree, e.synonyms, e); } nla.parsedLines.add(line); } } ret nla; }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028737 |
Snippet name: | nla_parse |
Eternal ID of this version: | #1028737/23 |
Text MD5: | ecba98d9c289aa2c3b08e7c92e795e85 |
Transpilation MD5: | 3d164be759a445c9c490b1b9230f07d5 |
Author: | stefan |
Category: | javax / natural language assembly |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-10 17:54:11 |
Source code size: | 1149 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 259 / 437 |
Version history: | 22 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |