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); // get entities if (nla.entities == null) { new Matches m; nla.entities = linkedHashSet(); for (S s : nla.lines) if "There is...|there are..." { S name = m.rest(); NLABlock.Entity e = new(name, s); if (matchX2("a...|an...", name, m)) e.addSynonym("the " + m.rest()); nla.entities.add(e); } } // parse lines into fragments if (nla.parsedLines == null) { nla.parsedLines = new L; MapSO wordTree = wordTree(); for (NLABlock.Entity e : nla.entities) for (S s : e.synonyms) addToWordTree(wordTree, javaTokC(s), e); print(+wordTree); for (int i = 0; i < l(nla.lines); i++) { S s = nla.lines.get(i); O parsed = parseToFragmentsUsingWordTree(s, wordTree); listPut(nla.parsedLines, i, parsed); } } ret nla; }