当前位置: 首页>>代码示例>>Java>>正文


Java JCasUtil.selectSingle方法代码示例

本文整理汇总了Java中org.apache.uima.fit.util.JCasUtil.selectSingle方法的典型用法代码示例。如果您正苦于以下问题:Java JCasUtil.selectSingle方法的具体用法?Java JCasUtil.selectSingle怎么用?Java JCasUtil.selectSingle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.fit.util.JCasUtil的用法示例。


在下文中一共展示了JCasUtil.selectSingle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReadDlinaMetadata

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
public void testReadDlinaMetadata() throws Exception {
	Iterator<JCas> iter = SimplePipeline.iteratePipeline(
			CollectionReaderFactory.createReaderDescription(XmiReader.class, XmiReader.PARAM_SOURCE_LOCATION,
					"src/test/resources/ReadDlinaMetadata/xmi/*.xmi"),
			AnalysisEngineFactory.createEngineDescription(ReadDlinaMetadata.class,
					ReadDlinaMetadata.PARAM_DLINA_DIRECTORY, "src/test/resources/ReadDlinaMetadata/zwischenformat"))
			.iterator();
	JCas jcas;
	Drama d;
	jcas = iter.next();
	assertNotNull(jcas);
	d = JCasUtil.selectSingle(jcas, Drama.class);
	assertNotNull(d);

	assertEquals(1802, JCasUtil.selectSingle(jcas, DatePrint.class).getYear());
	assertEquals(0, JCasUtil.selectSingle(jcas, DatePremiere.class).getYear());
	assertEquals(0, JCasUtil.selectSingle(jcas, DateWritten.class).getYear());

	jcas = iter.next();
	assertNotNull(jcas);
	d = JCasUtil.selectSingle(jcas, Drama.class);
	assertNotNull(d);
	assertEquals(1801, JCasUtil.selectSingle(jcas, DatePrint.class).getYear());
	assertEquals(1801, JCasUtil.selectSingle(jcas, DatePremiere.class).getYear());
	assertEquals(1801, JCasUtil.selectSingle(jcas, DateWritten.class).getYear());
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:27,代码来源:TestReadDlinaMetadata.java

示例2: process

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	Drama drama = JCasUtil.selectSingle(jcas, Drama.class);

	Author author = new Author(jcas);
	author.addToIndexes();
	if (authorName != null)
		author.setName(authorName);
	if (authorPnd != null)
		author.setPnd(authorPnd);
	if (dramaId != null)
		drama.setDocumentId(dramaId);
	if (referenceDate > 0)
		DramaUtil.createFeatureStructure(jcas, DateReference.class).setYear(referenceDate);
	if (dramaTitle != null)
		drama.setDocumentTitle(dramaTitle);

	drama.setTranslation(translation);
	if (translation) {
		Translator translator;
		if (JCasUtil.exists(jcas, Translator.class)) {
			translator = JCasUtil.selectSingle(jcas, Translator.class);
		} else {
			translator = DramaUtil.createFeatureStructure(jcas, Translator.class);
		}
		if (translatorName != null)
			translator.setName(translatorName);
		if (translatorPnd != null)
			translator.setPnd(translatorPnd);
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:32,代码来源:SetDramaMetaData.java

示例3: process

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	Drama d = JCasUtil.selectSingle(jcas, Drama.class);
	Document doc = fileIndex.get(d.getDocumentId());
	if (doc == null)
		return;

	Elements dateElements = doc.getRootElement().getFirstChildElement("header", namespaceUri)
			.getChildElements("date", namespaceUri);
	for (int i = 0; i < dateElements.size(); i++) {
		Element dateElement = dateElements.get(i);
		if (dateElement.getAttributeValue("when") != null) {
			String whenAttVal = dateElement.getAttributeValue("when");
			Date date = null;
			if (dateElement.getAttributeValue("type").equals("print")) {
				date = DramaUtil.createFeatureStructure(jcas, DatePrint.class);
			} else if (dateElement.getAttributeValue("type").equals("written")) {
				date = DramaUtil.createFeatureStructure(jcas, DateWritten.class);
			} else if (dateElement.getAttributeValue("type").equals("premiere")) {
				date = DramaUtil.createFeatureStructure(jcas, DatePremiere.class);
			}
			if (date != null) {
				date.setYear(Integer.valueOf(whenAttVal));
				date.setSource("dlina");
			}
		}
	}
	return;

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:31,代码来源:ReadDlinaMetadata.java

示例4: process

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {

	// open file for this document
	DocumentMetaData meta = JCasUtil.selectSingle(jCas,
			DocumentMetaData.class);
	String baseUri = meta.getDocumentBaseUri();
	String docUri = meta.getDocumentUri();

	String relativeDocumentPath = docUri.substring(baseUri.length());
	relativeDocumentPath = FilenameUtils
			.removeExtension(relativeDocumentPath);

	try {
		PrintWriter w = new PrintWriter(new FileWriter(outputFile + "/"
				+ relativeDocumentPath + ".deps"));

		// iterate over sentences and write out dependency parses
		Iterator<Sentence> sentences = JCasUtil
				.select(jCas, Sentence.class).iterator();

		while (sentences.hasNext()) {

			Sentence sent = sentences.next();
			w.println(sent.getCoveredText());

			List<Dependency> sentDeps = JCasUtil.selectCovered(
					Dependency.class, sent);
			for (Dependency dep : sentDeps) {
				w.println(dep.getGovernor().getCoveredText() + " --"
						+ dep.getDependencyType() + "--> "
						+ dep.getDependent().getCoveredText());
			}

			w.println();
		}

		w.close();

	} catch (IOException e) {
		e.printStackTrace();
		throw new RuntimeException();
	}

}
 
开发者ID:annefried,项目名称:sitent,代码行数:46,代码来源:ParseWriterAnnotator.java

示例5: process

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	
	DocumentMetaData dm = JCasUtil.selectSingle(jcas, DocumentMetaData.class);
	System.out.println(dm.getDocumentId());

	// add LINGUISTIC INDICATOR features for verbs
	Iterator<ClassificationAnnotation> annots = JCasUtil.select(jcas, ClassificationAnnotation.class).iterator();

	while (annots.hasNext()) {

		ClassificationAnnotation annot = annots.next();

		if (annot.getTask() == null) {
			continue;
		}

		if (!annot.getTask().equals("VERB")) {
			continue;
		}

		// ClassificationAnnotation for verbs covers exactly one token (the
		// head)
		List<Token> tokens = JCasUtil.selectCovered(Token.class, annot);
		if (tokens.size() != 1) {
			// this should not happen
			System.err.println(tokens.size() + annot.getCoveredText());
			for (Token token: tokens) {
				System.out.println(token);
			}
			return;
			//throw new IllegalStateException();
		}
		Token verb = tokens.get(0);

		for (String indName : indNames) {
			Double val = 0.0;
			if (inds.containsKey(verb.getLemma().getValue())) {
				val = inds.get(verb.getLemma().getValue()).get(indName);
			}
			FeaturesUtil.addFeature(indName, val.toString(), jcas, annot);
		}

	}
}
 
开发者ID:annefried,项目名称:sitent,代码行数:46,代码来源:LinguisticIndicatorsAnnotator.java

示例6: getGraph

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
public static Graph<Figure, DefaultWeightedEdge> getGraph(JCas jcas, String viewName)
		throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
		InvocationTargetException, NoSuchMethodException, SecurityException, CASException {

	JCas graphView = jcas.getView(viewName);

	Map<Integer, Figure> figureMap = new HashMap<Integer, Figure>();
	for (Figure figure : JCasUtil.select(jcas, Figure.class)) {
		figureMap.put(figure.getBegin(), figure);
	}
	if (!JCasUtil.exists(graphView, GraphMetaData.class))
		return null;
	GraphMetaData gmd = JCasUtil.selectSingle(graphView, GraphMetaData.class);

	Class<?> cl = Class.forName(gmd.getGraphClassName());
	@SuppressWarnings("unchecked")
	Graph<Figure, DefaultWeightedEdge> graph = (Graph<Figure, DefaultWeightedEdge>) cl.getConstructor(Class.class)
			.newInstance(DefaultWeightedEdge.class);
	boolean weighted = false;
	if (graph instanceof WeightedGraph) {
		weighted = true;
	}

	// SimpleWeightedGraph<Figure, DefaultWeightedEdge> graph =
	// new SimpleWeightedGraph<Figure, DefaultWeightedEdge>(
	// DefaultWeightedEdge.class);
	Pattern pattern;
	if (weighted)
		pattern = Pattern.compile("(-?\\d+) (-?\\d+) (\\d+.\\d+)");
	else
		pattern = Pattern.compile("(-?\\d+) (-?\\d+)");
	for (String line : graphView.getDocumentText().split("\n")) {
		Matcher m = pattern.matcher(line);
		if (m.find()) {
			int sId = Integer.valueOf(m.group(1));
			int tId = Integer.valueOf(m.group(2));

			Figure sFigure = figureMap.get(sId);
			Figure tFigure = figureMap.get(tId);
			if (!graph.containsVertex(sFigure))
				graph.addVertex(sFigure);
			if (!graph.containsVertex(tFigure))
				graph.addVertex(tFigure);
			Object edge = graph.addEdge(sFigure, tFigure);
			if (weighted) {
				double w = Double.valueOf(m.group(3));
				if (edge != null)
					((WeightedGraph<Figure, DefaultWeightedEdge>) graph).setEdgeWeight((DefaultWeightedEdge) edge,
							w);
			}
		}
	}

	return graph;

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:57,代码来源:GraphImporter.java

示例7: getNext

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void getNext(JCas jcas, InputStream file, Drama drama) throws IOException, CollectionException {

	String str = IOUtils.toString(file);
	org.jsoup.nodes.Document doc = Jsoup.parseBodyFragment(str);
	Visitor vis = new Visitor(jcas);
	doc.traverse(vis);
	jcas = vis.getJCas();
	Map<String, HTMLAnnotation> annoMap = vis.getAnnotationMap();

	// identify front and main matter
	select2Annotation(jcas, doc, annoMap, "div.gutenb:eq(0)", FrontMatter.class, null);
	selectRange2Annotation(jcas, doc, annoMap, "div.gutenb:eq(1)", "div.gutenb:last-child", MainMatter.class);
	FrontMatter frontMatter = JCasUtil.selectSingle(jcas, FrontMatter.class);
	MainMatter mainMatter = JCasUtil.selectSingle(jcas, MainMatter.class);

	// identify simple annotations
	select2Annotation(jcas, doc, annoMap, "span.speaker", Speaker.class, mainMatter);
	select2Annotation(jcas, doc, annoMap, "span.speaker", Figure.class, frontMatter);
	select2Annotation(jcas, doc, annoMap, "span.regie", StageDirection.class, mainMatter);
	select2Annotation(jcas, doc, annoMap, "span.footnote", Footnote.class, mainMatter);
	select2Annotation(jcas, doc, annoMap, "h3 + p", DramatisPersonae.class, frontMatter);

	// find utterances
	select2Annotation(jcas, doc, annoMap, "p:has(span.speaker)", Utterance.class, mainMatter);

	// some utterances continue in the next paragraph
	// they are (in RuJ) marked with class leftmarg
	Elements elms = doc.select("p.leftmarg");
	for (Element elm : elms) {
		HTMLAnnotation hAnno = annoMap.get(elm.cssSelector());
		Utterance utterance = JCasUtil.selectPreceding(Utterance.class, hAnno, 1).get(0);
		utterance.setEnd(hAnno.getEnd());
	}

	annotateSpeech(jcas, mainMatter);

	// aggregating annotations
	// TODO: convert to range function
	int currentSceneBegin = -1;
	int currentActBegin = -1;
	for (HTMLAnnotation anno : JCasUtil.select(jcas, HTMLAnnotation.class)) {
		if (anno.getTag().equals("h2") && !anno.getCls().contains("author")) {
			AnnotationFactory.createAnnotation(jcas, anno.getBegin(), anno.getEnd(), SceneHeading.class);
			if (currentSceneBegin >= 0) {
				AnnotationFactory.createAnnotation(jcas, currentSceneBegin, anno.getBegin() - 1, Scene.class);
			}
			currentSceneBegin = anno.getBegin();
		}
		if (anno.getTag().equals("h1") && !anno.getCls().contains("title")) {
			AnnotationFactory.createAnnotation(jcas, anno.getBegin(), anno.getEnd(), ActHeading.class);
			if (currentActBegin >= 0) {
				AnnotationFactory.createAnnotation(jcas, currentActBegin, anno.getBegin() - 1, Act.class);
				if (currentSceneBegin >= 0) {
					AnnotationFactory.createAnnotation(jcas, currentSceneBegin, anno.getBegin() - 1, Scene.class);
					currentSceneBegin = -1;
				}
			}
			currentActBegin = anno.getBegin();
		}
	}
	if (currentActBegin >= 0) {
		AnnotationFactory.createAnnotation(jcas, currentActBegin, mainMatter.getEnd(), Act.class);
	}
	if (currentSceneBegin >= 0) {
		AnnotationFactory.createAnnotation(jcas, currentSceneBegin, mainMatter.getEnd(), Scene.class);
	}
	AnnotationUtil.trim(new ArrayList<Scene>(JCasUtil.select(jcas, Scene.class)));
	AnnotationUtil.trim(new ArrayList<Act>(JCasUtil.select(jcas, Act.class)));

	DramaIOUtil.cleanUp(jcas);

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:74,代码来源:GutenbergDEReader.java

示例8: getNext

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
public static void getNext(JCas jcas, InputStream file, Drama drama, boolean strict)
		throws IOException, CollectionException {

	Document doc = Jsoup.parse(file, "UTF-8", "", Parser.xmlParser());

	// meta data
	drama.setDocumentTitle(doc.select("titleStmt > title").first().text());
	if (!doc.select("idno[type=\"TextGridUri\"]").isEmpty())
		drama.setDocumentId(doc.select("idno[type=\"TextGridUri\"]").first().text().substring(9));

	// Author
	Elements authorElements = doc.select("author");
	for (int i = 0; i < authorElements.size(); i++) {
		Element authorElement = authorElements.get(i);
		Author author = new Author(jcas);
		author.setName(authorElement.text());
		if (authorElement.hasAttr("key")) {
			author.setPnd(authorElement.attr("key").replace("pnd:", ""));
		}
		author.addToIndexes();
	}

	Visitor vis = new Visitor(jcas);

	Element root = doc.select("TEI > text").first();
	root.traverse(vis);
	jcas = vis.getJCas();

	select2Annotation(jcas, root, vis.getAnnotationMap(), "front", FrontMatter.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "body", MainMatter.class, null);

	MainMatter mainMatter = JCasUtil.selectSingle(jcas, MainMatter.class);

	select2Annotation(jcas, root, vis.getAnnotationMap(), "speaker", Speaker.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "stage", StageDirection.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "sp", Utterance.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "l", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "ab", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "p", Speech.class, mainMatter);

	readActsAndScenes(jcas, root, vis.getAnnotationMap(), strict);
	readDramatisPersonae(jcas, root, vis.getAnnotationMap());

	fixSpeakerAnnotations(jcas);

	AnnotationUtil.trim(new ArrayList<Figure>(JCasUtil.select(jcas, Figure.class)));
	AnnotationUtil.trim(new ArrayList<Speech>(JCasUtil.select(jcas, Speech.class)));
	AnnotationUtil.trim(new ArrayList<Utterance>(JCasUtil.select(jcas, Utterance.class)));
	AnnotationUtil.trim(new ArrayList<Scene>(JCasUtil.select(jcas, Scene.class)));
	AnnotationUtil.trim(new ArrayList<Act>(JCasUtil.select(jcas, Act.class)));

	// DramaIOUtil.cleanUp(jcas);

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:55,代码来源:TextGridUtil.java

示例9: getNext

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void getNext(final JCas jcas, InputStream file, Drama drama) throws IOException, CollectionException {
	Document doc = Jsoup.parse(file, "UTF-8", "", Parser.xmlParser());

	// meta data
	drama.setDocumentTitle(doc.select("titleStmt > title").first().text());
	if (!doc.select("sourceDesc > bibl > idno[type=\"URL\"]").isEmpty())
		drama.setDocumentId(doc.select("sourceDesc > bibl > idno[type=\"URL\"]").first().text().substring(36));

	// Author
	Elements authorElements = doc.select("author");
	for (int i = 0; i < authorElements.size(); i++) {
		Element authorElement = authorElements.get(i);
		Author author = new Author(jcas);
		author.setName(authorElement.text());
		if (authorElement.hasAttr("key")) {
			author.setPnd(authorElement.attr("key").replace("pnd:", ""));
		}
		author.addToIndexes();
	}

	Visitor vis = new Visitor(jcas);

	Element root = doc.select("TEI > text").first();
	root.traverse(vis);
	vis.getJCas();

	select2Annotation(jcas, root, vis.getAnnotationMap(), "front", FrontMatter.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "body", MainMatter.class, null);

	MainMatter mainMatter = JCasUtil.selectSingle(jcas, MainMatter.class);

	select2Annotation(jcas, root, vis.getAnnotationMap(), "speaker", Speaker.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "stage", StageDirection.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "sp", Utterance.class, null,
			new Select2AnnotationCallback<Utterance>() {
				@Override
				public void call(Utterance annotation, Element xmlElement) {
					Collection<Speaker> speakers = JCasUtil.selectCovered(Speaker.class, annotation);
					for (Speaker sp : speakers) {
						String[] whos = xmlElement.attr("who").split(" ");
						sp.setXmlId(new StringArray(jcas, whos.length));
						for (int i = 0; i < whos.length; i++)
							sp.setXmlId(i, whos[i].substring(1));
					}
				}
			});
	select2Annotation(jcas, root, vis.getAnnotationMap(), "l", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "ab", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "p", Speech.class, mainMatter);

	TextGridUtil.readActsAndScenes(jcas, root, vis.getAnnotationMap(), true);
	TextGridUtil.readDramatisPersonae(jcas, root, vis.getAnnotationMap());

	readCast(jcas, drama, doc);

	AnnotationUtil.trim(new ArrayList<Figure>(JCasUtil.select(jcas, Figure.class)));
	AnnotationUtil.trim(new ArrayList<Speech>(JCasUtil.select(jcas, Speech.class)));
	AnnotationUtil.trim(new ArrayList<Utterance>(JCasUtil.select(jcas, Utterance.class)));
	AnnotationUtil.trim(new ArrayList<Scene>(JCasUtil.select(jcas, Scene.class)));
	AnnotationUtil.trim(new ArrayList<Act>(JCasUtil.select(jcas, Act.class)));

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:64,代码来源:GerDraCorUrlReader.java

示例10: getNext

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void getNext(final JCas jcas, InputStream file, Drama drama) throws IOException, CollectionException {
	Document doc = Jsoup.parse(file, "UTF-8", "", Parser.xmlParser());

	// meta data
	drama.setDocumentTitle(doc.select("titleStmt > title[type=\"main\"]").first().text());
	if (!doc.select("publicationStmt > idno[type=\"cligs\"]").isEmpty())
		drama.setDocumentId(doc.select("publicationStmt > idno[type=\"cligs\"]").first().text());

	// Author
	Elements authorElements = doc.select("author");
	for (int i = 0; i < authorElements.size(); i++) {
		Element authorElement = authorElements.get(i);
		Author author = new Author(jcas);
		author.setName(authorElement.select("name[type=\"full\"]").text());
		author.addToIndexes();
	}

	Visitor vis = new Visitor(jcas);

	Element root = doc.select("TEI > text").first();
	root.traverse(vis);
	vis.getJCas();

	select2Annotation(jcas, root, vis.getAnnotationMap(), "front", FrontMatter.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "body", MainMatter.class, null);

	MainMatter mainMatter = JCasUtil.selectSingle(jcas, MainMatter.class);

	select2Annotation(jcas, root, vis.getAnnotationMap(), "speaker", Speaker.class, null);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "stage", StageDirection.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "sp", Utterance.class, null,
			new Select2AnnotationCallback<Utterance>() {
				@Override
				public void call(Utterance annotation, Element xmlElement) {
					Collection<Speaker> speakers = JCasUtil.selectCovered(Speaker.class, annotation);
					for (Speaker sp : speakers) {
						String[] whos = xmlElement.attr("who").split(" ");
						sp.setXmlId(new StringArray(jcas, whos.length));
						for (int i = 0; i < whos.length; i++)
							sp.setXmlId(i, whos[i]);
					}
				}
			});
	select2Annotation(jcas, root, vis.getAnnotationMap(), "l", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "ab", Speech.class, mainMatter);
	select2Annotation(jcas, root, vis.getAnnotationMap(), "p", Speech.class, mainMatter);

	readActsAndScenes(jcas, root, vis.getAnnotationMap(), true);
	TextGridUtil.readDramatisPersonae(jcas, root, vis.getAnnotationMap());

	readCast(jcas, drama, doc);

	AnnotationUtil.trim(new ArrayList<Figure>(JCasUtil.select(jcas, Figure.class)));
	AnnotationUtil.trim(new ArrayList<Speech>(JCasUtil.select(jcas, Speech.class)));
	AnnotationUtil.trim(new ArrayList<Utterance>(JCasUtil.select(jcas, Utterance.class)));
	AnnotationUtil.trim(new ArrayList<Scene>(JCasUtil.select(jcas, Scene.class)));
	AnnotationUtil.trim(new ArrayList<Act>(JCasUtil.select(jcas, Act.class)));

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:61,代码来源:TheatreClassicUrlReader.java

示例11: next

import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
public AbstractCas next() throws AnalysisEngineProcessException {
  JCas jCasDst = getEmptyJCas();
  
  jCasDst.setDocumentLanguage(mBaseJcas.getDocumentLanguage());
  
  //logger.info("*** NEXT! ***");

  CasCopier   copier = new CasCopier(mBaseJcas.getCas(), jCasDst.getCas());                  
  
  if (mAnswId < 0) {
    Question yaq = JCasUtil.selectSingle(mBaseJcas, Question.class);
  
    jCasDst.setDocumentText(mQuestJCas.getDocumentText());
    // Copy tags produced by the sentence splitter, tagger, and tokenizer
    copyAnnotations(mQuestJCas, jCasDst);
    
    // After copying attributes, correct start/end 
    Question dstQuest = (Question)copier.copyFs(yaq);
    dstQuest.setBegin(0);
    dstQuest.setEnd(yaq.getCoveredText().length());
    // start/end are corrected, can now index 
    dstQuest.addToIndexes();                 
    
    mAnswId = 0;
    
    PrintInfoHelper.printInfo1(logger, jCasDst);
    
    return jCasDst;
  }
  
  JCas    answJCas = mAnswerJCas.get(mAnswId);
  Answer  yan      = mAnswerAnnot.get(mAnswId);
  
  jCasDst.setDocumentText(answJCas.getDocumentText());
  
  // After copying attributes, correct start/end indices
  Answer dstAnsw = (Answer)copier.copyFs(yan);
  dstAnsw.setBegin(0);
  dstAnsw.setEnd(yan.getCoveredText().length());
  // start/end are corrected, can now index 
  dstAnsw.addToIndexes();
  
  // Copy tags produced by the sentence splitter, tagger, and tokenizer
  copyAnnotations(answJCas, jCasDst);
  
  ++mAnswId; 
  
  PrintInfoHelper.printInfo1(logger, jCasDst);
  
  return jCasDst;
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:52,代码来源:InputSplitterClearAnnot1.java


注:本文中的org.apache.uima.fit.util.JCasUtil.selectSingle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。