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

trim user's sentence #53

Merged
merged 4 commits into from
Dec 22, 2015
Merged

trim user's sentence #53

merged 4 commits into from
Dec 22, 2015

Conversation

pirelaurent
Copy link
Contributor

relates to a post https://www.chatbots.org/ai_zone/viewthread/2314/
Rivescript doesn’t cut the trailing blanks after cleaning punctuation symbols and leading blanks give also problems;

for example, with :

  • do you love me
  • yes, i do !

if user enter :
do you love me ? (with a blank before ? ), this doesn’t match
do you love me? works well
do you love me? doesn’t match

I add this branch to add the trim once punctuation has been treated.
Everything comes back to : do you love me and is ok.

-> as this is my first Coffee script, my first github pull and my first rivescript test, be indulgent !

HTH

@pirelaurent
Copy link
Contributor Author

caution : third sentence had a leading blank not kept by the chat.:
.do you love me? (. for blank )

@@ -398,7 +398,8 @@ class Brain
else
# For everything else, strip all non-alphanumerics
msg = utils.stripNasties(msg, @utf8)

# cut leading and trailing blanks
msg = utils.trimWhitespace(msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In coffeescript, indentation levels are important. These lines should be indented to the same level as the return statement.

Also, String.prototype.trim() is already built into the language, so this line can be replaced with:

msg = msg.trim()

@pirelaurent
Copy link
Contributor Author

Hi Kirsle,
i try the following :
remove previous proposal by git revert ,
change only brain.coffee as suggested by yourself (previously i use tab , not series of whitespaces doing indentation problems)
commit locally
push on my clone
send this message

hope this is correct.
Hope this tiny change correct too in order to have answer to >do you love me ? (space ?)
Hope you accept too.

@@ -398,7 +398,9 @@ class Brain
else
# For everything else, strip all non-alphanumerics
msg = utils.stripNasties(msg, @utf8)


# cut leading and trailing blanks once punctuation dropped office
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this comment line too.

@pirelaurent
Copy link
Contributor Author

Done:.same thing: i must leave my editor to show special char as tab , i can't see by default.
thanks for tutorial.

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

Successfully merging this pull request may close these issues.

2 participants