Reputation: 159
I need to work with MaltParser 1.5 version for parsing russian sentences. So, when I'm trying to type in cmd next command:
java -jar malt.jar
I'm getting next exception:
C:\malt1.5>java -jar malt.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.maltparser.MaltConsoleEngine.<init>(MaltConsoleEngine.java:29)
at org.maltparser.Malt.main(Malt.java:17)
Caused by: java.util.regex.PatternSyntaxException: Unclosed character class near index 17
^.*malt[^\]*\.jar$
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.clazz(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at org.maltparser.core.helper.SystemInfo.<init>(SystemInfo.java:28)
at org.maltparser.core.helper.SystemInfo.<clinit>(SystemInfo.java:21)
... 2 more
I've tried to run this command whith JRE 1.5 and 1.8.45 - same result.
Upvotes: 0
Views: 50
Reputation: 8147
The problem appears to be the [^\]
part of the regex. The [
part starts a character class. Ordinarily ]
ends a character class, but it's quoted with \]
so you have written a character class that contains everything except the characters ]
, *
, .
, j
, a
, r
, $
, and is not terminated.
If the character class is supposed to contain everything except backslash, it should be [^\\]
rather than [^\]
. To write the regex as a Java string, you will need an additional level of quoting: "[^\\\\]"
. One level of quoting is for the regular expression and the other is for the string.
Upvotes: 1