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


Java StringUtils.splitOnCharWithQuoting方法代码示例

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


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

示例1: readData

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Populates data in this Lexicon from the character stream given by the
 * Reader r.
 */
public void readData(BufferedReader in) throws IOException {
  final String SEEN = "SEEN";
  String line;
  int lineNum = 1;
  // all lines have one tagging with raw count per line
  line = in.readLine();
  Pattern p = Pattern.compile("^smooth\\[([0-9])\\] = (.*)$");
  while (line != null && line.length() > 0) {
    try {
      Matcher m = p.matcher(line);
      if (m.matches()) {
        int i = Integer.parseInt(m.group(1));
        smooth[i] = Double.parseDouble(m.group(2));
      } else {
        // split on spaces, quote with doublequote, and escape with backslash
        String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\');
        // System.out.println("fields:\n" + fields[0] + "\n" + fields[1] +
        // "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4]);
        boolean seen = fields[3].equals(SEEN);
        addTagging(seen, new IntTaggedWord(fields[2], fields[0]), Double.parseDouble(fields[4]));
      }
    } catch (RuntimeException e) {
      throw new IOException("Error on line " + lineNum + ": " + line);
    }
    lineNum++;
    line = in.readLine();
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:33,代码来源:BaseLexicon.java

示例2: UnaryRule

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/** Decode a UnaryRule out of a String representation with help from
 *  a Numberer.
 */
public UnaryRule(String s, Numberer n) {
  String[] fields = StringUtils.splitOnCharWithQuoting(s, ' ', '\"', '\\');
  //    System.out.println("fields:\n" + fields[0] + "\n" + fields[2] + "\n" + fields[3]);
  this.parent = n.number(fields[0]);
  this.child = n.number(fields[2]);
  this.score = Float.parseFloat(fields[3]);
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:11,代码来源:UnaryRule.java

示例3: readData

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Populates data in this DependencyGrammar from the character stream
 * given by the Reader r.
 */
@Override
public void readData(BufferedReader in) throws IOException {
  final String LEFT = "left";
  int lineNum = 1;
  // all lines have one rule per line
  boolean doingStop = false;
  IntDependency tempDependency = new IntDependency(-2, -2, -2, -2, false, 0);

  for (String line = in.readLine(); line != null && line.length() > 0; line = in.readLine()) {
    try {
      if (line.equals("BEGIN_STOP")) {
        doingStop = true;
        continue;
      }
      String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\'); // split on spaces, quote with doublequote, and escape with backslash
      //        System.out.println("fields:\n" + fields[0] + "\n" + fields[1] + "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4] + "\n" + fields[5]);

      tempDependency.leftHeaded = fields[3].equals(LEFT);
      short distance = (short)Integer.parseInt(fields[4]);
      tempDependency.head = new IntTaggedWord(fields[0], '/');
      tempDependency.arg = new IntTaggedWord(fields[2], '/');

      double count = Double.parseDouble(fields[5]);
      if (doingStop) {
        expandStop(tempDependency, distance, count, false);
      } else {
        expandArg(tempDependency, distance, count);
      }
    } catch (Exception e) {
      IOException ioe = new IOException("Error on line " + lineNum + ": " + line);
      ioe.initCause(e);
      throw ioe;
    }
    //      System.out.println("read line " + lineNum + ": " + line);
    lineNum++;
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:42,代码来源:MLEDependencyGrammar.java

示例4: BinaryRule

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Creates a BinaryRule from String s, assuming it was created using toString().
 *
 * @param s A String in which the binary rule is represented as parent,
 *     left-child, right-child, score, with the items quoted as needed
 * @param n Number used to convert String names to ints
 */
public BinaryRule(String s, Numberer n) {
  String[] fields = StringUtils.splitOnCharWithQuoting(s, ' ', '\"', '\\');
  //    System.out.println("fields:\n" + fields[0] + "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4]);
  this.parent = n.number(fields[0]);
  this.leftChild = n.number(fields[2]);
  this.rightChild = n.number(fields[3]);
  this.score = Float.parseFloat(fields[4]);
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:16,代码来源:BinaryRule.java

示例5: readData

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Populates data in this Lexicon from the character stream given by the
 * Reader r.
 * TODO: this doesn't appear to correctly read in the
 * UnknownWordModel in the case of a model more complicated than the
 * unSeenCounter
 */
public void readData(BufferedReader in) throws IOException {
  final String SEEN = "SEEN";
  String line;
  int lineNum = 1;
  // all lines have one tagging with raw count per line
  line = in.readLine();
  Pattern p = Pattern.compile("^smooth\\[([0-9])\\] = (.*)$");
  while (line != null && line.length() > 0) {
    try {
      Matcher m = p.matcher(line);
      if (m.matches()) {
        int i = Integer.parseInt(m.group(1));
        smooth[i] = Double.parseDouble(m.group(2));
      } else {
        // split on spaces, quote with doublequote, and escape with backslash
        String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\');
        // System.out.println("fields:\n" + fields[0] + "\n" + fields[1] +
        // "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4]);
        boolean seen = fields[3].equals(SEEN);
        addTagging(seen, new IntTaggedWord(fields[2], fields[0], wordIndex, tagIndex), Double.parseDouble(fields[4]));
      }
    } catch (RuntimeException e) {
      throw new IOException("Error on line " + lineNum + ": " + line, e);
    }
    lineNum++;
    line = in.readLine();
  }
  initRulesWithWord();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:37,代码来源:BaseLexicon.java

示例6: readData

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Populates data in this DependencyGrammar from the character stream
 * given by the Reader r.
 */
@Override
public void readData(BufferedReader in) throws IOException {
  final String LEFT = "left";
  int lineNum = 1;
  // all lines have one rule per line
  boolean doingStop = false;

  for (String line = in.readLine(); line != null && line.length() > 0; line = in.readLine()) {
    try {
      if (line.equals("BEGIN_STOP")) {
        doingStop = true;
        continue;
      }
      String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\'); // split on spaces, quote with doublequote, and escape with backslash
      //        System.out.println("fields:\n" + fields[0] + "\n" + fields[1] + "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4] + "\n" + fields[5]);

      
      short distance = (short)Integer.parseInt(fields[4]);
      IntTaggedWord tempHead = new IntTaggedWord(fields[0], '/', wordIndex, tagIndex);
      IntTaggedWord tempArg = new IntTaggedWord(fields[2], '/', wordIndex, tagIndex);
      IntDependency tempDependency = new IntDependency(tempHead, tempArg, fields[3].equals(LEFT), distance);

      double count = Double.parseDouble(fields[5]);
      if (doingStop) {
        expandStop(tempDependency, distance, count, false);
      } else {
        expandArg(tempDependency, distance, count);
      }
    } catch (Exception e) {
      IOException ioe = new IOException("Error on line " + lineNum + ": " + line);
      ioe.initCause(e);
      throw ioe;
    }
    //      System.out.println("read line " + lineNum + ": " + line);
    lineNum++;
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:42,代码来源:MLEDependencyGrammar.java

示例7: UnaryRule

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/** Decode a UnaryRule out of a String representation with help from
 *  an Index.
 *
 *  @param s The String representation
 *  @param index The Index used to convert String to int
 */
public UnaryRule(String s, Index<String> index) {
  String[] fields = StringUtils.splitOnCharWithQuoting(s, ' ', '\"', '\\');
  //    System.out.println("fields:\n" + fields[0] + "\n" + fields[2] + "\n" + fields[3]);
  this.parent = index.indexOf(fields[0]);
  this.child = index.indexOf(fields[2]);
  this.score = Float.parseFloat(fields[3]);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:14,代码来源:UnaryRule.java

示例8: BinaryRule

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Creates a BinaryRule from String s, assuming it was created using toString().
 *
 * @param s A String in which the binary rule is represented as parent,
 *     left-child, right-child, score, with the items quoted as needed
 * @param index Index used to convert String names to ints
 */
public BinaryRule(String s, Index<String> index) {
  String[] fields = StringUtils.splitOnCharWithQuoting(s, ' ', '\"', '\\');
  //    System.out.println("fields:\n" + fields[0] + "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4]);
  this.parent = index.indexOf(fields[0], true);
  this.leftChild = index.indexOf(fields[2], true);
  this.rightChild = index.indexOf(fields[3], true);
  this.score = Float.parseFloat(fields[4]);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:16,代码来源:BinaryRule.java


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