本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph类的典型用法代码示例。如果您正苦于以下问题:Java Paragraph类的具体用法?Java Paragraph怎么用?Java Paragraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Paragraph类属于de.tudarmstadt.ukp.dkpro.core.api.segmentation.type包,在下文中一共展示了Paragraph类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPipeline
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
/**
* Creates a tokenizing pipeline
*
* @throws IOException exception
*/
private static AnalysisEngineDescription getPipeline()
throws IOException
{
if (pipelineSingleton == null) {
try {
pipelineSingleton = AnalysisEngineFactory.createEngineDescription(
AnalysisEngineFactory.createEngineDescription(ParagraphSplitter.class,
ParagraphSplitter.PARAM_SPLIT_PATTERN,
ParagraphSplitter.SINGLE_LINE_BREAKS_PATTERN),
AnalysisEngineFactory.createEngineDescription(ArkTweetTokenizerFixed.class),
AnalysisEngineFactory.createEngineDescription(StanfordSegmenter.class,
StanfordSegmenter.PARAM_WRITE_TOKEN, false,
StanfordSegmenter.PARAM_ZONE_TYPES,
Paragraph.class.getCanonicalName()));
}
catch (ResourceInitializationException e) {
throw new IOException();
}
}
return pipelineSingleton;
}
示例2: copyParagraphAndTokenAnnotations
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
private static void copyParagraphAndTokenAnnotations(JCas source, JCas target)
{
if (!source.getDocumentText().equals(target.getDocumentText())) {
throw new IllegalArgumentException("Source and target have different content");
}
for (Paragraph p : JCasUtil.select(source, Paragraph.class)) {
Paragraph paragraph = new Paragraph(target);
paragraph.setBegin(p.getBegin());
paragraph.setEnd(p.getEnd());
paragraph.addToIndexes();
}
for (Token t : JCasUtil.select(source, Token.class)) {
Token token = new Token(target);
token.setBegin(t.getBegin());
token.setEnd(t.getEnd());
token.addToIndexes();
}
}
示例3: copyParagraphAnnotations
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
/**
* Creates paragraph annotations in {@code target} by copying paragraphs from the {@code source}.
*
* @param source source jcas
* @param target target jcas
* @throws IllegalArgumentException if source text and target text are different or if target
* already contains paragraph annotations
*/
public static void copyParagraphAnnotations(JCas source, JCas target)
throws IllegalArgumentException
{
if (!source.getDocumentText().equals(target.getDocumentText())) {
throw new IllegalArgumentException(
"source.documentText and target.documentText are not equal");
}
Collection<Paragraph> targetParagraphs = JCasUtil.select(target, Paragraph.class);
if (!targetParagraphs.isEmpty()) {
throw new IllegalArgumentException("target already contains paragraph annotations");
}
for (Paragraph paragraph : JCasUtil.select(source, Paragraph.class)) {
Paragraph paragraphCopy = new Paragraph(target);
paragraphCopy.setBegin(paragraph.getBegin());
paragraphCopy.setEnd(paragraph.getEnd());
paragraphCopy.addToIndexes();
}
}
示例4: hasSpaceBefore
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
/**
* Returns true if the token has a preceding whitespace in the original document
*
* @param token token
* @param jCas jcas
* @return boolen
*/
public static boolean hasSpaceBefore(Token token, JCas jCas)
{
// select previous token(s)
List<Token> prevTokens = JCasUtil.selectPreceding(jCas, Token.class, token, 1);
Paragraph paragraph = JCasUtil.selectCovering(jCas, Paragraph.class, token).iterator()
.next();
return !prevTokens.isEmpty() && (prevTokens.iterator().next().getEnd() != token.getBegin())
&& (token.getBegin() != paragraph.getBegin());
}
示例5: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
@Override
public void process(JCas jCas)
throws AnalysisEngineProcessException
{
String text = jCas.getDocumentText();
ArrayList<ParagraphBoundaries> boundaries = getParagraphBoundaries(text);
Iterator<ParagraphBoundaries> it = boundaries.iterator();
while(it.hasNext()) {
ParagraphBoundaries p = it.next();
//System.out.println(p.getBegin() + " " + p.getEnd());
new Paragraph(jCas, p.getBegin(), p.getEnd()).addToIndexes();
}
}
示例6: renderDocumentToHtmlParagraphs
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
public static List<String> renderDocumentToHtmlParagraphs(JCas jCas)
{
List<String> result = new ArrayList<>();
// iterate over paragraphs
for (Paragraph p : JCasUtil.select(jCas, Paragraph.class)) {
StringWriter writer = new StringWriter();
PrintWriter out = new PrintWriter(writer);
// iterate over tokens
for (Token t : JCasUtil.selectCovered(jCas, Token.class, p)) {
// print token's preceding space if needed
if (ArgumentPrinterUtils.hasSpaceBefore(t, jCas)) {
out.print(" ");
}
// does an argument concept begin here?
ArgumentComponent argumentConcept = ArgumentPrinterUtils
.argAnnotationBegins(t, jCas);
if (argumentConcept != null) {
String additionalInfo = "";
if (argumentConcept instanceof Claim) {
additionalInfo = " [stance: " + ((Claim) argumentConcept).getStance() + "]";
}
out.printf("<span class=\"component\">%s%s:</span> <span class=\"%s\">",
argumentConcept.getClass().getSimpleName().toLowerCase(),
additionalInfo,
argumentConcept.getClass().getSimpleName().toLowerCase());
}
Sentence sentence = ArgumentPrinterUtils.sentenceStartsOnToken(t);
if (sentence != null) {
out.printf("<span class=\"sentence\">S%d</span>",
ArgumentPrinterUtils.getSentenceNumber(sentence, jCas));
}
// print token
out.print(t.getCoveredText());
// does an argument concept end here?
if (ArgumentPrinterUtils.argAnnotationEnds(t, jCas)) {
out.print("</span>");
}
}
result.add(writer.toString());
}
return result;
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:50,代码来源:Step06eAnnotatedDataExporter.java
示例7: getParagraphCount
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph; //导入依赖的package包/类
/**
* Returns the number of {@link Paragraph} in the CAS.
*
* @param aJCas the CAS
* @return the paragraph count
*/
public static int getParagraphCount(final JCas aJCas)
{
return count(Paragraph.class, aJCas);
}