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

30
LINES

< > BotCompany Repo | #1017192 // Match Input With Pattern v1 [Dyn Module, OK]

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

Libraryless. Click here for Pure Java version (17632L/126K).

!7

sclass MatchInput > DynPrintLogWithInput {
  start {
    useLocalMechListCopies(true);
    set serverMechList_raw_fresh_verbose;
  }
  
  void update(S s) {
    print("\n> " + s);
    L<S> pats = mL("English sentence patterns");
    L<S> tok = javaTokWithAngleBracketsC(s);
    printStruct(tok);
    for (S pat : pats) {
      L<S> tokPat;
      tokPat = javaTokWithAngleBracketsC(pat);
      L<Pair<S>> match = uniquify(dropTwinPairs(zipTwoListsToPairs_ifSameLength(tokPat, tok)));
      if (match != null) {
        print("  Result: Choose pattern " + quote(pat) + " for input "  + quote(s) + " if match: " + sfu(match));
        for (Pair<S> p : match)
          if (isAngleBracketed(p.a)) {
            Set<S> entries = mechSetCI(plural_mech(deAngleBracket(p.a)));
            //print("Found " + n2(entries, "entry", "entries") + " for " + p.a);
            if (contains(entries, p.b))
              print("  Match!!");
          }
      }
    }
  }
}

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: #1017192
Snippet name: Match Input With Pattern v1 [Dyn Module, OK]
Eternal ID of this version: #1017192/24
Text MD5: 254602a425183ae94c9fb6854450d273
Transpilation MD5: fc500792b1b50a64b5569471f3b2d10a
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: 2018-07-13 19:53:27
Source code size: 988 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 325 / 508
Version history: 23 change(s)
Referenced in: [show references]