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

23
LINES

< > TinyBrain | #1007670 - conceptsFromDump

JavaX fragment (include)

static L<AIConcept> conceptsFromDump(S s) {
  new L<L<S>> l;
  if (neq(first(javaTokC(s)), "[")) {
    for (S line : toLinesFullTrim(s)) {
      int i = line.indexOf(" - ");
      if (i > 0) {
        S id = trim(substring(line, 0, i));
        if (!possibleGlobalID(id)) warn("no id: " + id);
        else
          l.add(ll(id, trim(substring(line, i+3))));
      }
    }
  } else
    l = (L) safeUnstructure("[" + s + "]");
  new L<AIConcept> out;
  for (L<S> x : l) {
    AIConcept c = unlisted(AIConcept);
    S id = makeNewID(get(x, 0));
    cset(c, globalID := id, name := unnull(get(x, 1)), comment := unnull(get(x, 2)));
    out.add(c);
  }
  ret out;
}

download  show line numbers  debug dex   

Travelled to 2 computer(s): cfunsshuasjs, tvejysmllsmz

No comments. add comment

Snippet ID: #1007670
Snippet name: conceptsFromDump
Eternal ID of this version: #1007670/4
Text MD5: e39a20ae5c458fbb271a08620d8a15cf
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-21 16:34:39
Source code size: 684 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 32 / 12
Version history: 3 change(s)
Referenced in: [show]