Package opennlp.ccg.lexicon

Examples of opennlp.ccg.lexicon.Word


    /** Adds the items (eg stems) from the given sign's words to the context items. */
    public void updateContext(Sign sign) {
        List words = sign.getWords();
        if (words == null) return;
        for (int i = 0; i < words.size(); i++) {
            Word word = (Word) words.get(i);
            updateItems(word, contextItems);
        }
    }
View Full Code Here


     */
    protected double repeatedItems(List words) {
        previousItems.clear();
        double retval = 0;
        for (int i = 0; i < words.size(); i++) {
            Word word = (Word) words.get(i);
            retval += repeatedItems(word);
            updateItems(word, previousItems);
        }
        return retval;
    }
View Full Code Here

    List<Word> words = currentSign.getWords();
    int min = Math.min(currentHeadIndex, currentDepIndex);
    int max = Math.max(currentHeadIndex, currentDepIndex);
    int count = 0;
    for (int i=min+1; i < max; i++) {
      Word w = words.get(i);
      if (!isPunct(w)) count++;
    }
    return count;
  }
View Full Code Here

     */
    @Override
    protected void prepareToScoreWords() {
        stringsToScore.clear();
        for (int i = 0; i < wordsToScore.size(); i++) {
            Word w = wordsToScore.get(i);
            String s = w.getForm();
            // check for sem class replacement
            String scr = semClassReplacement(w);
            if (scr != null) s = scr;
            // add pitch accent and attrs, if any
            String pitchAccent = w.getPitchAccent();
            Iterator<Pair<String,String>> pairs = w.getAttrValPairs();
            if (pitchAccent != null || pairs.hasNext()) {
                StringBuffer sb = new StringBuffer();
                sb.append(s);
                if (pitchAccent != null) sb.append('_').append(pitchAccent);
                for (; pairs.hasNext(); ) {
View Full Code Here

     * probability.
     */
    public List<TaggedWord> betaBestFilter(List<TaggedWord> sentence) {
        List<TaggedWord> res = new ArrayList<TaggedWord>(sentence.size());
        for (TaggedWord tw : sentence) {
            Word w = tw.getWord();
            double best = tw.getPOSTagging().get(0).a;
            int endIndex = 0;
            for (Pair<Double, String> tagging : tw.getPOSTagging()) {
                if (tagging.a >= (beta * best)) {
                    endIndex++;
View Full Code Here

              if (reverse) {
                  List<Word> tmp = words;
                  words = new ArrayList<Word>(words.size());
                  words.add(Word.createWord("<s>"));
                  for (int j = tmp.size()-1; j >= 0; j--) {
                      Word w = tmp.get(j);
                      if (w.getForm() == "<s>" || w.getForm() == "</s>") continue; // skip <s> or </s>
                      words.add(w);
                  }
                  words.add(Word.createWord("</s>"));
              }
              // write str, add to unique set
View Full Code Here

    public static int compareTo(List<Word> words1, List<Word> words2) {
      int i=0;
      while (i < words1.size() || i < words2.size()) {
        if (i == words1.size()) return -1;
        if (i == words2.size()) return 1;
        Word w1 = words1.get(i); Word w2 = words2.get(i);
        int cmp = w1.compareTo(w2);
        if (cmp != 0) return cmp;
        i++;
      }
      return 0;
View Full Code Here

TOP

Related Classes of opennlp.ccg.lexicon.Word

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.