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

37
LINES

< > BotCompany Repo | #1005474 // Parse Sentence [works]

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

Libraryless. Click here for Pure Java version (5523L/35K/118K).

1  
!752
2  
3  
concepts.
4  
5  
concept WithTime {
6  
  new Ref sentence;
7  
  new Ref time;
8  
}
9  
10  
concept SPO {
11  
  new Ref s; // subject
12  
  new Ref p; // predicate
13  
  new Ref o; // object
14  
  
15  
  *() {}
16  
  *(Concept s, Concept p, Concept o) {
17  
    this.s.set(s);
18  
    this.p.set(p);
19  
    this.o.set(o);
20  
  }
21  
}
22  
23  
p {
24  
  print(structureConcept(parse("I've been here today")));
25  
}
26  
27  
static Concept parse(S s) {
28  
  new Matches m;
29  
  
30  
  if (flexMatch("* today", s, m))
31  
    ret cnew(WithTime, sentence := parse($1), time := concept("today"));
32  
  
33  
  if (flexMatch("I've been *", s, m))
34  
    ret new SPO(cstr("I"), cstr("have been"), parse($1));
35  
    
36  
  ret cstr(s); // default
37  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005474
Snippet name: Parse Sentence [works]
Eternal ID of this version: #1005474/1
Text MD5: f3a5b7534f69822edf22621bcc591c6d
Transpilation MD5: 01d60814c1a231f68127848e3481e71e
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-20 19:12:57
Source code size: 664 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 518 / 617
Referenced in: [show references]