Skip to content

Commit

Permalink
added "what gift should I buy" rules in german "was sol ich schenken"
Browse files Browse the repository at this point in the history
and bugfixes to make this possible.
Just as "was soll ich schenken"
  • Loading branch information
Orbiter committed Jan 1, 2017
1 parent 4548f44 commit d8854e9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions conf/susi/en_0810_ai_problem_solving_present_expert.txt
Expand Up @@ -16,12 +16,9 @@ For whom should the present be?^gift^>_action

# counter questions and communication flow

my *|*
my *
?$_action$=gift:You want to buy a gift for your $1$>_person. Does `$1$ noun` like `$1$ topic`>_topic?^giftlike^>_action

yes
?$_action$=giftlike:


# knowledge about persons to generate correct sentences

Expand All @@ -43,6 +40,9 @@ flowers|jewelry|gardening
wife topic
flowers|jewelry

husband topic

neig

# links to products

Expand Down
8 changes: 4 additions & 4 deletions src/org/loklak/susi/SusiAction.java
Expand Up @@ -86,12 +86,12 @@ public DialogType getDialogType() {
}

public static DialogType getDialogType(Collection<String> phrases) {
DialogType type = DialogType.answer;
DialogType type = DialogType.reply;
for (String phrase: phrases) {
type = getDialogType(phrase);
if (type != DialogType.answer) return type;
DialogType t = getDialogType(phrase);
if (t.getSubscore() < type.getSubscore()) type = t;
}
return DialogType.answer;
return type;
}

public static DialogType getDialogType(String phrase) {
Expand Down
1 change: 1 addition & 0 deletions src/org/loklak/susi/SusiMind.java
Expand Up @@ -389,6 +389,7 @@ public List<SusiArgument> react(String query, int maxcount, String client, SusiT
SusiArgument observation_argument = new SusiArgument();
if (observation != null && observation.length() > 0) observation_argument.think(observation);
ArrayList<SusiInteraction> interactions = this.logs.getInteractions(client);
// latest interaction is first in list
interactions.forEach(action -> observation_argument.think(action.recallDispute()));
// perform a mindmeld to create a single thought out of the recalled argument
// the mindmeld will squash the latest thoughts into one so it does not pile up to exponential growth
Expand Down
2 changes: 1 addition & 1 deletion src/org/loklak/susi/SusiRule.java
Expand Up @@ -438,7 +438,7 @@ public SusiArgument consideration(final String query, SusiThought recall, SusiRe
}

// we deduced thoughts from the inferences in the rules. Now apply the actions of rule to produce results
this.getActionsClone().forEach(action -> flow.addAction(action/*.apply(flow, mind, client)*/));
this.getActionsClone().forEach(action -> flow.addAction(action/*.execution(flow, mind, client)*/));
return flow;
}
// fail, no alternative was successful
Expand Down
15 changes: 10 additions & 5 deletions src/org/loklak/susi/SusiThought.java
Expand Up @@ -364,14 +364,19 @@ private JSONArray getActionsJSON() {
* @return the instantiated statement with elements of the argument applied as much as possible
*/
public String unify(String statement) {
if (statement.indexOf('$') < 0) return statement;
JSONArray table = this.getData();
if (table != null && table.length() > 0) {
JSONObject row = table.getJSONObject(0);
for (String key: row.keySet()) {
int i;
while ((i = statement.indexOf("$" + key + "$")) >= 0) {
statement = statement.substring(0, i) + row.get(key).toString() + statement.substring(i + key.length() + 2);
for (int rownum = 0; rownum < table.length(); rownum++) {
JSONObject row = table.getJSONObject(rownum);
for (String key: row.keySet()) {
int i;
while ((i = statement.indexOf("$" + key + "$")) >= 0) {
statement = statement.substring(0, i) + row.get(key).toString() + statement.substring(i + key.length() + 2);
}
if (statement.indexOf('$') < 0) break;
}
if (statement.indexOf('$') < 0) break;
}
}
return statement;
Expand Down

0 comments on commit d8854e9

Please sign in to comment.