本文整理汇总了Java中ixa.kaflib.Term.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Term.getLength方法的具体用法?Java Term.getLength怎么用?Java Term.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ixa.kaflib.Term
的用法示例。
在下文中一共展示了Term.getLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpan
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static List<Term> getSpan(List<Term> terms, int start, int end) {
List<Term> ret = new ArrayList<>();
for (Term t : terms) {
int tStart = t.getOffset();
int tEnd = t.getOffset() + t.getLength();
if ((tEnd >= start && tEnd <= end) || (tStart >= start && tStart <= end)) {
ret.add(t);
// System.out.println(t);
// System.out.println(t.getOffset());
// System.out.println(t.getLength());
}
}
return ret;
}
示例2: main
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
final CommandLine cmd = CommandLine
.parser()
.withName("./ecb-extractor")
.withHeader("Extracts URI of events in the gold standard")
.withOption("n", "input-naf", "Input NAF folder", "FOLDER",
CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
.withOption("o", "output", "Output file", "FILE",
CommandLine.Type.FILE, true, false, true)
.withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);
File inputNaf = cmd.getOptionValue("input-naf", File.class);
File outputFile = cmd.getOptionValue("output", File.class);
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
if (!file.isFile()) {
continue;
}
if (file.getName().startsWith(".")) {
continue;
}
String path = file.getParentFile().toString();
Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));
LOGGER.debug(file.getAbsolutePath());
KAFDocument document = KAFDocument.createFromFile(file);
String uri = document.getPublic().uri;
for (Coref coref : document.getCorefs()) {
if (coref.getType() == null) {
continue;
}
if (!coref.getType().equals("event-gold")) {
continue;
}
Integer cluster = Integer.parseInt(coref.getCluster());
String idCluster = folder + "_" + cluster;
for (Span<Term> termSpan : coref.getSpans()) {
Term term = termSpan.getTargets().get(0);
String thisURI =
uri + "#char=" + term.getOffset() + "," + (term.getOffset() + term.getLength());
writer.append(thisURI).append("\n");
}
}
}
writer.close();
} catch (Exception e) {
CommandLine.fail(e);
}
}