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

39
LINES

< > BotCompany Repo | #1006327 // Text 2 Graph [dev.]

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

Libraryless. Click here for Pure Java version (7037L/47K/156K).

1  
!752
2  
3  
concept Node {
4  
  S name;
5  
6  
  void attachPhrase(L<S> phrase) {
7  
    print(name + ": phrase=" + phrase);
8  
  }
9  
}
10  
11  
Node > Is {
12  
  void attachPhrase(L<S> phrase) {
13  
    super.attachPhrase(phrase);
14  
    if (eq(first(phrase), "*") && l(phrase) == 3) {
15  
      S adjective = third(phrase);
16  
      print("  Could call is_" + adjective);
17  
    }
18  
  }
19  
}
20  
21  
static Node getNode(S name) {
22  
  Node node = findConcept(Node, +name);
23  
  if (node != null) ret node;
24  
  Class<? extends Node> c = Node;
25  
  if (eqic(name, "is"))
26  
    c = Is;
27  
  ret uniq(c, +name);
28  
}
29  
30  
p {
31  
  S s = "is the_button green?";
32  
  L<S> words = words(s);
33  
  for i over words: {
34  
    S word = words.get(i);
35  
    Node node = getNode(word);
36  
    L<S> phrase = replaceNthItem(words, i, "*");
37  
    node.attachPhrase(phrase);
38  
  }
39  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006327
Snippet name: Text 2 Graph [dev.]
Eternal ID of this version: #1006327/1
Text MD5: 211c80221f6442b79dae77c4b4a3bfe6
Transpilation MD5: 3eec821c37f7459429659166136c0943
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-28 21:37:34
Source code size: 797 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 616 / 725
Referenced in: [show references]