本文整理汇总了Java中opennlp.model.Event类的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Event类属于opennlp.model包,在下文中一共展示了Event类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readInXmiFiles
import opennlp.model.Event; //导入依赖的package包/类
/**
* @param filePath
* the xmi file or directory path of the dataset
* @return return the instances of the dataset, represented in
* <code>Event</code>s
*/
protected final EventStream readInXmiFiles(String filePath)
throws ConfigurationException {
List<Event> eventList = new ArrayList<Event>();
File dir = new File(filePath);
if (dir.isFile()) {
eventList.add(readInXmiFile(dir.getAbsolutePath()));
} else if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
// ignore all the non-xmi files
if (!file.getName().endsWith(".xmi")) {
continue;
}
// add the instance to the dataset
eventList.add(readInXmiFile(file.getAbsolutePath()));
}
}
return new ListEventStream(eventList);
}
示例2: next
import opennlp.model.Event; //导入依赖的package包/类
public Event next() {
int split = line.indexOf(' ');
String outcome = line.substring(0, split);
String question = line.substring(split + 1);
Parse query = ParserTool.parseLine(question, parser, 1)[0];
return (new Event(outcome, atcg.getContext(query)));
}
示例3: toLine
import opennlp.model.Event; //导入依赖的package包/类
/**
* Generates a string representing the specified event.
*
* @param event The event for which a string representation is needed.
* @return A string representing the specified event.
*/
public static String toLine(Event event) {
StringBuffer sb = new StringBuffer();
sb.append(event.getOutcome());
String[] context = event.getContext();
for (int ci = 0, cl = context.length; ci < cl; ci++) {
sb.append(" " + context[ci]);
}
sb.append(System.getProperty("line.separator"));
return sb.toString();
}
示例4: readInXmiFile
import opennlp.model.Event; //导入依赖的package包/类
/**
* @param filePath
* the single xmi file path of the dataset
* @return return the instance of that file, represented in
* <code>Event</code>
*/
protected final Event readInXmiFile(String filePath)
throws ConfigurationException {
try {
File xmiFile = new File(filePath);
return casToEvent(PlatformCASProber.probeXmi(xmiFile, System.out));
} catch (LAPException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例5: casToEvent
import opennlp.model.Event; //导入依赖的package包/类
/**
* @param cas
* the <code>JCas</code> object
* @return return the instance of the input, represented in
* <code>Event</code>
*/
protected final Event casToEvent(JCas cas) throws ConfigurationException {
String goldAnswer = getGoldLabel(cas);
if (null == goldAnswer) {
goldAnswer = DecisionLabel.Abstain.toString();
}
try {
String[] contexts = constructContext(cas);
float[] values = RealValueFileEventStream.parseContexts(contexts);
return new Event(goldAnswer, contexts, values);
} catch (ScoringComponentException e) {
throw new ConfigurationException(e.getMessage());
}
}