I have an Optaplanner drools file, and when I run the code below:
// ############################################################################
// Hard constraints
// ############################################################################
rule "DevCanOnlyDoOneTask"
when
$T1:Task(assignedDev==$D)
$T2:Task(assignedDev==$D)
(($T2.getAllottedStartTime()<=$T1.getAllottedStartTime())&&($T1.getAllottedStartTime()<$T2.getAllottedStartTime()+$T2.getDuration()))||(($T1.getAllottedStartTime()<=$T2.getAllottedStartTime())&&($T2.getAllottedStartTime()<$T1.getAllottedStartTime()+$T1.getDuration())) //line 21
then
scoreHolder.addHardConstraintMatch(kcontext,-1000);
end
// ############################################################################
// Soft constraints
// ############################################################################
rule "MaximiseEarliestFinishTime"
when
$TA: TaskAssignment($EFT: getEFT())
then
scoreHolder.addSoftConstraintMatch(kcontext,+$TA.getEFT());
I get the following error message (note I have commented on where the relevant are in the code above):
08:08:41.613 [main] ERROR o.d.c.k.b.impl.AbstractKieModule - Unable to build KieBaseModel:defaultKieBase
[21,36]: [ERR 102] Line 21:36 mismatched input '<=' in rule "DevCanOnlyDoOneTask"
[36,66]: [ERR 102] Line 36:66 mismatched input '<eof>' in rule "MaximiseEarliestFinishTime"
[0,0]: Parser returned a null Package
I assume there is something fundamentally wrong with the syntax I am using, but I am finding it difficult to pin down exactly what.
Thanks guys
Line 36:66 mismatched input '<eof>' in rule "MaximiseEarliestFinishTime"
All rules must end with the keyword end.
As for line 21, either put an eval around it (see drools docs for more info) or better yet, do those restrictions as part of $T2:Task. Also, the $D in $T1:Task doesn't exist yet, so you probably want to define it (bind it) instead of == compare it.
Related
When I run a file which is begin with #!/usr/bin/perl -w, I get a error:
syntax error at line 153, near "=~ ?"
I try to add "#!/bin/bash", this error is not append, but I get another
error:
"line 34: syntax error near unexpected token `('"
line 153 in my file:
($output_volume =~ ?^([\S]+).mnc?) && ($base_name = $1) ||
die "sharpen_volume failed: output volume does not appear to be"
." a minc volume.\n";
line34 in my file:
use MNI::Startup qw(nocputimes);
$output_volume =~ ?^([\S]+).mnc?
This used to be valid perl and thus might appear in old code and instructional material.
From perlop:
In the past, the leading m in m?PATTERN? was optional, but omitting it would produce a deprecation warning. As of v5.22.0, omitting it produces a syntax error. If you encounter this construct in older code, you can just add m.
That is Perl code so the first error message is meaningful.
With delimiters other than // in the match operator you must have the explicit m for it, so
$output_volume =~ m?^([\S]+).mnc?
It is only with // delimiters that the m may be omitted; from Regex Quote-Like Operators (perlop)
If "/" is the delimiter then the initial m is optional.
See perlretut for a tutorial introduction to regex and perlre for reference.
Also note that the particular delimiters of ? trigger specific regex behavior in a special case. This is discussed by the end of the documentation section in perlop linked above.
You already have two answers that explain the problem.
? ... ? is no longer valid syntax for a match operator. You need m? ... ? instead.
Until Perl 5.22, your syntax generated a warning. Now it's a fatal error (which is what you are seeing). So I assume you're now running this on a more recent version of Perl.
There are, however, a few other points it is probably worth making.
You say you tried to investigate this by changing the first line of your file from #!/usr/bin/perl -w to #!/bin/bash. I'm not sure how you think this was going to help. This line defines the program that is used to run your code. As you have Perl code, you need to run it with Perl. Trying to run it with bash is very unlikely to be useful.
The m? ... ? (or, formerly, ? ... ?) syntax triggers an obscure and specialised behaviour. It seems to me that this behaviour isn't required in your case, so you can probably change it to the more usual / ... /.
Your regex contains an unescaped dot character. Given that you seem to be extracting the basename from a filename that has an extension, it seems likely that this should be escaped (using \.) so that it matches an actual dot (rather than any character).
If you are using this code to extract a file's basename, then using a regex probably isn't the best approach. Perhaps take a look at File::Basename instead.
I used SpreadsheetCompiler to extract the drl for my Decision Table. Here is the relevant bit
global Integer netincome;
// rule values at C14, header at C8
rule "Net Income_14"
salience 65522
when
user:CSUserBundle(user.grossHouseholdIncome >= 0, user.grossHouseholdIncome < 1150000, user.grossHouseholdIncome >= 15700*52, user.grossHouseholdIncome < 86600*52)
then
netincome = eval(user.grossHouseholdIncome - 0 - (user.grossHouseholdIncome – 816400) * 0.12 - 0)
end
My error is:
E 14:35:30:235 : main : org.drools.compiler.kie.builder.impl.AbstractKieModule : Unable to build KieBaseModel:defaultKieBase
[11,78]: [ERR 101] Line 11:78 no viable alternative at input ''
Unfortunately the column number 78, is in the error is the middle of the 2nd user.grossHouseholdIncome in the 'then' statement. I searched thru the documentation but could not find anything about using a variable name twice in the text. I tried adding the 'eval' in response to De Smet's suggestion for the same error. Any ideas?
What I did was to copy-paste the rule into a decent text editor and then try to search for all occurrences of special ASCII characters like quote (") or hyphen (-) or anything else the marvellous office programs are apt to convert into some Unicode glyph that sure is looking good but rejected by compilers. Also, do not trust spaces. Frequently they are optical illusions created by a program due to some TAB character. I have replaced the spaces by a single underscore
to represent a TAB. And now the 78 aligns exactly with the evil character.
_netincome = eval(user.grossHouseholdIncome - 0 - (user.grossHouseholdIncome – 816400) * 0.12 - 0)
....5...10....5...20....5...30....5...40....5...50....5...60....5...70....5...80
I'm trying to run the word_align.pl script provided by CMUSphinx. I write the command as follows:
perl word_align.pl actualtext.txt batchOutputText.txt
But the terminal gives me the following errors:
Use of uninitialized value $ref_uttid in hash element at word_align.pl line 60, line 1.
Use of uninitialized value $ref_uttid in concatenation (.) or string at word_align.pl line 61, line 1.
UttID is not ignored but it could not found in any entries of the hypothesis file on line3 1 UTTID
I am not quite familiar with Perl and I can't figure out what is the problem here though I followed the instructions provided by CMUSphinx to run that script
You can find the script here
Edit: here is the reference's file link
The answer is in this error message
UttID is not ignored but it could not found in any entries of the hypothesis file on line3 1 UTTID
The reference file that you are passing is malformed, specifically its first line isn't formatted as it should be
More precisely, each line of the reference file requires a UTT ID—a unique string in parentheses like (output00000). It must be unique because it is used as a hash key. A simple digit like (1) won't work as it will be mistaken for an alternative pronunciation
The first line of your file must be different from that. You suggest
<s> text </s> (file12)
which actually works fine—I have tested it—and $ref_uttid comes out as FILE12. If you tell us what is actually in your file then I am sure we could help you better
I have a Matlab file with multiple functions defined. When calling the file, I get the following error: "Error: File: kmeans.m Line: 20 Column: 1\n Function definition is misplaced or improperly nested."
How can I get rid of the error?
Make sure every function has a matching end.
I am trying to configure a Decision table to evaluate certain condition.
Below is the snippet from my decision table.
While doing so I am getting following error
[ERR 102] Line 8:143 mismatched input '==' in rule "Rules_11".
I am not sure about what I am doing wrong.
The problem is in line 9
The condition cannot have a variable with a comparison floating there.
$selectedAttribute.code in line 9 doesn't mean anything, that's not a Conditional element.