-
Notifications
You must be signed in to change notification settings - Fork 6
Are periods optional for .add()? #1
Comments
nvm im just dumb |
Glad you got it figured out. Is this something I should add to the README to make it more clear for newer users? |
@seiyria No it was just me being stupid. Once I loaded a bunch of sentences into it then it seemed to spit responses back out. The only problem I had was that it never mixed any of the sentences for replies, it was just picking a random one with X phrase from the pool so it didn't work well as a chat bot |
@contra Fair enough. Hopefully you'd also seen the addMass function for adding large blobs of text too! |
Couldn't you simplify the lib to just do this then? add: (msg) -> @sentences.push msg
reply: (phrase) ->
out = @sentences.filter (v) -> v.indexOf(phrase) isnt -1
out = Math.random out[Math.floor(Math.random()*out.length)]
return out |
I can not. This library is founded on the principle of markov chains. I suspect the reason you're getting your statements back verbatim is because your markov chain order is 4, which is very, very high for not having much data to work off of. My database of ~84k sentences, at a markov chain order of 4, would interpolate statements on common words. My first attempt, at around ~5k, was not nearly so successful in the interpolation process. I would recommend setting a markov order of 2 with a small data set and seeing if you get adequate results. If you would like to try something larger, I would make a test program to feed jsMegaHal War and Peace. One such program might resemble this: jsmegahal = require './jsMegaHal'
fs = require 'fs'
bot = new jsmegahal(2)
fs.readFile 'wap.txt', 'utf8', (err,data) ->
return console.log err if err
lines = data.split("\r\n").join(' ').split(/[?!\.]/)
bot.add line for line in lines
console.log "Loaded WAP."
process.stdin.resume()
process.stdin.setEncoding 'utf8'
process.stdin.on 'data', (chunk) ->
console.log "chunk: #{chunk}"
console.log bot.getReplyFromSentence chunk |
@seiyria That comment was tongue in cheek - I can be a bit of a troll. I'll try setting the markov order a bit lower and feeding it wap |
@contra It's hard to tell sometimes; better safe than sorry. Best of luck! |
@seiyria Did you strip all of the headings/chapter marks from the source input? |
@contra Yes, in my tests, I did. I would recommend doing so, at least for the legalese at the bottom and the non-useful data at the top. |
I keep getting nothing back from getReply and getReplyFromSentence when not using periods
The text was updated successfully, but these errors were encountered: