Package opennlp.tools.util

Examples of opennlp.tools.util.Pair


        }

        for (Iterator i = scanner.getPositions(sb).iterator();
             i.hasNext();) {
            Integer candidate = (Integer)i.next();
            Pair p = new Pair(sb, candidate);
            String type = (candidate.intValue() == sentEndPos) ? "T" : "F";
            SDEvent evt = new SDEvent(type,cg.getContext(p));

            if (null != tail) {
                tail.next = evt;
View Full Code Here


      int fws = getFirstWS(s,cint + 1);
      if (((i + 1) < end) && (((Integer) enders.get(i + 1)).intValue() < fws)) {
        continue;
      }

      Pair pair = new Pair(sb, candidate);
      double[] probs = model.eval(cgen.getContext(pair));
      String bestOutcome = model.getBestOutcome(probs);
      sentProb *= probs[model.getIndex(bestOutcome)];
      if (bestOutcome.equals("T") && isAcceptableBreak(s, index, cint)) {
        if (index != cint) {
View Full Code Here

    int split = s.lastIndexOf("_");
    if (split == -1) {
      System.out.println("There is a problem in your training data: "
          + s
          + " does not conform to the format WORD_TAG.");
      return new Pair(s, "UNKNOWN");
    }
    return new Pair(s.substring(0, split), s.substring(split+1));
  }
View Full Code Here

  public static Pair convertAnnotatedString(String s) {
    ArrayList tokens = new ArrayList();
    ArrayList outcomes = new ArrayList();
    StringTokenizer st = new StringTokenizer(s);
    while(st.hasMoreTokens()) {
      Pair p = split(st.nextToken());
      tokens.add(p.a);
      outcomes.add(p.b);
    }
    return new Pair(tokens, outcomes);
  }
View Full Code Here

    //System.out.println("Collecting events");
    try {
      String s = br.readLine();
     
      while (s != null) {
        Pair p = convertAnnotatedString(s);
        ArrayList tokens = (ArrayList)p.a;
        ArrayList outcomes = (ArrayList)p.b;
        ArrayList tags = new ArrayList();
       
        for (int i=0; i<tokens.size(); i++) {
View Full Code Here

    BufferedReader br = new BufferedReader(r);
    String line;
    try {
      while ((line = br.readLine()) != null) {
        sentences++;
        Pair p = POSEventCollector.convertAnnotatedString(line);
        List words = (List) p.a;
        List outcomes = (List) p.b;
        List tags = beam.bestSequence(words, null).getOutcomes();

        int c = 0;
View Full Code Here

TOP

Related Classes of opennlp.tools.util.Pair

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.