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

43
LINES

< > BotCompany Repo | #1028008 // Cool NLP Shopping List [dev.]

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

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

1  
!7
2  
3  
cmodule ShoppingList > DynPrintLog {
4  
  
5  
  transient S input = [[
6  
    okay shopping list
7  
    buy bananas
8  
    at least three
9  
    I have to be cheap
10  
    they have to be cheap
11  
    buy potatoes
12  
    also get some milk
13  
    newspapers
14  
    hold on I have a phone call
15  
    hey Mom
16  
    yes mam
17  
    it's all good
18  
    by Mom
19  
    okay I'm back
20  
    where were we
21  
    buy some chicken
22  
    or maybe no chicken
23  
    okay that's all
24  
  ]];
25  
    
26  
  transient S rules = [[
27  
    sentence => "(first/then/also/) we (will/) need (some/) <stuff>" => buy $1
28  
    sentence => "(first/then/also/) (buy/get/you should get) (some/) <stuff>" => buy $1
29  
    sentence => "they have to be <quality>" => last item has to be $1
30  
    sentence => "at least <quantity>" => last item quantity at least $1
31  
    sentence => "or (maybe/rather/) no <stuff>" => don't buy $1 after all
32  
  ]];
33  
34  
  LS intermediate; // intermediate result (buy X, ...)
35  
36  
  start-thread {
37  
    new RecursiveProbabilisticParser1 parser;
38  
    parser.splitIntoSentences = lambda1 tlft;
39  
40  
    setField(intermediate := recursiveProbabilisticParse(rules, "sentence", input, +parser));
41  
    pnlWithHeading("Intermediate result", intermediate);
42  
  }
43  
}

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: #1028008
Snippet name: Cool NLP Shopping List [dev.]
Eternal ID of this version: #1028008/1
Text MD5: 4bfb396733a9f93c73881d7397ddb444
Transpilation MD5: d974e8db23a6bd5d20327edc2b7b6455
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-01 19:31:57
Source code size: 1166 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 219 / 957
Referenced in: [show references]