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


Java StringUtils.getNotNullString方法代码示例

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


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

示例1: printAnswersXML

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
private static <IN extends CoreMap> void printAnswersXML(List<IN> doc, PrintWriter out) {
  int num = 0;
  for (IN wi : doc) {
    String prev = StringUtils.getNotNullString(wi.get(CoreAnnotations.BeforeAnnotation.class));
    out.print(prev);
    out.print("<wi num=\"");
    // tag.append(wi.get("position"));
    out.print(num++);
    out.print("\" entity=\"");
    out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.AnswerAnnotation.class)));
    out.print("\">");
    out.print(XMLUtils.escapeXML(StringUtils.getNotNullString(wi.get(CoreAnnotations.TextAnnotation.class))));
    out.print("</wi>");
    String after = StringUtils.getNotNullString(wi.get(CoreAnnotations.AfterAnnotation.class));
    out.print(after);
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:18,代码来源:PlainTextDocumentReaderAndWriter.java

示例2: printAnswersInlineXML

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
private void printAnswersInlineXML(List<IN> doc, PrintWriter out) {
  final String background = flags.backgroundSymbol;
  String prevTag = background;
  for (Iterator<IN> wordIter = doc.iterator(); wordIter.hasNext();) {
    IN wi = wordIter.next();
    String tag = StringUtils.getNotNullString(wi.get(CoreAnnotations.AnswerAnnotation.class));

    String before = StringUtils.getNotNullString(wi.get(CoreAnnotations.BeforeAnnotation.class));

    String current = StringUtils.getNotNullString(wi.get(CoreAnnotations.OriginalTextAnnotation.class));
    if (!tag.equals(prevTag)) {
      if (!prevTag.equals(background) && !tag.equals(background)) {
        out.print("</");
        out.print(prevTag);
        out.print('>');
        out.print(before);
        out.print('<');
        out.print(tag);
        out.print('>');
      } else if (!prevTag.equals(background)) {
        out.print("</");
        out.print(prevTag);
        out.print('>');
        out.print(before);
      } else if (!tag.equals(background)) {
        out.print(before);
        out.print('<');
        out.print(tag);
        out.print('>');
      }
    } else {
      out.print(before);
    }
    out.print(current);
    String afterWS = StringUtils.getNotNullString(wi.get(CoreAnnotations.AfterAnnotation.class));

    if (!tag.equals(background) && !wordIter.hasNext()) {
      out.print("</");
      out.print(tag);
      out.print('>');
      prevTag = background;
    } else {
      prevTag = tag;
    }
    out.print(afterWS);
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:48,代码来源:PlainTextDocumentReaderAndWriter.java

示例3: printAnswersTokenizedInlineXML

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
private void printAnswersTokenizedInlineXML(List<IN> doc, PrintWriter out) {
  final String background = flags.backgroundSymbol;
  String prevTag = background;
  boolean first = true;
  for (Iterator<IN> wordIter = doc.iterator(); wordIter.hasNext();) {
    IN wi = wordIter.next();
    String tag = StringUtils.getNotNullString(wi.get(CoreAnnotations.AnswerAnnotation.class));
    if (!tag.equals(prevTag)) {
      if (!prevTag.equals(background) && !tag.equals(background)) {
        out.print("</");
        out.print(prevTag);
        out.print("> <");
        out.print(tag);
        out.print('>');
      } else if (!prevTag.equals(background)) {
        out.print("</");
        out.print(prevTag);
        out.print("> ");
      } else if (!tag.equals(background)) {
        if (!first) {
          out.print(' ');
        }
        out.print('<');
        out.print(tag);
        out.print('>');
      }
    } else {
      if (!first) {
        out.print(' ');
      }
    }
    first = false;
    out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.OriginalTextAnnotation.class)));

    if (!wordIter.hasNext()) {
      if (!tag.equals(background)) {
        out.print("</");
        out.print(tag);
        out.print('>');
      }
      out.print(' ');
      prevTag = background;
    } else {
      prevTag = tag;
    }
  }
  out.println();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:49,代码来源:PlainTextDocumentReaderAndWriter.java


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