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

force lowercase for triggers #143

Closed
dcsan opened this issue Jul 15, 2016 · 2 comments · Fixed by #154
Closed

force lowercase for triggers #143

dcsan opened this issue Jul 15, 2016 · 2 comments · Fixed by #154

Comments

@dcsan
Copy link
Contributor

dcsan commented Jul 15, 2016

Due to writers not being able to get used to using lowercase for words like "I"
and triggers failing unless it's all lowercase,
add a startup option like

forcecase: true

similar to the utf8: true flag.


@dcsan: not sure where you last talked about this, but a solution to your problem with authors putting a capital "I" in triggers could be to just pre-process the scripts using sed or a perl one-liner (I'm more familiar with the latter) so here's an example:

% cat test.rive
+ do you know who I am
- You are <get name>.

+ i am called *
- <set name=<formal>>Nice to meet you, <get name>.

> topic test
    + another I trigger
    - Indented.
< topic
% perl -pi -e 's/^(\s*)\+(.+)$/\1+\L\2\E/g' test.rive
% cat test.rive
+ do you know who i am
- You are <get name>.

+ i am called *
- <set name=<formal>>Nice to meet you, <get name>.

> topic test
    + another i trigger
    - Indented.
< topic

[4:28]
the relevant bit being: perl -pi -e 's/^(\s*)\+(.+)$/\1+\L\2\E/g' test.rive

[4:29]
it matches zero+ spaces before a "+" and all the remaining text, and outputs the same number of space, the "+", and the lowercased version of the remainder

dcsan [4:53 PM]
thanks. i've mentioned it a few times, most recently in a ticket. it's a headache i deal with every day as our writers can never get used to lowercase "I" or non-capitals. they are writers after all.

[4:53]
i guess we could do a regex somewhere ideally inside Rivescript itself. (edited)

[4:54]
maybe if there was some way to pass that as an option like the utf8: true

kirsle [4:54 PM]
it'd be a pretty short fix (maybe 3 lines of code) to make it an option like that

dcsan [4:54 PM]
i can't recall why it is rive requires this, yet doesn't enforce it. something about utf8 characters?

[4:55]
if you can give me a pointer i can look at a PR

new messages
kirsle [4:55 PM]
something like that. also some of its AIML inspiration showing through, but in AIML the patterns are mandatory uppercase instead of lowercase

[4:55]
so you'd probably change the constructor in rivescript.coffee to accept/store the option, possibly pass it as an option to parser.coffee too, and then in parser.coffee when it handles the + command it can check that option and run it through a .toLowerCase()

related to:
#140

@josephrexme
Copy link

I did notice the forceCase option but I guess it's affecting something else. All my inputs are forced to lowerCase by default according to the line showed in #245 and I do not want that because one of the arguments for my JS repl macro is Math.sin() and the likes which always get turned into math.sin() that gives an error

@kirsle
Copy link
Member

kirsle commented Sep 13, 2017

Yeah forceCase affects whether triggers in RiveScript source are allowed to have uppercase letters or not.

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

Successfully merging a pull request may close this issue.

3 participants