Libraryless. Click here for Pure Java version (11989L/85K).
static PTElement ai_parseToTreeWithCurlyPhrases(S input) { ret ai_parseToTreeWithCurlyPhrases(input, new AI_BottomUpParser1); } static PTElement ai_parseToTreeWithCurlyPhrases(S input, AI_BottomUpParser1 parser) { L<S> tok = javaTokPlusBrackets(input); tok = dropPunctuation(tok); //pnlStruct(tok); // Pre-parse curly fragments & guess categories for unknown words Map<S, Map<S, Double>> guessMap = new HashMap; parser.wordsToCategories = DerivedMap(ai_wordToCategories()); for (int i = 1; i < l(tok); i += 2) { S t = tok.get(i); if (isCurlyBraced(t)) { tok.set(i, t = uncurly(t)); PTElement tree = ai_parseToTreeWithGuessing(t); if (tree != null) { //preparsed.put(i, tree); //print(className(tree)); //print(ai_renderCulledParseTree(tree)); if (!tree instanceof ChooseCategory) print("Weird: " + className(tree)); else { for (HaveCategory c : (L<HaveCategory>) (L) tree.children) subHashMap(guessMap, t).put(c.category, c.totalWeight); } } else { //print("No parse for " + t); } } else if (ai_isUncategorizedWord(t)) guessMap.put(t, ai_guessCategoriesForUnknownWord_weighted(t)); } temp tempSetThreadLocal(ai_getWordToCategoryWeight_map, guessMap); for (S word : keys(guessMap)) parser.wordsToCategories.put(word, keys(guessMap.get(word))); ret ai_parseBottomUpToTree(parser, tok); }
Began life as a copy of #1017403
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017685 |
Snippet name: | ai_parseToTreeWithCurlyPhrases (Parser v3) |
Eternal ID of this version: | #1017685/3 |
Text MD5: | 4b397020203a9808dcf3899b4e2353c2 |
Transpilation MD5: | 5f4e42cbe1cd124d5dee0b8bb98ad7a8 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-10 11:32:41 |
Source code size: | 1502 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 413 / 513 |
Version history: | 2 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1017738 - ai_parseToCulledTree |