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

!752

concepts.

concept WithTime {
  new Ref sentence;
  new Ref time;
}

concept SPO {
  new Ref s; // subject
  new Ref p; // predicate
  new Ref o; // object
  
  *() {}
  *(Concept s, Concept p, Concept o) {
    this.s.set(s);
    this.p.set(p);
    this.o.set(o);
  }
}

p {
  print(structureConcept(parse("I've been here today")));
}

static Concept parse(S s) {
  new Matches m;
  
  if (flexMatch("* today", s, m))
    ret cnew(WithTime, sentence := parse($1), time := concept("today"));
  
  if (flexMatch("I've been *", s, m))
    ret new SPO(cstr("I"), cstr("have been"), parse($1));
    
  ret cstr(s); // default
}

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: 405 / 468
Referenced in: [show references]