gpt4 book ai didi

edu.illinois.cs.cogcomp.lbjava.nlp.Word.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 05:29:05 29 4
gpt4 key购买 nike

本文整理了Java中edu.illinois.cs.cogcomp.lbjava.nlp.Word.<init>()方法的一些代码示例,展示了Word.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Word.<init>()方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.lbjava.nlp.Word
类名称:Word
方法名:<init>

Word.<init>介绍

[英]When all that is known is the spelling of the word.
[中]当我们只知道单词的拼写时。

代码示例

代码示例来源:origin: CogComp/cogcomp-nlp

/**
 * Add the provided token to the sentence, for also do any additional word spliting.
 *
 * @param sentence the sentence to add the word to.
 * @param token the individual token.
 * @param tag the tag to annotate the word with.
 */
public static void addTokenToSentence(LinkedVector sentence, String token, String tag, ParametersForLbjCode prs) {
  NEWord word = new NEWord(new Word(token), null, tag);
  word.params = prs;
  addTokenToSentence(sentence, word);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-ner

/**
 * Add the provided token to the sentence, for also do any additional word spliting.
 *
 * @param sentence the sentence to add the word to.
 * @param token the individual token.
 * @param tag the tag to annotate the word with.
 */
public static void addTokenToSentence(LinkedVector sentence, String token, String tag, ParametersForLbjCode prs) {
  NEWord word = new NEWord(new Word(token), null, tag);
  word.params = prs;
  addTokenToSentence(sentence, word);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-mlner

/**
 * Add the provided token to the sentence, for also do any additional word spliting.
 *
 * @param sentence the sentence to add the word to.
 * @param token the individual token.
 * @param tag the tag to annotate the word with.
 */
public static void addTokenToSentence(LinkedVector sentence, String token, String tag) {
  NEWord word = new NEWord(new Word(token), null, tag);
  addTokenToSentence(sentence, word);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-standalone-nlp-pipeline

public IllinoisPOSHandler() 
{
  super("Illinois Part-Of-Speech Tagger", "0.2", "illinoispos");
  logger.info("Loading POS model..");
  tagger.discreteValue(new Token(new Word("The"), null, ""));
  logger.info("POS Tagger ready");
  tokensfield = CuratorViewNames.tokens;
  sentencesfield = CuratorViewNames.sentences;
}

代码示例来源:origin: CogComp/cogcomp-nlp

/**
   * Given textual input in the format shown below, this method parses and
   * returns the <code>Word</code> that the text represents.  Expected
   * format: <br><br>
   * <p/>
   * <code>(pos spelling)</code>
   *
   * @param text     Text representing a word in POS bracket form.
   * @param previous The word that came before this word in the sentence.
   * @return A <code>Word</code> represented by the input text or
   * <code>null</code> if the input does not represent a
   * <code>Word</code>.
   **/
  public static Word parsePOSBracketForm(String text, Word previous) {
    if (text.charAt(0) != '(' || text.charAt(text.length() - 1) != ')')
      return null;
    String[] tokens = text.split(" ");
    if (tokens.length != 2) return null;
    return new Word(tokens[1].substring(0, tokens[1].length() - 1),
        tokens[0].substring(1),
        previous);
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

/**
 * Given an array of <code>String</code>s, this method creates a new
 * {@link LinkedVector} containing {@link Word}s.
 *
 * @param a An array of <code>String</code>s.
 * @return A {@link LinkedVector} of {@link Word}s corresponding to the
 * input <code>String</code>s.
 **/
public static LinkedVector convert(String[] a) {
  if (a == null) return null;
  if (a.length == 0) return new LinkedVector();
  Word w = new Word(a[0]);
  for (int i = 1; i < a.length; ++i) {
    w.next = new Word(a[i], null, w);
    w = (Word) w.next;
  }
  return new LinkedVector(w);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava-NLP-tools

/**
 * Given an array of <code>String</code>s, this method creates a new
 * {@link LinkedVector} containing {@link Word}s.
 *
 * @param a An array of <code>String</code>s.
 * @return A {@link LinkedVector} of {@link Word}s corresponding to the
 * input <code>String</code>s.
 **/
public static LinkedVector convert(String[] a) {
  if (a == null) return null;
  if (a.length == 0) return new LinkedVector();
  Word w = new Word(a[0]);
  for (int i = 1; i < a.length; ++i) {
    w.next = new Word(a[i], null, w);
    w = (Word) w.next;
  }
  return new LinkedVector(w);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava-NLP-tools

/**
   * Given textual input in the format shown below, this method parses and
   * returns the <code>Word</code> that the text represents.  Expected
   * format: <br><br>
   * <p/>
   * <code>(pos spelling)</code>
   *
   * @param text     Text representing a word in POS bracket form.
   * @param previous The word that came before this word in the sentence.
   * @return A <code>Word</code> represented by the input text or
   * <code>null</code> if the input does not represent a
   * <code>Word</code>.
   **/
  public static Word parsePOSBracketForm(String text, Word previous) {
    if (text.charAt(0) != '(' || text.charAt(text.length() - 1) != ')')
      return null;
    String[] tokens = text.split(" ");
    if (tokens.length != 2) return null;
    return new Word(tokens[1].substring(0, tokens[1].length() - 1),
        tokens[0].substring(1),
        previous);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-standalone-nlp-pipeline

public IllinoisChunkerHandler(String configFilename) {
  super("Illinois Chunker", "0.3", "illinoischunker");
  logger.info("Loading Chunker model..");
  tagger.discreteValue(new Token(new Word("The"), null, ""));
  logger.info("Chunker ready");
  // XXX If no configuration file is give use the default values from CuratorViewNames
  if (configFilename.trim().equals("")) {
    tokensfield = CuratorViewNames.tokens;
    sentencesfield = CuratorViewNames.sentences;
    posfield = CuratorViewNames.pos;
  }
  else {
    Properties config = new Properties();
    try {
      FileInputStream in = new FileInputStream(configFilename);
      config.load(new BufferedInputStream(in));
      in.close();
    } catch (IOException e) {
      logger.warn("Error reading configuration file. {}", configFilename);
    }
    tokensfield = config.getProperty("tokens.field", CuratorViewNames.tokens );
    sentencesfield = config.getProperty("sentences.field", CuratorViewNames.sentences );
    posfield = config.getProperty("pos.field", CuratorViewNames.pos );
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava-NLP-tools

Word w = new Word(tokens[1].substring(0, tokens[1].length() - 1),
    tokens[0].substring(1),
    0,
      new Word(tokens[i + 1].substring(0, tokens[i + 1].length() - 1),
          tokens[i].substring(1),
          w,

代码示例来源:origin: CogComp/cogcomp-nlp

/**
   * Produces the next object parsed from the input file; in this case, that object is guaranteed
   * to be a <code>LinkedVector</code> populated by <code>Token</code>s representing a sentence.
   **/
  public Object next() {
    String[] line = (String[]) super.next();
    while (line != null && (line.length < 2 || line[4].equals("-X-")))
      line = (String[]) super.next();
    if (line == null)
      return null;

    if (line[3].charAt(0) == 'I')
      line[3] = "B" + line[3].substring(1);
    Token t = new Token(new Word(line[5], line[4]), null, line[3]);
    String previous = line[3];

    for (line = (String[]) super.next(); line != null && line.length > 0; line =
        (String[]) super.next()) {
      if (line[3].charAt(0) == 'I' && !previous.endsWith(line[3].substring(2)))
        line[3] = "B" + line[3].substring(1);
      t.next = new Token(new Word(line[5], line[4]), t, line[3]);
      t = (Token) t.next;
      previous = line[3];
    }

    return new LinkedVector(t);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-chunker

/**
   * Produces the next object parsed from the input file; in this case, that object is guaranteed
   * to be a <code>LinkedVector</code> populated by <code>Token</code>s representing a sentence.
   **/
  public Object next() {
    String[] line = (String[]) super.next();
    while (line != null && (line.length < 2 || line[4].equals("-X-")))
      line = (String[]) super.next();
    if (line == null)
      return null;

    if (line[3].charAt(0) == 'I')
      line[3] = "B" + line[3].substring(1);
    Token t = new Token(new Word(line[5], line[4]), null, line[3]);
    String previous = line[3];

    for (line = (String[]) super.next(); line != null && line.length > 0; line =
        (String[]) super.next()) {
      if (line[3].charAt(0) == 'I' && !previous.endsWith(line[3].substring(2)))
        line[3] = "B" + line[3].substring(1);
      t.next = new Token(new Word(line[5], line[4]), t, line[3]);
      t = (Token) t.next;
      previous = line[3];
    }

    return new LinkedVector(t);
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

/**
   * Produces the next object parsed from the input file; in this case, that object is guaranteed
   * to be a <code>LinkedVector</code> populated by <code>Token</code>s representing a sentence.
   **/
  public Object next() {
    String[] line = (String[]) super.next();
    while (line != null && line.length == 0)
      line = (String[]) super.next();
    if (line == null)
      return null;

    String pos = line[1];
    if (pos.equals("-"))
      pos = null;
    Token t = new Token(new Word(line[0], pos), null, line[2]);

    for (line = (String[]) super.next(); line != null && line.length > 0; line =
        (String[]) super.next()) {
      pos = line[1];
      if (pos.equals("-"))
        pos = null;
      t.next = new Token(new Word(line[0], pos), t, line[2]);
      t = (Token) t.next;
    }

    return new LinkedVector(t);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-chunker

/**
   * Produces the next object parsed from the input file; in this case, that object is guaranteed
   * to be a <code>LinkedVector</code> populated by <code>Token</code>s representing a sentence.
   **/
  public Object next() {
    String[] line = (String[]) super.next();
    while (line != null && line.length == 0)
      line = (String[]) super.next();
    if (line == null)
      return null;

    String pos = line[1];
    if (pos.equals("-"))
      pos = null;
    Token t = new Token(new Word(line[0], pos), null, line[2]);

    for (line = (String[]) super.next(); line != null && line.length > 0; line =
        (String[]) super.next()) {
      pos = line[1];
      if (pos.equals("-"))
        pos = null;
      t.next = new Token(new Word(line[0], pos), t, line[2]);
      t = (Token) t.next;
    }

    return new LinkedVector(t);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-mlner

private static Vector<NEWord> splitWord(NEWord word) {
  String[] sentence = {word.form + " "};
  Parser parser = new WordSplitter(new SentenceSplitter(sentence));
  LinkedVector words = (LinkedVector) parser.next();
  Vector<NEWord> res = new Vector<>();
  if (words == null) {
    res.add(word);
    return res;
  }
  String label = word.neLabel;
  for (int i = 0; i < words.size(); i++) {
    if (label.contains("B-") && i > 0)
      label = "I-" + label.substring(2);
    NEWord w = new NEWord(new Word(((Word) words.get(i)).form), null, label);
    res.addElement(w);
  }
  return res;
}

代码示例来源:origin: CogComp/cogcomp-nlp

private static Vector<NEWord> splitWord(NEWord word) {
  String[] sentence = {word.form + " "};
  Parser parser = new WordSplitter(new SentenceSplitter(sentence));
  LinkedVector words = (LinkedVector) parser.next();
  Vector<NEWord> res = new Vector<>();
  if (words == null) {
    res.add(word);
    return res;
  }
  String label = word.neLabel;
  for (int i = 0; i < words.size(); i++) {
    if (label.contains("B-") && i > 0)
      label = "I-" + label.substring(2);
    NEWord w = new NEWord(new Word(((Word) words.get(i)).form), null, label);
    res.addElement(w);
  }
  return res;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-ner

private static Vector<NEWord> splitWord(NEWord word) {
  String[] sentence = {word.form + " "};
  Parser parser = new WordSplitter(new SentenceSplitter(sentence));
  LinkedVector words = (LinkedVector) parser.next();
  Vector<NEWord> res = new Vector<>();
  if (words == null) {
    res.add(word);
    return res;
  }
  String label = word.neLabel;
  for (int i = 0; i < words.size(); i++) {
    if (label.contains("B-") && i > 0)
      label = "I-" + label.substring(2);
    NEWord w = new NEWord(new Word(((Word) words.get(i)).form), null, label);
    res.addElement(w);
  }
  return res;
}

代码示例来源:origin: CogComp/cogcomp-nlp

public static void nullifyTaggerCachedFields(SparseNetworkLearner tagger) {
  NEWord w = new NEWord(new Word("lala1"), null, "O");
  w.parts = new String[0];
  NEWord[] words =
      {new NEWord(w, null, "O"), new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O")};
  for (int i = 1; i < words.length; i++) {
    words[i].parts = new String[0];
    words[i].previous = words[i - 1];
    words[i].previousIgnoreSentenceBoundary = words[i - 1];
    words[i - 1].next = words[i];
    words[i - 1].nextIgnoreSentenceBoundary = words[i];
  }
  for (NEWord word : words)
    word.neTypeLevel1 = word.neTypeLevel2 = "O";
  tagger.classify(words[3]);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-mlner

public static void nullifyTaggerCachedFields(SparseNetworkLearner tagger) {
  NEWord w = new NEWord(new Word("lala1"), null, "O");
  w.parts = new String[0];
  NEWord[] words =
      {new NEWord(w, null, "O"), new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O")};
  for (int i = 1; i < words.length; i++) {
    words[i].parts = new String[0];
    words[i].previous = words[i - 1];
    words[i].previousIgnoreSentenceBoundary = words[i - 1];
    words[i - 1].next = words[i];
    words[i - 1].nextIgnoreSentenceBoundary = words[i];
  }
  for (NEWord word : words)
    word.neTypeLevel1 = word.neTypeLevel2 = "O";
  tagger.classify(words[3]);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-ner

public static void nullifyTaggerCachedFields(SparseNetworkLearner tagger) {
  NEWord w = new NEWord(new Word("lala1"), null, "O");
  w.parts = new String[0];
  NEWord[] words =
      {new NEWord(w, null, "O"), new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O"),
          new NEWord(w, null, "O"), new NEWord(w, null, "O")};
  for (int i = 1; i < words.length; i++) {
    words[i].parts = new String[0];
    words[i].previous = words[i - 1];
    words[i].previousIgnoreSentenceBoundary = words[i - 1];
    words[i - 1].next = words[i];
    words[i - 1].nextIgnoreSentenceBoundary = words[i];
  }
  for (NEWord word : words)
    word.neTypeLevel1 = word.neTypeLevel2 = "O";
  tagger.classify(words[3]);
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com