pierredavidbelanger / chatter-bot-api

A Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.
182 stars 71 forks source link

Is it possible to force the language Cleverbot respond? #23

Closed marcinciarka closed 8 years ago

marcinciarka commented 8 years ago

I tried adding header Accept-Language: to fopen, but it doesnt work.

pierredavidbelanger commented 8 years ago

I did not even know that Cleverbot has multi language support. I will need to investigate this one.

marcinciarka commented 8 years ago

Cleverbot speaks many languages. When I write in polish on the website he always responds in polish, but through the api it does polish/english, sometimes german.

Im counting on you, thanks for great api :)

pierredavidbelanger commented 8 years ago

I've played a little with the Java version, and made it works.

The latest java 1.4.0-SNAPSHOT version (this is a snapshot release only) now accepts an array of Locale that controls the languages the bot should respond into.

If I get good feedbacks with this, I will migrate the .NET, PHP and Python versions too.

marcinciarka commented 8 years ago

Is there any chance to move this to PHP?

pierredavidbelanger commented 8 years ago

Yeah, I will take some time for this. I do not know exactly how I will do it though. Maybe make ChatterBot.createSession take an optional array of Locale ?

pierredavidbelanger commented 8 years ago

Ok, here it is, this commit allows one to pass a string to createSession to change de default language.

So now you can do something like this:

    $factory = new ChatterBotFactory();
    $bot1 = $factory->create(ChatterBotType::CLEVERBOT);
    $bot1session = $bot1->createSession('fr-CA'); // for canadian french

This new param, is straight added as an Accept-Language header

So, have a look at the Language Tags spec for the valid values you can use.

It feels like a hack, please test it and/or submit a PR to help me make this less smelly ;)