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

40
LINES

< > BotCompany Repo | #1017678 // Pregrouped Parsing Spike [OK!]

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

Download Jar. Libraryless. Click here for Pure Java version (13140L/96K).

1  
!7
2  
3  
p-exp {
4  
  S s = "{At some point in the past} I go for a walkkk";
5  
  L<S> tok = javaTokPlusBrackets(s);
6  
  tok = dropPunctuation(tok);
7  
  pnlStruct(tok);
8  
  useLocalMechListMirrorsIfBotActive_verbose();
9  
  
10  
  // Pre-parse curly fragments & guess categories for unknown words
11  
  Map<S, Map<S, Double>> guessMap = new HashMap;
12  
  new AI_BottomUpParser1 parser;
13  
  parser.wordsToCategories = DerivedMap(ai_wordToCategories());
14  
  for (int i = 1; i < l(tok); i += 2) {
15  
    S t = tok.get(i);
16  
    if (isCurlyBraced(t)) {
17  
      tok.set(i, t = uncurly(t));
18  
      PTElement tree = ai_parseToTreeWithGuessing(t);
19  
      if (tree != null) {
20  
        //preparsed.put(i, tree);
21  
        print(className(tree));
22  
        print(ai_renderCulledParseTree(tree));
23  
        
24  
        if (!tree instanceof ChooseCategory)
25  
          print("Weird: " + className(tree));
26  
        else {
27  
          for (HaveCategory c : (L<HaveCategory>) (L) tree.children)
28  
            subHashMap(guessMap, t).put(c.category, c.totalWeight);
29  
        }
30  
      } else print("No parse for " + t);
31  
    } else if (ai_isUncategorizedWord(t))
32  
      guessMap.put(t, ai_guessCategoriesForUnknownWord_weighted(t));
33  
  }
34  
  
35  
  temp tempSetThreadLocal(ai_getWordToCategoryWeight_map, guessMap);
36  
  for (S word : keys(guessMap))
37  
    parser.wordsToCategories.put(word, keys(guessMap.get(word)));
38  
  PTElement tree = ai_parseBottomUpToTree(parser, tok);
39  
  print(ai_renderCulledParseTree(tree));
40  
}

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: #1017678
Snippet name: Pregrouped Parsing Spike [OK!]
Eternal ID of this version: #1017678/13
Text MD5: 5c7d3b1c829bb422dc4bc0f0fa1febcb
Transpilation MD5: 7915acee04b87875a6fe474078226706
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-02 17:01:47
Source code size: 1461 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 451 / 1062
Version history: 12 change(s)
Referenced in: [show references]