json loading directly

master
Michael Murtaugh 6 years ago
parent 2612aab009
commit c0a8fe42b8

@ -1,52 +1,71 @@
{ {
"final": "Goodbye. Thank you for talking to me.",
"pre": [
"dont don't",
"cant can't",
"wont won't",
"recollect remember",
"dreamt dreamed",
"dreams dream",
"maybe perhaps",
"how what",
"when what",
"certainly yes",
"machine computer",
"computers computer",
"were was",
"you're you are",
"i'm i am",
"same alike"
],
"initial": "How do you do. Please tell me your problem.", "initial": "How do you do. Please tell me your problem.",
"keywords": [ "keywords": [
{ {
"weight": 0, "weight": 0,
"token": "xnone",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"I'm not sure I understand you fully.", "I'm not sure I understand you fully.",
"Please go on.", "Please go on.",
"What does that suggest to you ?", "What does that suggest to you ?",
"Do you feel strongly about discussing such things ?" "Do you feel strongly about discussing such things ?"
]
}
], ],
"token": "xnone" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "sorry",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Please don't apologise.", "Please don't apologise.",
"Apologies are not necessary.", "Apologies are not necessary.",
"I've told you that apologies are not required." "I've told you that apologies are not required."
]
}
], ],
"token": "sorry" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "apologise",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto sorry" "goto sorry"
]
}
], ],
"token": "apologise" "decomp": "*"
}
]
}, },
{ {
"weight": 5, "weight": 5,
"token": "remember",
"rules": [ "rules": [
{ {
"decomp": "* i remember *",
"reasmb": [ "reasmb": [
"Do you often think of (2) ?", "Do you often think of (2) ?",
"Does thinking of (2) bring anything else to mind ?", "Does thinking of (2) bring anything else to mind ?",
@ -54,177 +73,177 @@
"Why do you recollect (2) just now ?", "Why do you recollect (2) just now ?",
"What in the present situation reminds you of (2) ?", "What in the present situation reminds you of (2) ?",
"What is the connection between me and (2) ?" "What is the connection between me and (2) ?"
] ],
"decomp": "* i remember *"
}, },
{ {
"decomp": "* do you remember *",
"reasmb": [ "reasmb": [
"Did you think I would forget (2) ?", "Did you think I would forget (2) ?",
"Why do you think I should recall (2) now ?", "Why do you think I should recall (2) now ?",
"What about (2) ?", "What about (2) ?",
"goto what", "goto what",
"You mentioned (2) ?" "You mentioned (2) ?"
]
}
], ],
"token": "remember" "decomp": "* do you remember *"
}
]
}, },
{ {
"weight": 3, "weight": 3,
"token": "if",
"rules": [ "rules": [
{ {
"decomp": "* if *",
"reasmb": [ "reasmb": [
"Do you think its likely that (2) ?", "Do you think its likely that (2) ?",
"Do you wish that (2) ?", "Do you wish that (2) ?",
"What do you know about (2) ?", "What do you know about (2) ?",
"Really, if (2) ?" "Really, if (2) ?"
]
}
], ],
"token": "if" "decomp": "* if *"
}
]
}, },
{ {
"weight": 4, "weight": 4,
"token": "dreamed",
"rules": [ "rules": [
{ {
"decomp": "* i dreamed *",
"reasmb": [ "reasmb": [
"Really, (2) ?", "Really, (2) ?",
"Have you ever fantasized (2) while you were awake ?", "Have you ever fantasized (2) while you were awake ?",
"Have you ever dreamed (2) before ?", "Have you ever dreamed (2) before ?",
"goto dream" "goto dream"
]
}
], ],
"token": "dreamed" "decomp": "* i dreamed *"
}
]
}, },
{ {
"weight": 3, "weight": 3,
"token": "dream",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"What does that dream suggest to you ?", "What does that dream suggest to you ?",
"Do you dream often ?", "Do you dream often ?",
"What persons appear in your dreams ?", "What persons appear in your dreams ?",
"Do you believe that dreams have something to do with your problems ?" "Do you believe that dreams have something to do with your problems ?"
]
}
], ],
"token": "dream" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "perhaps",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"You don't seem quite certain.", "You don't seem quite certain.",
"Why the uncertain tone ?", "Why the uncertain tone ?",
"Can't you be more positive ?", "Can't you be more positive ?",
"You aren't sure ?", "You aren't sure ?",
"Don't you know ?" "Don't you know ?"
]
}
], ],
"token": "perhaps" "decomp": "*"
}
]
}, },
{ {
"weight": 15, "weight": 15,
"token": "name",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"I am not interested in names.", "I am not interested in names.",
"I've told you before, I don't care about names -- please continue." "I've told you before, I don't care about names -- please continue."
]
}
], ],
"token": "name" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "deutsch",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto xforeign", "goto xforeign",
"I told you before, I don't understand German." "I told you before, I don't understand German."
]
}
], ],
"token": "deutsch" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "francais",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto xforeign", "goto xforeign",
"I told you before, I don't understand French." "I told you before, I don't understand French."
]
}
], ],
"token": "francais" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "italiano",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto xforeign", "goto xforeign",
"I told you before, I don't understand Italian." "I told you before, I don't understand Italian."
]
}
], ],
"token": "italiano" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "espanol",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto xforeign", "goto xforeign",
"I told you before, I don't understand Spanish." "I told you before, I don't understand Spanish."
]
}
], ],
"token": "espanol" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "xforeign",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"I speak only English." "I speak only English."
]
}
], ],
"token": "xforeign" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "hello",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"How do you do. Please state your problem.", "How do you do. Please state your problem.",
"Hi. What seems to be your problem ?" "Hi. What seems to be your problem ?"
]
}
], ],
"token": "hello" "decomp": "*"
}
]
}, },
{ {
"weight": 50, "weight": 50,
"token": "computer",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Do computers worry you ?", "Do computers worry you ?",
"Why do you mention computers ?", "Why do you mention computers ?",
@ -232,79 +251,79 @@
"Don't you think computers can help people ?", "Don't you think computers can help people ?",
"What about machines worrys you ?", "What about machines worrys you ?",
"What do you think about machines ?" "What do you think about machines ?"
]
}
], ],
"token": "computer" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "am",
"rules": [ "rules": [
{ {
"decomp": "* am i *",
"reasmb": [ "reasmb": [
"Do you believe you are (2) ?", "Do you believe you are (2) ?",
"Would you want to be (2) ?", "Would you want to be (2) ?",
"Do you wish I would tell you you are (2) ?", "Do you wish I would tell you you are (2) ?",
"What would it mean if you were (2) ?", "What would it mean if you were (2) ?",
"goto what" "goto what"
] ],
"decomp": "* am i *"
}, },
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Why do you say 'am' ?", "Why do you say 'am' ?",
"I don't understand that." "I don't understand that."
]
}
], ],
"token": "am" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "are",
"rules": [ "rules": [
{ {
"decomp": "* are you *",
"reasmb": [ "reasmb": [
"Why are you interested in whether I am (2) or not ?", "Why are you interested in whether I am (2) or not ?",
"Would you prefer if I weren't (2) ?", "Would you prefer if I weren't (2) ?",
"Perhaps I am (2) in your fantasies.", "Perhaps I am (2) in your fantasies.",
"Do you sometimes think I am (2) ?", "Do you sometimes think I am (2) ?",
"goto what" "goto what"
] ],
"decomp": "* are you *"
}, },
{ {
"decomp": "* are *",
"reasmb": [ "reasmb": [
"Did you think they might not be (2) ?", "Did you think they might not be (2) ?",
"Would you like it if they were not (2) ?", "Would you like it if they were not (2) ?",
"What if they were not (2) ?", "What if they were not (2) ?",
"Possibly they are (2)." "Possibly they are (2)."
]
}
], ],
"token": "are" "decomp": "* are *"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "your",
"rules": [ "rules": [
{ {
"decomp": "* your *",
"reasmb": [ "reasmb": [
"Why are you concerned over my (2) ?", "Why are you concerned over my (2) ?",
"What about your own (2) ?", "What about your own (2) ?",
"Are you worried about someone else's (2) ?", "Are you worried about someone else's (2) ?",
"Really, my (2) ?" "Really, my (2) ?"
]
}
], ],
"token": "your" "decomp": "* your *"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "was",
"rules": [ "rules": [
{ {
"decomp": "* was i *",
"reasmb": [ "reasmb": [
"What if you were (2) ?", "What if you were (2) ?",
"Do you think you were (2) ?", "Do you think you were (2) ?",
@ -312,34 +331,34 @@
"What would it mean if you were (2) ?", "What would it mean if you were (2) ?",
"What does (2) suggest to you ?", "What does (2) suggest to you ?",
"goto what" "goto what"
] ],
"decomp": "* was i *"
}, },
{ {
"decomp": "* i was *",
"reasmb": [ "reasmb": [
"Were you really ?", "Were you really ?",
"Why do you tell me you were (2) now ?", "Why do you tell me you were (2) now ?",
"Perhaps I already know you were (2)." "Perhaps I already know you were (2)."
] ],
"decomp": "* i was *"
}, },
{ {
"decomp": "* was you *",
"reasmb": [ "reasmb": [
"Would you like to believe I was (2) ?", "Would you like to believe I was (2) ?",
"What suggests that I was (2) ?", "What suggests that I was (2) ?",
"What do you think ?", "What do you think ?",
"Perhaps I was (2).", "Perhaps I was (2).",
"What if I had been (2) ?" "What if I had been (2) ?"
]
}
], ],
"token": "was" "decomp": "* was you *"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "i",
"rules": [ "rules": [
{ {
"decomp": "* i @desire *",
"reasmb": [ "reasmb": [
"What would it mean to you if you got (3) ?", "What would it mean to you if you got (3) ?",
"Why do you want (3) ?", "Why do you want (3) ?",
@ -347,123 +366,123 @@
"What if you never got (3) ?", "What if you never got (3) ?",
"What would getting (3) mean to you ?", "What would getting (3) mean to you ?",
"What does wanting (3) have to do with this discussion ?" "What does wanting (3) have to do with this discussion ?"
] ],
"decomp": "* i @desire *"
}, },
{ {
"decomp": "* i am* @sad *",
"reasmb": [ "reasmb": [
"I am sorry to hear that you are (3).", "I am sorry to hear that you are (3).",
"Do you think that coming here will help you not to be (3) ?", "Do you think that coming here will help you not to be (3) ?",
"I'm sure it's not pleasant to be (3).", "I'm sure it's not pleasant to be (3).",
"Can you explain what made you (3) ?" "Can you explain what made you (3) ?"
] ],
"decomp": "* i am* @sad *"
}, },
{ {
"decomp": "* i am* @happy *",
"reasmb": [ "reasmb": [
"How have I helped you to be (3) ?", "How have I helped you to be (3) ?",
"Has your treatment made you (3) ?", "Has your treatment made you (3) ?",
"What makes you (3) just now ?", "What makes you (3) just now ?",
"Can you explan why you are suddenly (3) ?" "Can you explan why you are suddenly (3) ?"
] ],
"decomp": "* i am* @happy *"
}, },
{ {
"decomp": "* i was *",
"reasmb": [ "reasmb": [
"goto was" "goto was"
] ],
"decomp": "* i was *"
}, },
{ {
"decomp": "* i @belief * i *",
"reasmb": [ "reasmb": [
"Do you really think so ?", "Do you really think so ?",
"But you are not sure you (3).", "But you are not sure you (3).",
"Do you really doubt you (3) ?" "Do you really doubt you (3) ?"
] ],
"decomp": "* i @belief * i *"
}, },
{ {
"decomp": "* i* @belief *you *",
"reasmb": [ "reasmb": [
"goto you" "goto you"
] ],
"decomp": "* i* @belief *you *"
}, },
{ {
"decomp": "* i am *",
"reasmb": [ "reasmb": [
"Is it because you are (2) that you came to me ?", "Is it because you are (2) that you came to me ?",
"How long have you been (2) ?", "How long have you been (2) ?",
"Do you believe it is normal to be (2) ?", "Do you believe it is normal to be (2) ?",
"Do you enjoy being (2) ?" "Do you enjoy being (2) ?"
] ],
"decomp": "* i am *"
}, },
{ {
"decomp": "* i @cannot *",
"reasmb": [ "reasmb": [
"How do you think that you can't (3) ?", "How do you think that you can't (3) ?",
"Have you tried ?", "Have you tried ?",
"Perhaps you could (3) now.", "Perhaps you could (3) now.",
"Do you really want to be able to (3) ?" "Do you really want to be able to (3) ?"
] ],
"decomp": "* i @cannot *"
}, },
{ {
"decomp": "* i don't *",
"reasmb": [ "reasmb": [
"Don't you really (2) ?", "Don't you really (2) ?",
"Why don't you (2) ?", "Why don't you (2) ?",
"Do you wish to be able to (2) ?", "Do you wish to be able to (2) ?",
"Does that trouble you ?" "Does that trouble you ?"
] ],
"decomp": "* i don't *"
}, },
{ {
"decomp": "* do i feel *",
"reasmb": [ "reasmb": [
"Tell me more about such feelings.", "Tell me more about such feelings.",
"Do you often feel (2) ?", "Do you often feel (2) ?",
"Do you enjoy feeling (2) ?", "Do you enjoy feeling (2) ?",
"Of what does feeling (2) remind you ?" "Of what does feeling (2) remind you ?"
] ],
"decomp": "* do i feel *"
}, },
{ {
"decomp": "* i * you *",
"reasmb": [ "reasmb": [
"Perhaps in your fantasies we (2) each other.", "Perhaps in your fantasies we (2) each other.",
"Do you wish to (2) me ?", "Do you wish to (2) me ?",
"You seem to need to (2) me.", "You seem to need to (2) me.",
"Do you (2) anyone else ?" "Do you (2) anyone else ?"
] ],
"decomp": "* i * you *"
}, },
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"You say (1) ?", "You say (1) ?",
"Can you elaborate on that ?", "Can you elaborate on that ?",
"Do you say (1) for some special reason ?", "Do you say (1) for some special reason ?",
"That's quite interesting." "That's quite interesting."
]
}
], ],
"token": "i" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "you",
"rules": [ "rules": [
{ {
"decomp": "* you remind me of *",
"reasmb": [ "reasmb": [
"goto alike" "goto alike"
] ],
"decomp": "* you remind me of *"
}, },
{ {
"decomp": "* you are *",
"reasmb": [ "reasmb": [
"What makes you think I am (2) ?", "What makes you think I am (2) ?",
"Does it please you to believe I am (2) ?", "Does it please you to believe I am (2) ?",
"Do you sometimes wish you were (2) ?", "Do you sometimes wish you were (2) ?",
"Perhaps you would like to be (2)." "Perhaps you would like to be (2)."
] ],
"decomp": "* you are *"
}, },
{ {
"decomp": "* you* me *",
"reasmb": [ "reasmb": [
"Why do you think I (2) you ?", "Why do you think I (2) you ?",
"You like to think I (2) you -- don't you ?", "You like to think I (2) you -- don't you ?",
@ -472,113 +491,113 @@
"Do you wish to believe I (2) you ?", "Do you wish to believe I (2) you ?",
"Suppose I did (2) you -- what would that mean ?", "Suppose I did (2) you -- what would that mean ?",
"Does someone else believe I (2) you ?" "Does someone else believe I (2) you ?"
] ],
"decomp": "* you* me *"
}, },
{ {
"decomp": "* you *",
"reasmb": [ "reasmb": [
"We were discussing you -- not me.", "We were discussing you -- not me.",
"Oh, I (2) ?", "Oh, I (2) ?",
"You're not really talking about me -- are you ?", "You're not really talking about me -- are you ?",
"What are your feelings now ?" "What are your feelings now ?"
]
}
], ],
"token": "you" "decomp": "* you *"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "yes",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"You seem to be quite positive.", "You seem to be quite positive.",
"You are sure.", "You are sure.",
"I see.", "I see.",
"I understand." "I understand."
]
}
], ],
"token": "yes" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "no",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Are you saying no just to be negative?", "Are you saying no just to be negative?",
"You are being a bit negative.", "You are being a bit negative.",
"Why not ?", "Why not ?",
"Why 'no' ?" "Why 'no' ?"
]
}
], ],
"token": "no" "decomp": "*"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "my",
"rules": [ "rules": [
{ {
"decomp": "* my *",
"save": true, "save": true,
"reasmb": [ "reasmb": [
"Does that have anything to do with the fact that your (2) ?", "Does that have anything to do with the fact that your (2) ?",
"Lets discuss further why your (2).", "Lets discuss further why your (2).",
"Earlier you said your (2).", "Earlier you said your (2).",
"But your (2)." "But your (2)."
] ],
"decomp": "* my *"
}, },
{ {
"decomp": "* my* @family *",
"reasmb": [ "reasmb": [
"Tell me more about your family.", "Tell me more about your family.",
"Who else in your family (4) ?", "Who else in your family (4) ?",
"Your (3) ?", "Your (3) ?",
"What else comes to mind when you think of your (3) ?" "What else comes to mind when you think of your (3) ?"
] ],
"decomp": "* my* @family *"
}, },
{ {
"decomp": "* my *",
"reasmb": [ "reasmb": [
"Your (2) ?", "Your (2) ?",
"Why do you say your (2) ?", "Why do you say your (2) ?",
"Does that suggest anything else which belongs to you ?", "Does that suggest anything else which belongs to you ?",
"Is it important that your (2) ?" "Is it important that your (2) ?"
]
}
], ],
"token": "my" "decomp": "* my *"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "can",
"rules": [ "rules": [
{ {
"decomp": "* can you *",
"reasmb": [ "reasmb": [
"You believe I can (2) don't you ?", "You believe I can (2) don't you ?",
"goto what", "goto what",
"You want me to be able to (2).", "You want me to be able to (2).",
"Perhaps you would like to be able to (2) yourself." "Perhaps you would like to be able to (2) yourself."
] ],
"decomp": "* can you *"
}, },
{ {
"decomp": "* can i *",
"reasmb": [ "reasmb": [
"Whether or not you can (2) depends on you more than me.", "Whether or not you can (2) depends on you more than me.",
"Do you want to be able to (2) ?", "Do you want to be able to (2) ?",
"Perhaps you don't want to (2).", "Perhaps you don't want to (2).",
"goto what" "goto what"
]
}
], ],
"token": "can" "decomp": "* can i *"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "what",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Why do you ask ?", "Why do you ask ?",
"Does that question interest you ?", "Does that question interest you ?",
@ -589,63 +608,63 @@
"What comes to mind when you ask that ?", "What comes to mind when you ask that ?",
"Have you asked such questions before ?", "Have you asked such questions before ?",
"Have you asked anyone else ?" "Have you asked anyone else ?"
]
}
], ],
"token": "what" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "because",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Is that the real reason ?", "Is that the real reason ?",
"Don't any other reasons come to mind ?", "Don't any other reasons come to mind ?",
"Does that reason seem to explain anything else ?", "Does that reason seem to explain anything else ?",
"What other reasons might there be ?" "What other reasons might there be ?"
]
}
], ],
"token": "because" "decomp": "*"
}
]
}, },
{ {
"weight": 0, "weight": 0,
"token": "why",
"rules": [ "rules": [
{ {
"decomp": "* why don't you *",
"reasmb": [ "reasmb": [
"Do you believe I don't (2) ?", "Do you believe I don't (2) ?",
"Perhaps I will (2) in good time.", "Perhaps I will (2) in good time.",
"Should you (2) yourself ?", "Should you (2) yourself ?",
"You want me to (2) ?", "You want me to (2) ?",
"goto what" "goto what"
] ],
"decomp": "* why don't you *"
}, },
{ {
"decomp": "* why can't i *",
"reasmb": [ "reasmb": [
"Do you think you should be able to (2) ?", "Do you think you should be able to (2) ?",
"Do you want to be able to (2) ?", "Do you want to be able to (2) ?",
"Do you believe this will help you to (2) ?", "Do you believe this will help you to (2) ?",
"Have you any idea why you can't (2) ?", "Have you any idea why you can't (2) ?",
"goto what" "goto what"
] ],
"decomp": "* why can't i *"
}, },
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto what" "goto what"
]
}
], ],
"token": "why" "decomp": "*"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "everyone",
"rules": [ "rules": [
{ {
"decomp": "* @everyone *",
"reasmb": [ "reasmb": [
"Realy, (2) ?", "Realy, (2) ?",
"Surely not (2).", "Surely not (2).",
@ -656,67 +675,67 @@
"Someone special perhaps ?", "Someone special perhaps ?",
"You have a particular person in mind, don't you ?", "You have a particular person in mind, don't you ?",
"Who do you think you're talking about ?" "Who do you think you're talking about ?"
]
}
], ],
"token": "everyone" "decomp": "* @everyone *"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "everybody",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto everyone" "goto everyone"
]
}
], ],
"token": "everybody" "decomp": "*"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "nobody",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto everyone" "goto everyone"
]
}
], ],
"token": "nobody" "decomp": "*"
}
]
}, },
{ {
"weight": 2, "weight": 2,
"token": "noone",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"goto everyone" "goto everyone"
]
}
], ],
"token": "noone" "decomp": "*"
}
]
}, },
{ {
"weight": 1, "weight": 1,
"token": "always",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"Can you think of a specific example ?", "Can you think of a specific example ?",
"When ?", "When ?",
"What incident are you thinking of ?", "What incident are you thinking of ?",
"Really, always ?" "Really, always ?"
]
}
], ],
"token": "always" "decomp": "*"
}
]
}, },
{ {
"weight": 10, "weight": 10,
"token": "alike",
"rules": [ "rules": [
{ {
"decomp": "*",
"reasmb": [ "reasmb": [
"In what way ?", "In what way ?",
"What resemblence do you see ?", "What resemblence do you see ?",
@ -726,25 +745,24 @@
"What is the connection, do you suppose ?", "What is the connection, do you suppose ?",
"Could here really be some connection ?", "Could here really be some connection ?",
"How ?" "How ?"
]
}
], ],
"token": "alike" "decomp": "*"
}
]
}, },
{ {
"weight": 10, "weight": 10,
"token": "like",
"rules": [ "rules": [
{ {
"decomp": "* @be *like *",
"reasmb": [ "reasmb": [
"goto alike" "goto alike"
]
}
], ],
"token": "like" "decomp": "* @be *like *"
}
]
} }
], ],
"final": "Goodbye. Thank you for talking to me.",
"post": [ "post": [
"am are", "am are",
"your my", "your my",
@ -766,23 +784,5 @@
"everyone everybody nobody noone", "everyone everybody nobody noone",
"be am is are was" "be am is are was"
], ],
"pre": [
"dont don't",
"cant can't",
"wont won't",
"recollect remember",
"dreamt dreamed",
"dreams dream",
"maybe perhaps",
"how what",
"when what",
"certainly yes",
"machine computer",
"computers computer",
"were was",
"you're you are",
"i'm i am",
"same alike"
],
"quit": [] "quit": []
} }

@ -51,7 +51,20 @@
</div> </div>
<script src="eliza.js"></script> <script src="eliza.js"></script>
<script> <script>
function eliza (rules) { function get_json (url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
callback(data);
} else { callback("server error"); }
};
request.onerror = function() { callback("connection error"); };
request.send();
}
get_json("doctor.json", function (rules) {
var input = document.getElementById("textinput"), var input = document.getElementById("textinput"),
output = document.getElementById("display"), output = document.getElementById("display"),
bot = chatbot(rules, true); bot = chatbot(rules, true);
@ -78,8 +91,8 @@ function eliza (rules) {
} }
}); });
say(rules.initial); say(rules.initial);
} });
</script> </script>
<script src="doctor.js"></script>
</body> </body>
</html> </html>

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
#wrapper {
display: flex;
flex-direction: column;
position: absolute;
left: 5%; top: 5%; right: 5%; bottom: 5%;
}
#textinput {
width: 100%;
border: none;
background: none;
}
#input {
padding: 2%;
flex: 0 1 auto;
background: aqua;
}
#display {
flex: 1 1 auto;
background: pink;
padding: 2%;
overflow: auto;
}
#display div.msg {
padding-bottom: 0.5em;
}
#display div.human {
color: black;
}
#display div.bot {
color: black;
text-transform: uppercase;
}
#display div.debug {
color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="display">
</div>
<div id="input">
<input type="text" id="textinput" autofocus />
</div>
</div>
<script src="eliza.js"></script>
<script>
function eliza (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
function log (msg, kls) {
var d = document.createElement("div");
d.setAttribute("class", "msg " + kls);
d.innerHTML = msg;
display.appendChild(d);
}
function say (msg) {
log(msg, "bot");
display.scrollTop = display.scrollTopMax;
}
input.addEventListener("keypress", function (event) {
if (event.keyCode == 13) {
var text = input.value;
log(text, "user");
say(bot(text), "bot");
input.value = "";
input.focus();
}
});
say(rules.initial);
}
</script>
<script src="doctor.js"></script>
</body>
</html>

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
#wrapper {
display: flex;
flex-direction: column;
position: absolute;
left: 5%; top: 5%; right: 5%; bottom: 5%;
}
#textinput {
width: 100%;
border: none;
background: none;
}
#input {
padding: 2%;
flex: 0 1 auto;
background: aqua;
}
#display {
flex: 1 1 auto;
background: pink;
padding: 2%;
overflow: auto;
}
#display div.msg {
padding-bottom: 0.5em;
}
#display div.human {
color: black;
}
#display div.bot {
color: black;
text-transform: uppercase;
}
#display div.debug {
color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="display">
</div>
<div id="input">
<input type="text" id="textinput" autofocus />
</div>
</div>
<script src="eliza.js"></script>
<script>
function get_json (url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
callback(data);
} else { callback("server error"); }
};
request.onerror = function() { callback("connection error"); };
request.send();
}
get_json("doctor.json", function (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
function log (msg, kls) {
var d = document.createElement("div");
d.setAttribute("class", "msg " + kls);
d.innerHTML = msg;
display.appendChild(d);
}
function say (msg) {
responsiveVoice.speak(msg)
log(msg, "bot");
// https://responsivevoice.org/api/
display.scrollTop = display.scrollTopMax;
// responsiveVoice.speak("hello world", "UK English Male", {onstart: StartCallback, onend: EndCallback});
}
var voicelist = responsiveVoice.getVoices();
console.log("voicelist", voicelist);
responsiveVoice.setDefaultVoice("US English Female");
input.addEventListener("keypress", function (event) {
if (event.keyCode == 13) {
var text = input.value;
log(text, "user");
say(bot(text), "bot");
input.value = "";
input.focus();
}
});
say(rules.initial);
});
</script>
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
</body>
</html>

@ -2,3 +2,6 @@
python3 eliza_script_to_json.py < $< > $@ python3 eliza_script_to_json.py < $< > $@
%.js: %.json %.js: %.json
python3 jsonp.py --callback "eliza" < $< > $@ python3 jsonp.py --callback "eliza" < $< > $@
doctor.html: doctor.json
python3 json_to_print.py $< rules.template.html > $@

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>Speech synthesiser</title>
<link rel="stylesheet" href="style.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<h1>Speech synthesiser</h1>
<p>Enter some text in the input below and press return to hear it. change voices using the dropdown menu.</p>
<form>
<input type="text" class="txt">
<div>
<label for="rate">Rate</label><input type="range" min="0.5" max="2" value="1" step="0.1" id="rate">
<div class="rate-value">1</div>
<div class="clearfix"></div>
</div>
<div>
<label for="pitch">Pitch</label><input type="range" min="0" max="2" value="1" step="0.1" id="pitch">
<div class="pitch-value">1</div>
<div class="clearfix"></div>
</div>
<select>
</select>
</form>
<script src="speech.js"></script>
</body>
</html>

@ -0,0 +1,67 @@
var synth = window.speechSynthesis;
var inputForm = document.querySelector('form');
var inputTxt = document.querySelector('.txt');
var voiceSelect = document.querySelector('select');
var pitch = document.querySelector('#pitch');
var pitchValue = document.querySelector('.pitch-value');
var rate = document.querySelector('#rate');
var rateValue = document.querySelector('.rate-value');
var voices = [];
function populateVoiceList() {
voices = synth.getVoices();
var selectedIndex = voiceSelect.selectedIndex < 0 ? 0 : voiceSelect.selectedIndex;
voiceSelect.innerHTML = '';
for(i = 0; i < voices.length ; i++) {
var option = document.createElement('option');
option.textContent = voices[i].name + ' (' + voices[i].lang + ')';
if(voices[i].default) {
option.textContent += ' -- DEFAULT';
}
option.setAttribute('data-lang', voices[i].lang);
option.setAttribute('data-name', voices[i].name);
voiceSelect.appendChild(option);
}
voiceSelect.selectedIndex = selectedIndex;
}
populateVoiceList();
if (speechSynthesis.onvoiceschanged !== undefined) {
speechSynthesis.onvoiceschanged = populateVoiceList;
}
inputForm.onsubmit = function(event) {
event.preventDefault();
var utterThis = new SpeechSynthesisUtterance(inputTxt.value);
var selectedOption = voiceSelect.selectedOptions[0].getAttribute('data-name');
for(i = 0; i < voices.length ; i++) {
if(voices[i].name === selectedOption) {
utterThis.voice = voices[i];
}
}
utterThis.pitch = pitch.value;
utterThis.rate = rate.value;
synth.speak(utterThis);
utterThis.onpause = function(event) {
var char = event.utterance.text.charAt(event.charIndex);
console.log('Speech paused at character ' + event.charIndex + ' of "' +
event.utterance.text + '", which is "' + char + '".');
}
inputTxt.blur();
}
pitch.onchange = function() {
pitchValue.textContent = pitch.value;
}
rate.onchange = function() {
rateValue.textContent = rate.value;
}
Loading…
Cancel
Save