Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always has a b' or a b" #27

Closed
sudo-d4s3 opened this issue May 10, 2016 · 5 comments
Closed

always has a b' or a b" #27

sudo-d4s3 opened this issue May 10, 2016 · 5 comments

Comments

@sudo-d4s3
Copy link

sudo-d4s3 commented May 10, 2016

I don't know what I'm doing wrong this is my code

from chatterbotapi import ChatterBotFactory, ChatterBotType

factory = ChatterBotFactory()

bot1 = factory.create(ChatterBotType.CLEVERBOT)
bot1session = bot1.create_session()

bot2 = factory.create(ChatterBotType.CLEVERBOT)
bot2session = bot2.create_session()

s = 'Hi'
while (1):

    print ('bot1> ' + s)

    s = bot2session.think(s);
    print ('bot2> ' + s)

    s = bot1session.think(s);

and here is the output

bot1> Hi
bot2> b'Ja jestem ch\xc5\x82opakiem palancie.
bot1> b"That's not english.
bot2> b'Yash, it is.
bot1> b"Your last message was, but not the one before.
bot2> b'What are you doing?
bot1> b"Talking to you. What are you doing?
bot2> b'Talking with you. I think.
bot1> b"Ohhh, that was suprising.

@pierredavidbelanger
Copy link
Owner

Did you mod the chatterbotapi.py file ?

Can you paste here whats in your chatterbotapi.py file, near the lines 73 and 144

@sudo-d4s3
Copy link
Author

thought.text = text
return self.think_thought(thought).text

class ChatterBotThought:

pass

#################################################

Cleverbot impl

#################################################

class _Cleverbot(ChatterBot):

def __init__(self, baseUrl, serviceUrl, endIndex):
    self.baseUrl = baseUrl
    self.serviceUrl = serviceUrl
    self.endIndex = endIndex

def create_session(self):
    return _CleverbotSession(self)

class _CleverbotSession(ChatterBotSession):

def __init__(self, bot):
    self.bot = bot
    self.vars = OrderedDict()
    #self.vars['start'] = 'y'
    self.vars['stimulus'] = ''
    self.vars['islearning'] = '1'
    self.vars['icognoid'] = 'wsf'
    #self.vars['fno'] = '0'
    #self.vars['sub'] = 'Say'
    #self.vars['cleanslate'] = 'false'
    self.cookieJar = cookielib.CookieJar()
    self.opener = build_opener(HTTPCookieProcessor(self.cookieJar))
    self.opener.open(self.bot.baseUrl)

def think_thought(self, thought):
    self.vars['stimulus'] = thought.text
    data = urlencode(self.vars)
    data_to_digest = data[9:self.bot.endIndex]
    data_digest =

hashlib.md5(data_to_digest.encode('utf-8')).hexdigest()
data = data + '&icognocheck=' + data_digest
url_response = self.opener.open(self.bot.serviceUrl,
data.encode('utf-8'))
response = str(url_response.read())
response_values = re.split(r'\r|\r', response)
#self.vars['??'] = _utils_string_at_index(response_values, 0)
self.vars['sessionid'] = _utils_string_at_index(response_values, 1)
self.vars['logurl'] = _utils_string_at_index(response_values, 2)
self.vars['vText8'] = _utils_string_at_index(response_values, 3)
self.vars['vText7'] = _utils_string_at_index(response_values, 4)
self.vars['vText6'] = _utils_string_at_index(response_values, 5)
self.vars['vText5'] = _utils_string_at_index(response_values, 6)
self.vars['vText4'] = _utils_string_at_index(response_values, 7)
self.vars['vText3'] = _utils_string_at_index(response_values, 8)
self.vars['vText2'] = _utils_string_at_index(response_values, 9)
self.vars['prevref'] = _utils_string_at_index(response_values, 10)
#self.vars['??'] = _utils_string_at_index(response_values, 11)

self.vars['emotionalhistory'] =

_utils_string_at_index(response_values, 12)

self.vars['ttsLocMP3'] = _utils_string_at_index(response_values,

self.vars['ttsLocTXT'] = _utils_string_at_index(response_values,

self.vars['ttsLocTXT3'] = _utils_string_at_index(response_values,

self.vars['ttsText'] = _utils_string_at_index(response_values, 16)

self.vars['lineRef'] = _utils_string_at_index(response_values, 17)

self.vars['lineURL'] = _utils_string_at_index(response_values, 18)

self.vars['linePOST'] = _utils_string_at_index(response_values, 19)

self.vars['lineChoices'] = _utils_string_at_index(response_values,

self.vars['lineChoicesAbbrev'] =

_utils_string_at_index(response_values, 21)

self.vars['typingData'] = _utils_string_at_index(response_values,

self.vars['divert'] = _utils_string_at_index(response_values, 23)

    response_thought = ChatterBotThought()
    response_thought.text = _utils_string_at_index(response_values, 0)

On Tue, May 10, 2016 at 3:03 PM, Pierre-David Bélanger <
notifications@github.com> wrote:

Did you mod the chatterbotapi.py
https://github.com/pierredavidbelanger/chatter-bot-api/blob/master/python/chatterbotapi.py
file ?

Can you paste here whats in your chatterbotapi.py
https://github.com/pierredavidbelanger/chatter-bot-api/blob/master/python/chatterbotapi.py
file, near the lines 73
https://github.com/pierredavidbelanger/chatter-bot-api/blob/master/python/chatterbotapi.py#L73
and 144
https://github.com/pierredavidbelanger/chatter-bot-api/blob/master/python/chatterbotapi.py#L144


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#27 (comment)

@pierredavidbelanger
Copy link
Owner

This is strange.
I do not know your OS, or even if you are executing this is an terminal.
But, if you happen to use a unix like OS (linux or osx), execute the locale command in a terminal and paste the output here.
It should give you something like this:

$ locale
LANG="fr_CA.UTF-8"
LC_COLLATE="fr_CA.UTF-8"
LC_CTYPE="fr_CA.UTF-8"
LC_MESSAGES="fr_CA.UTF-8"
LC_MONETARY="fr_CA.UTF-8"
LC_NUMERIC="fr_CA.UTF-8"
LC_TIME="fr_CA.UTF-8"
LC_ALL=

@sudo-d4s3
Copy link
Author

I am running this on windows, with python idle but on another pc and it
doesn't do this
On May 11, 2016 3:01 PM, "Pierre-David Bélanger" notifications@github.com
wrote:

This is strange.
I do not know your OS, or even if you are executing this is an terminal.
But, if you happen to use a unix like OS (linux or osx), execute the
locale command in a terminal and paste the output here.
It should give you something like this:

$ locale
LANG="fr_CA.UTF-8"
LC_COLLATE="fr_CA.UTF-8"
LC_CTYPE="fr_CA.UTF-8"
LC_MESSAGES="fr_CA.UTF-8"
LC_MONETARY="fr_CA.UTF-8"
LC_NUMERIC="fr_CA.UTF-8"
LC_TIME="fr_CA.UTF-8"
LC_ALL=


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#27 (comment)

@pierredavidbelanger
Copy link
Owner

I do not have access to Windows, so I can not reproduce this strange bug.
Are you able to tel what is the difference between the two pc ?
Maybe the Python version, the OS locale, the IDE ..

Also, before your program (after the from chatterbotapi import ChatterBotFactory, ChatterBotType), try putting those lines:

import locale
locale.setlocale(locale.LC_ALL, '')

Anyways, I guess it has something to do with your OS regional or locale settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants