grammarian
Programmer
Hi there,
I'm a C/C++ and VB programmer and I have a program in mind that I would like to come true with the help of Perl. I want to ask you guys if what I want to do is doable.
I want to make a grammar checker.
So I was reading some snippets in Perl and I wanted to know if this was possible. I thought I'd try to write something in Perl that would correct English subjunctives, i.e. wherever it found "If it was" or "if he was" or "if his brother was", it would make it "If it were" and "if he were" and "if his brother were". So that's what I've written:
if ($Text =~ m/(If|if)..*(were){0,0}(was)/g) {
or
if ($Text =~ m/[(If)(if)]..*(were){0,0}(was)/g) {
(from what I understand, this means: find every "If" or "if" that is not followed by "were" before being followed by "was" and that is at least one character apart from the "If" or "if")
Is that right?
And then I don't know what to put inside the braces to make the substitution happen.
And then I would continue to turn grammar rules into Perl syntax. Do you think this is doable? Do you think there is any grammar rule that would be impossible or maybe too complicated to program in Perl?
Thanks.
I'm a C/C++ and VB programmer and I have a program in mind that I would like to come true with the help of Perl. I want to ask you guys if what I want to do is doable.
I want to make a grammar checker.
So I was reading some snippets in Perl and I wanted to know if this was possible. I thought I'd try to write something in Perl that would correct English subjunctives, i.e. wherever it found "If it was" or "if he was" or "if his brother was", it would make it "If it were" and "if he were" and "if his brother were". So that's what I've written:
if ($Text =~ m/(If|if)..*(were){0,0}(was)/g) {
or
if ($Text =~ m/[(If)(if)]..*(were){0,0}(was)/g) {
(from what I understand, this means: find every "If" or "if" that is not followed by "were" before being followed by "was" and that is at least one character apart from the "If" or "if")
Is that right?
And then I don't know what to put inside the braces to make the substitution happen.
And then I would continue to turn grammar rules into Perl syntax. Do you think this is doable? Do you think there is any grammar rule that would be impossible or maybe too complicated to program in Perl?
Thanks.