- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个关于在 GATE 中使用 ANNIE 插件的 Gate API 的问题。我在 java 程序中使用了 GATE api,它适用于 50 多个文档。但是当我为超过 50 个文档运行它时,它给出了以下错误:
Exception in thread "main" gate.creole.ExecutionException: No sentences or tokens to process in document GATE Document_0003D
Please run a sentence splitter and tokeniser first!
at gate.creole.POSTagger.execute(POSTagger.java:257)
at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291)
at gate.creole.ConditionalSerialController.runComponent(ConditionalSerialController.java:163)
at gate.creole.SerialController.executeImpl(SerialController.java:157)
at gate.creole.ConditionalSerialAnalyserController.executeImpl(ConditionalSerialAnalyserController.java:244)
at gate.creole.ConditionalSerialAnalyserController.execute(ConditionalSerialAnalyserController.java:139)
我尝试分别加载每个组件但它仍然给出相同的错误。我还尝试在处理过程中每 10 个文档后清理语料库,但仍然存在错误
代码是:
public class MyGate {
private CorpusController annieController;
/**
* Initialise the ANNIE system. This creates a "corpus pipeline"
* application that can be used to run sets of documents through
* the extraction system.
*/
public void initAnnie() throws GateException, IOException {
Out.prln("Initialising ANNIE...");
// load the ANNIE application from the saved state in plugins/ANNIE
File pluginsHome = Gate.getPluginsHome();
File anniePlugin = new File(pluginsHome, "ANNIE");
File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
annieController =
(CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
Out.prln("...ANNIE loaded");
} // initAnnie()
public void cleanUp(){
Corpus corp= annieController.getCorpus();
if(!corp.isEmpty()){
for(int i=0;i<corp.size();i++){
Document doc1 = (Document)corp.remove(i);
corp.unloadDocument(doc1);
Factory.deleteResource(corp);
Factory.deleteResource(doc1);
}
}
}
/** Tell ANNIE's controller about the corpus you want to run on */
public void setCorpus(Corpus corpus) {
annieController.setCorpus(corpus);
} // setCorpus
/** Run ANNIE */
public void execute() throws GateException {
Out.prln("Running ANNIE...");
annieController.execute();
Out.prln("...ANNIE complete");
} // execute()
//////-------------------------------MAIN--------------------------------------///////
public static void main(String args[]) throws GateException, IOException {
ArrayList<CreateHashMap> train_data_list = new ArrayList<CreateHashMap>();
String workingDir = System.getProperty("user.dir");
System.out.println("Current working directory : " + workingDir);
String trainpath=workingDir+"/input/test.json/test.json";
/*********************************************/
try {
// read the json file
FileReader reader = new FileReader(trainpath);
JSONParser jsonParser = new JSONParser();
JSONArray a = (JSONArray) jsonParser.parse(new FileReader(trainpath));
int g=0;
for (Object o : a)
{
if(g<=100){
CreateHashMap new_hash_item =new CreateHashMap();
JSONObject person = (JSONObject) o;
String rid = (String) person.get("request_id");
System.out.println(rid);
double date=(Double) person.get("times_request");
java.util.Date time=new java.util.Date((long)date*1000);
int day=time.getDate();
new_hash_item.createList(rid,day);
train_data_list.add(new_hash_item);
}
g++;}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ParseException ex) {
ex.printStackTrace();
} catch (NullPointerException ex) {
ex.printStackTrace();
}
/****************************************/
// initialise the GATE library
Out.prln("Initialising GATE...");
Gate.setGateHome(new File("C:/Program Files/GATE_Developer_8.0"));
Gate.init();
Out.prln("...GATE initialised");
// initialise ANNIE (this may take several minutes)
StandAloneAnnie annie = new StandAloneAnnie();
annie.initAnnie();
// create a GATE corpus and add a document for each command-line
// argument
Corpus corpus = Factory.newCorpus("StandAloneAnnie corpus");
String pathdoc=workingDir+"/input/test.json/";
SentenceSplitter sp= new SentenceSplitter();
int countdoc=0;
for(int i = 0; i < train_data_list.size()/*args.length*/; i++) {
Out.prln("here we go.............");
FeatureMap params = Factory.newFeatureMap();
String text=train_data_list.get(i).get_Request_text();
params.put(gate.Document.DOCUMENT_STRING_CONTENT_PARAMETER_NAME, text);
Document doc=(gate.Document)Factory.createResource("gate.corpora.DocumentImpl",params);
params.put("preserveOriginalContent", new Boolean(true));
params.put("collectRepositioningInfo", new Boolean(true));
corpus.add(doc);
countdoc++;
annie.setCorpus(corpus);
annie.execute();
if(countdoc==10)
{
corpus.cleanup();
System.out.println("...............cleanup....................");
}
} // for each of args
} // main
} // class MyGate
我在行中遇到错误:
annie.execute();
请帮助我。我无法弄清楚其中的问题。
最佳答案
通常这意味着“字符串文本”根本没有任何标记。只能有特殊字符或空格。打印出处理文件(或文件名)并验证它确实有一些合理的内容。
关于java - 安妮门,错误 : No sentences or tokens to process in document run sentence splitter and tokenizer first,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25341573/
因此,我将在数据库中存储数百万个句子,每个句子都有一个作者。我需要能够有效地搜索句子并返回作者。现在,我希望能够拼错一个词或忘记这句话中的一两个词,并且应用程序仍然能够匹配(模糊式)。谁能指出我正确的
我知道有 Edit > Change Case菜单。但是对于句子大小写没有选择。 我如何实现这一目标?正则表达式可以做到这一点吗? 最佳答案 你可以用这个正则表达式 : 查找 (^|\.\s|…\s)
我是 Ruby 新手。这是一个使用任何语言的编程面试问题。我正在尝试用 Ruby 来做。 编写一个程序来输入给定的句子。用单词的第一个字母/#ofcharactersbetween1st&laSTLe
我有一个关于在 GATE 中使用 ANNIE 插件的 Gate API 的问题。我在 java 程序中使用了 GATE api,它适用于 50 多个文档。但是当我为超过 50 个文档运行它时,它给出了
我有一个程序要求输入一个句子,然后要求输入一个词,并告诉你那个词的位置: sentence = input("enter sentence: ").lower() askedword = input(
题目地址:https://leetcode-cn.com/problems/sentence-similarity/ 题目描述 Given two sentences words1, words2
用例 准备一个正则表达式,可以匹配'sell|sold|selling'之后的1个或2个词,并匹配变量“product” 示例 Sentence - "John wants to sell 200$
我正在尝试对一列句子执行 StringIndexer 操作,即将单词列表转换为整数列表。 例如: 输入数据集: (1, ["I", "like", "Spark"]) (2, ["I", "h
背景 希望在 JasperServer 中自动创建域。域是用于创建临时报告的数据“ View ”。列的名称必须以人类可读的方式呈现给用户。 问题 从理论上讲,组织可能希望将超过 2,000 条数据包含
我正在为我的 Sentence Splitter 应用程序寻找一个测试文件,我希望该文件能够涵盖尽可能多的案例。 谢谢! 最佳答案 阅读 Lingua::Sentence 的文档.它命名了它使用的语料
我正在尝试创建一个程序,从电视直播网站获取 html,然后使用 split 函数将所有 html 数据拆分为 channel 名称和表中当前正在播放的节目,例如如:BBC 1 -“节目名称”。我只需要
这个问题在这里已经有了答案: Combining two sed commands (2 个答案) 关闭 1 年前。 我做了这个脚本: xrandr | grep '*' | sed 's/\S*\
如何使用 GO 编程语言找到给定句子的首字母缩写词。例如,“你好,世界!”变成“HW”。到目前为止,我已经尝试拆分句子: package main import ( "bufio" "
工厂定义: public function definition() { return [ 'user_id' => function() { retu
我在 HPC 上工作,工作节点上没有互联网访问权限,训练后保存 SetFit 训练器的唯一选择是将其推送到 HuggingFace hub。如何将其保存到本地磁盘? https://github.co
当我对以下文件运行 parser.y 时,出现以下错误: myanalyzer.y: warning: 14 nonterminals useless in grammar myanalyzer.y:
我在 HPC 上工作,工作节点上没有互联网访问权限,训练后保存 SetFit 训练器的唯一选择是将其推送到 HuggingFace hub。如何将其保存到本地磁盘? https://github.co
所以我刚刚在 Shinyapps 上部署了我的电影推荐,但我仍然想改变一件事。请看下面的图片。 因为我不想把“你可能也喜欢这个”放在另一个框中,我真的不知道如何在 html/css 格式中调整它。对我
我用 python 创建了一个程序,它基本上告诉用户输入一个单词,并告诉他们它是否是回文。 我的程序: def palindrome(word): return word == word[::
我需要删除第一个字符(不是空格)之前的所有空格,并删除最后一个字符(不是空格)之后的所有空格。 看起来像这样: ' a boat has an anchor
我是一名优秀的程序员,十分优秀!