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

29
LINES

< > BotCompany Repo | #1028213 // Probabilistic Riddle Parsing Spike 1 [seems to run forever]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (7974L/41K).

!7

cprint {
  start-thread {
    S riddle = "STATIC ALA FLATTEN LIST OF PAIRS L PAIR A LL A OUT EMPTY LIST LL FOR PAIR APUN NULL L OUT ADD PA OUT ADD PB RET OUT";
    S productions = [[
      $main        := $function
      $function    := $modifiers $typeParameters $returnType $name "(" $args ")" "{" $body "}"
      $body        := repeat0OrMore($statement)
      $declaration := $type $name "=" $value ";"
      $statement   := $returnStmt | $declaration
      $returnStmt  := "ret" $value ";"
    ]];
    
    new LS prods2;
    for (S grammarClass, def : parseColonEqualsProperties_tlftj(productions)) {
      def = replaceDollarVarsWithAngleBracketed(def);
      LS tok = javaTokWithAngleBracketsC(def);
      S def2 = joinWithSpace(withoutQuoted(tok));
      S replacement = joinWithSpace("bla");
      prods2.add(dropDollarPrefix(grammarClass) + " => " + quote(def2) + " => " + replacement);
    }
    
    new RecursiveProbabilisticParser1 parser;
    parser.minTokensForAny = 0;
    //parser.verbose = true;
    print(recursiveProbabilisticParse(print(lines(prods2)), "function", riddle, +parser));
  }
}

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: #1028213
Snippet name: Probabilistic Riddle Parsing Spike 1 [seems to run forever]
Eternal ID of this version: #1028213/1
Text MD5: 8e23c94ecc8b1fdf4b9555b45c793521
Transpilation MD5: 0020c252ff1f192d51fc385a30aa61af
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-26 14:29:50
Source code size: 1144 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 124 / 191
Referenced in: [show references]