Java GATE 8.0编译器问题

Java GATE 8.0编译器问题,java,eclipse,groovy,compiler-warnings,gate,Java,Eclipse,Groovy,Compiler Warnings,Gate,我一直在尝试用Groovy(使用Eclipse)构建一个简单的应用程序来调用GATE,并遇到了令人困惑的编译器错误——几年前,我在GATE用户身上看到过类似的问题,但没有一个解决方案为我修复了错误 守则: import gate.* import gate.creole.* import gate.creole.SerialAnalyserController import gate.util.persistence.PersistenceManager class AnnieExtracti

我一直在尝试用Groovy(使用Eclipse)构建一个简单的应用程序来调用GATE,并遇到了令人困惑的编译器错误——几年前,我在GATE用户身上看到过类似的问题,但没有一个解决方案为我修复了错误

守则:

import gate.*
import gate.creole.*
import gate.creole.SerialAnalyserController
import gate.util.persistence.PersistenceManager

class AnnieExtraction {

    static main(args) {
        println "--Initializing GATE--"
        Gate.init()
        Gate.getCreoleRegister().registerDirectories(new File("C:/apps/GATE_Developer_8.0/plugins/ANNIE").toURI().toURL())
        println "--GATE initialized--"

        SerialAnalyserController pipeline = (SerialAnalyserController) Factory.createResource("gate.creole.SerialAnalyserController")
        println "--Initializing PR--"
        ProcessingResource token = (ProcessingResource) Factory.createResource("gate.creole.tokeniser.DefaultTokeniser", Factory.newFeatureMap())


    }

}
然后返回错误:

Error: The type postprocessCannotActionClass4 must implement the inherited abstract method RhsAction.doit(Document, Map, AnnotationSet, AnnotationSet, Ontology) at line 10 in japeactionclasses.postprocessCannotActionClass4
Error: The type Map is not generic; it cannot be parameterized with arguments <String, AnnotationSet> at line 18 in japeactionclasses.postprocessCannotActionClass4
Error: Syntax error, parameterized types are only available if source level is 5.0 at line 18 in japeactionclasses.postprocessCannotActionClass4
Error: Type mismatch: cannot convert from Object to Annotation at line 24 in japeactionclasses.postprocessCannotActionClass4
Error: The operator + is undefined for the argument type(s) Long, long at line 31 in japeactionclasses.postprocessCannotActionClass4

The offending input was:

 1  // postprocessCannotActionClass4
 2  package japeactionclasses;
 3  import gate.*;
 4  import java.io.*;
 5  import java.util.*;
 6  import gate.util.*;
 7  import gate.jape.*;
 8  import gate.creole.ontology.*;
 9 
10  public class postprocessCannotActionClass4
11  implements java.io.Serializable, gate.jape.RhsAction {
12    private gate.jape.ActionContext ctx;
13    public java.lang.String ruleName() { return "Cannot"; }
14    public java.lang.String phaseName() { return "postprocess"; }
15    public void setActionContext(gate.jape.ActionContext ac) { ctx = ac; }
16    public gate.jape.ActionContext getActionContext() { return ctx; }
17    public void doit(gate.Document doc,
18                     java.util.Map<java.lang.String, gate.AnnotationSet> bindings,
19                     gate.AnnotationSet inputAS, gate.AnnotationSet outputAS,
20                     gate.creole.ontology.Ontology ontology) throws gate.jape.JapeException {
21      gate.AnnotationSet cannotAnnots = bindings.get("cannot");
22      if(cannotAnnots != null && cannotAnnots.size() != 0) {
23 
24    Annotation cannot = cannotAnnots.iterator().next();
25    String cannotStr = cannot.getFeatures().get("string").toString();
26    String canStr = cannotStr.substring(0,3);
27    String notStr = cannotStr.substring(3,6);
28 
29    Long start = cannot.getStartNode().getOffset();
30    Long end   = cannot.getEndNode().getOffset();
31    Long middle = start + 3L;
32 
33    /* Copy orth, &c., from the original Token;
34     * overwrite the others appropriately.  */
35    FeatureMap canFM = Factory.newFeatureMap();
36    FeatureMap notFM = Factory.newFeatureMap();
37    canFM.putAll(cannot.getFeatures());
38    notFM.putAll(cannot.getFeatures());
39 
40    canFM.put("string", canStr);
41    notFM.put("string", notStr);
42    canFM.put("length", Integer.toString(3));
43    notFM.put("length", Integer.toString(3));
44 
45    try {
46      outputAS.add(start, middle, "Token", canFM);
47      outputAS.add(middle, end, "Token", notFM);
48    }
49    catch (InvalidOffsetException e) {
50      /* This should never happen */
51      e.printStackTrace();
52    }
53 
54    outputAS.remove(cannot);
55 
56      }
57    }
58  }
错误:类型postprocessCannotActionClass4必须在JapeActionClasss.postprocessCannotActionClass4的第10行实现继承的抽象方法RhsAction.doit(文档、地图、注释集、注释集、本体)
错误:类型映射不是泛型的;无法使用japeactionclasses.postprocessCannotActionClass4中第18行的参数对其进行参数化
错误:语法错误,参数化类型仅在japeactionclasses.postprocessCannotActionClass4第18行的源代码级别为5.0时可用
错误:类型不匹配:无法在japeactionclasses.postprocessCannotActionClass4的第24行从对象转换为注释
错误:未为japeactionclasses.postprocessCannotActionClass4中第31行的参数类型Long定义运算符+
令人不快的输入是:
1//后处理CannotActionClass4
2个日本包类;
3.进口门*;
4导入java.io.*;
5导入java.util.*;
6进口门。util.*;
7进口门。日本。*;
8进口门。克里奥尔语。本体。*;
9
10公共类后处理CannotActionClass4
11实现java.io.Serializable、gate.jape.RhsAction{
12 private gate.jape.ActionContext ctx;
13 public java.lang.String ruleName(){return“Cannot”;}
14 public java.lang.String phaseName(){返回“后处理”;}
15 public void setActionContext(gate.jape.ActionContext ac){ctx=ac;}
16 public gate.jape.ActionContext getActionContext(){return ctx;}
17公共作废doit(gate.Document文件、,
18 java.util.Map绑定,
19 gate.AnnotationSet输入,gate.AnnotationSet输出,
20 gate.creole.ontology.ontology本体)抛出gate.jape.JapeException{
21 gate.AnnotationSet cannotAnnots=bindings.get(“cannot”);
22如果(cannotAnnots!=null&&cannotAnnots.size()!=0){
23
24 Annotation不能=cannotAnnots.iterator().next();
25字符串cannotStr=cannot.getFeatures().get(“字符串”).toString();
26字符串canStr=cannotStr.子字符串(0,3);
27字符串notStr=cannotStr.子字符串(3,6);
28
29 Long start=cannot.getStartNode().getOffset();
30 Long-end=无法.getEndNode().getOffset();
31中长=启动+3L;
32
33/*从原始代币复制orth,&c;
34*适当覆盖其他内容*/
35 FeatureMap canFM=Factory.newFeatureMap();
36 FeatureMap notFM=Factory.newFeatureMap();
37 canFM.putAll(cannot.getFeatures());
38 notFM.putAll(cannot.getFeatures());
39
40 canFM.put(“字符串”,canStr);
41 notFM.put(“字符串”,notStr);
42 canFM.put(“长度”,Integer.toString(3));
43 notFM.put(“长度”,Integer.toString(3));
44
45试{
46输出。添加(开始,中间,“标记”,canFM);
47输出。添加(中间,结尾,“标记”,非FM);
48    }
49捕获(无效偏移异常e){
50/*这永远不会发生*/
51 e.printStackTrace();
52    }
53
54输出。移除(不能);
55
56      }
57    }
58  }
我尝试了一系列不同的编译器、JDK版本,甚至尝试了Gate7.1而不是8.0

目前正在使用Java版本1.7,正如我读到的jasper-compiler-jdt.jar不能很好地与Java 1.8配合使用。编译器版本也是1.7

我知道问题与编译器jar类型有关,但它们似乎都在GATE本身和Eclipse之间匹配。gategui指向正确的JDK。仅使用jasper编译器即可生成: NoClassDefFoundError:gate/util/compilers/eclipse/jdt/internal/compiler/env/INameEnvironment

因此,我必须包含一个门编译器jdt JAR,它会产生上面的第一个错误

据我所知,所有其余的jar文件都与GATE 8.0正确关联。有人能告诉我错误可能在哪里,或者使用哪套编译器是正确的吗


非常感谢

正如你和伊恩所说,我使用的是
GATE 8.1
,方法是在POM.XML中设置“GATE compiler jdt”的编译器版本,与
GATE\u HOME/lib中的版本类似

'C:\Program Files\GATE_Developer_8.2\lib'

要使用的正确的gate编译器jdt jar将始终是您从中获得gate.jar的gate发行版的一部分。或者,如果您从Maven central中提取GATE,那么正确的编译器jar将作为一个依赖项存在。Ian-通过将编译器从GATE_HOME/lib目录显式添加到类路径并删除其他文件(即使是整个lib目录中已经添加的文件)来实现。我相信我现在理解了这个问题。非常感谢。