Package org.fnlp.ml.types.alphabet

Examples of org.fnlp.ml.types.alphabet.LabelAlphabet.lookupIndex()


    s = rd.readLine();          //#label
    int nLabel = Integer.parseInt(s);
    System.out.println(nLabel);
    for(int i=0; i<nLabel; i++) {
      s = rd.readLine();        //label
      labels.lookupIndex(s);
    }
    out.writeObject(labels);
    rd.readLine();            //blank line
    rd.readLine();            //#column
    rd.readLine();            //blank line
View Full Code Here


      TIntArrayList wordlist = new TIntArrayList();
      for(int j=0;j<toks.length;j++){
        String tok = toks[j];
        if(sw.isStopWord(tok))
          continue;
        int idx = dict.lookupIndex(tok);
        wordlist.add(idx);
      }
      documentsList.add(wordlist);
    }
    in.close();
View Full Code Here

    for(int i=0;i<label.size();i++){
      String cn = label.lookupString(i);
      String en = map.get(cn);     
      if(en==null)
        System.out.println("POSTag Not Found: "+cn);
      int id = enLabel.lookupIndex(en);     
    }
    enLabel.setStopIncrement(true);
  }

}
View Full Code Here

        if (action == ParsingState.Action.RIGHT)
          heads[lr[0]] = -1;

        // writer.write(String.valueOf(instance.postags[lr[0]]));
        String pos = instance.getTagAt(lr[0]);
        postagAlphabet.lookupIndex(pos);
        writer.write(pos);
        writer.write(" ");
        switch (action) {
        case LEFT:
          writer.write("L");
View Full Code Here

        int[] data = new int[tokens.size() - 2];
        for (int i = 0; i < data.length; i++) {
          data[i] = Integer.parseInt(tokens.get(i + 2));
        }
        Instance inst = new Instance(data);
        inst.setTarget(labelAlphabet.lookupIndex(tokens.get(1)));

        instset.add(inst);
      }
    }
View Full Code Here

    LabelAlphabet la = factory.DefaultLabelAlphabet();
    IFeatureAlphabet fa = factory.DefaultFeatureAlphabet();
    int count = 0;
   
    //preReader为了把ysize定下来
    la.lookupIndex("S");
    while(preReader.hasNext()){
      Sentence sent = (Sentence) preReader.next();
      Target targets = (Target)sent.getTarget();
      for(int i=0; i<sent.length(); i++){
        String label;
View Full Code Here

          }
          //else if(targets.getHead(i) > i){
          else{
            label = "R" + targets.getDepClass(i);
          }
          la.lookupIndex(label);
        }
      }
    }
    int ysize = la.size();
    la.setStopIncrement(true);
View Full Code Here

          label+="R"+sent.getDepClass(lr[0]);
          break;
        default:
          label = "S";         
        }
        int id = la.lookupIndex(label);       
        Instance inst = new Instance();
        inst.setTarget(id);
        int[] idx = JointParser.addFeature(fa, features, ysize);
        inst.setData(idx);
        instset.add(inst);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.