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

111
LINES

< > BotCompany Repo | #1005291 // User's Name 2 [Include]

JavaX fragment (include)

// Someone's name
concept Name {
  S name;
}

// A person (human or computer)
concept Person {}

// link a person to a name
concept Person2Name {
  new Ref<Person> person;
  new Ref<Name> name;
  bool usable = true;
}

// our user
Person > User {}

// myself
Person > Me {}

// A line typed by user or bot
concept Line {
  S text;
  new Ref<Person> author;
  new Ref<LineIdea> idea; // the interpretation we settled on

  *() {}
  *(Person a, S *text) { author.set(a); }
  *(S *text, LineIdea idea) { this.idea.set(idea); }
  *(S *text, Class<? extends LineIdea> idea) { this.idea.set(uniq(idea)); }
}

// A line interpretation
concept LineIdea {}

// Bot error
LineIdea > LError {
  S stackTrace;
  
  *() {}
  *(Throwable e) { stackTrace = getStackTrace(e); change(); }
}

// "test"
LineIdea > LTest {}

// repeating another line
LineIdea > LRepeating {}

// A greeting ("hello X")
LineIdea > LGreet {
  new Ref<Person2Name> name;
  
  *() {}
  *(Person2Name n) { name.set(n); }
}

// base class for questions
LineIdea > LQuestion {}

// "What is your name?"
LQuestion > LWhatsYourName {}

// "I don't understand"
LineIdea > LIDontUnderstand {}

// I have nothing to say
LineIdea > LLalala {}

// "My name is X"
LineIdea > LMyNameIs {
  new Ref<Name> name;
}

// A specific question/answer pair
concept QA_WhatsYourName_MyNameIs {
  new Ref<Line> q;
  new Ref<Line> a;
}

LineIdea > LAskMeSomething {}

// Wrap a bug during processing of user input
LineIdea > LBug {
  S stackTrace;
  
  *() {}
  *(Throwable e) { stackTrace = getStackTrace(e); change(); }
}

// We couldn't interpret a line yet
LineIdea > LUnknown {}

LineIdea > LIDontKnowWhatToAskYou {}

LineIdea > LGreetMe {}

LineIdea > LISee {}

concept Dialog {
  new RefL<Line> lines;
}

static Dialog dialog() { ret unique(Dialog); }
static User user() { ret uniq(User); }
static Me me() { ret uniq(Me); }

static L<Person2Name> usableNames(Person p) {
  ret list(Person2Name, "usable", true, "person", p);
}

Author comment

Began life as a copy of #1005284

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1005291
Snippet name: User's Name 2 [Include]
Eternal ID of this version: #1005291/1
Text MD5: 77a34d068fa636e08a08c5ba7898fced
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-30 19:17:34
Source code size: 2080 bytes / 111 lines
Pitched / IR pitched: No / No
Views / Downloads: 533 / 507
Referenced in: