为什么在多线程中使用mallet时会随机抛出异常?

……
CsvIterator reader = new CsvIterator(trizBayes.stringToBuffer(outdata.globalId + "\t1\t" + tmpString, "(\w+)\t(\w+)\t(.*)", 3, 2, 1);
Iterator instances = MalletClassifier.getInstancePipe().newIteratorFrom(reader);
while (instances.hasNext()){
Instance ins = instances.next();此处随机抛出异常,异常信息内容如下:

Exception in thread "Processing1" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1904)
at java.lang.String.subSequence(String.java:1946)
at java.util.regex.Matcher.getSubSequence(Matcher.java:1245)
at java.util.regex.Matcher.group(Matcher.java:490)
at java.util.regex.Matcher.group(Matcher.java:445)
at cc.mallet.util.CharSequenceLexer.updateMatchText(CharSequenceLexer.java:126)
at cc.mallet.util.CharSequenceLexer.hasNext(CharSequenceLexer.java:143)
at cc.mallet.pipe.CharSequence2TokenSequence.pipe(CharSequence2TokenSequence.java:66)
at cc.mallet.pipe.Pipe$SimplePipeInstanceIterator.next(Pipe.java:295)
at cc.mallet.pipe.Pipe$SimplePipeInstanceIterator.next(Pipe.java:1)
……
at cc.mallet.pipe.Pipe$SimplePipeInstanceIterator.next(Pipe.java:295)
at cc.mallet.pipe.Pipe$SimplePipeInstanceIterator.next(Pipe.java:1)
at com.incoshare.infoext.infoext.InformationExtraction(infoext.java:1098)
at com.incoshare.infoext.ProcessData$ProcessThread.run(ProcessData.java:281)
at java.lang.Thread.run(Thread.java:745)

1个回答

reader = new CsvIterator(trizBayes.stringToBuffer(outdata.globalId + "\t1\t" + tmpString, "(\w+)\t(\w+)\t(.*)", 3, 2, 1);
Iterator instances = MalletClassifier.getInstancePipe().newIteratorFrom(reader);
while (instances.hasNext()){
Instance ins = instances.next();此处随机抛出异常,异常信息内容如下:
Exception in thread "Processing1" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1904)
at java.lang.String.subSequence(String.java:1946)
at java.util.regex.Matcher.getSubSequence(Matcher.java:1245)
at java.util.regex.Matcher.group(Matcher.java:490)
at java.util.regex.Matcher.group(Matcher.java:445)
at cc.mallet.util.CharSequenceLexer.updateMatchText(CharSequenceLexer.java:126)
at cc.mallet.util.CharSequenceLexer.hasNext(CharSequenceLexer.java:143)
at cc.mallet.pipe.CharSequence2TokenSequence.pipe(CharSequence2TokenSequence.java:66)
at cc.mallet.pipe.Pipe$SimplePipeInstanceIterator.ne

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐