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

!7

p-exp {
  S s = "{At some point in the past} I go for a walkkk";
  L<S> tok = javaTokPlusBrackets(s);
  tok = dropPunctuation(tok);
  pnlStruct(tok);
  useLocalMechListMirrorsIfBotActive_verbose();
  
  // Pre-parse curly fragments & guess categories for unknown words
  Map<S, Map<S, Double>> guessMap = new HashMap;
  new AI_BottomUpParser1 parser;
  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)));
  PTElement tree = ai_parseBottomUpToTree(parser, tok);
  print(ai_renderCulledParseTree(tree));
}

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: 450 / 1061
Version history: 12 change(s)
Referenced in: