Package org.fnlp.nlp.cn.tag

Examples of org.fnlp.nlp.cn.tag.CWSTagger


   * @param args
   * @throws IOException
   * @throws 
   */
  public static void main(String[] args) throws Exception {
    CWSTagger tag = new CWSTagger("./models/seg.m")

    RLSeg rlseg = new RLSeg(tag,"./tmpdata/FNLPDATA/all.dict");

    tag.setDictionary(tempdict);

    System.out.println("\n处理文件:");
    String s4 = tag.tagFile("../example-data/data-tag.txt");
    System.out.println(s4);
    String[] toks = s4.split("\\s+");
    int newset = rlseg.update(toks);
    rlseg.close();

    tag.setDictionary(tempdict);

    System.out.println("\n处理文件:");
    String s = tag.tagFile("../example-data/data-tag.txt");
    System.out.println(s);


  }
View Full Code Here


   * @param args
   * @throws IOException
   * @throws 
   */
  public static void main(String[] args) throws Exception {
    CWSTagger tag = new CWSTagger("./models/seg.m");
    Dictionary dict=new Dictionary();
    dict.addFile("./models/dict.txt");
    tag.setDictionary(dict);
    ArrayList<String> str = MyCollection.loadList("./testcase/test case seg.txt",null);
    for(String s:str){     
      String t = tag.tag(s);
//      t = tag.tag(t);
      System.out.println(t);
    }
    tag.setEnFilter(false);
    for(String s:str){
      String t = tag.tag(s);
      System.out.println(t);
    }
   
    String t = tag.tagFile("data/FNLPDATA/seg/bad case.txt");
    System.out.println(t);
   
  }
View Full Code Here

   * @param args
   * @throws IOException
   * @throws 
   */
  public static void main(String[] args) throws Exception {
    CWSTagger tag = new CWSTagger("./models/seg.m");
    ArrayList<String> str = MyCollection.loadList("./testcase/seg.txt",null);
    for(String s:str){     
      String t = tag.tag(s);
//      t = tag.tag(t);
      System.out.println(t);
    }
    tag.setEnFilter(false);
    for(String s:str){
      String t = tag.tag(s);
      System.out.println(t);
    }
   
    ArrayList<String> str1 = MyCollection.loadList("data/FNLPDATA/seg/bad case.txt",null);
    for(String s:str1){   
      s = s.trim();
      String s1 = s.replaceAll(" ", "");
      String t = tag.tag(s1);
      System.out.println("处理: "+t);
      if(!t.equals(s))
        System.err.println("正确: "+s)
    }
   
View Full Code Here

    for(m=1;m<=4;m++){
      System.out.println(m);
      MemoryStatic.start();
      switch(m){
      case 1:
        stag = new CWSTagger("../models/seg.m");
        System.out.println("分词");
        break;
      case 2:
        ttag = new POSTagger("../models/seg.m","../models/pos.m");
        System.out.println("词性标注");
View Full Code Here

  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    seg = new CWSTagger("./models/seg.m");
    cl = seg.getClassifier();
    int ysize = cl.getAlphabetFactory().getLabelSize();
    LinearViterbi vit = (LinearViterbi) cl.getInferencer();
    System.out.println(cl.getAlphabetFactory().getFeatureSize());
    HigherOrderViterbi inferencer = new HigherOrderViterbi(vit.getTemplets(), ysize);
View Full Code Here

    out.close();

  }
 
  private static void seg() throws IOException, LoadModelException {
    CWSTagger seg = new CWSTagger("../models/seg.m");
   
    BufferedReader in = new BufferedReader(new InputStreamReader(
        new FileInputStream(simpfile ), "utf8"));

    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
        segfile), "utf8"));

    String line = null
    int count=0;
    while ((line = in.readLine()) != null) {
      if(line.length()==0){
       
      }else if(line.startsWith("<doc")){
        count++;       
      }else if(line.startsWith("</doc>")){
        count--;
      }else{
        line = seg.tag(line);     
      }
      out.append(line);
      out.append("\n");
    }
    System.out.println(count);
View Full Code Here

TOP

Related Classes of org.fnlp.nlp.cn.tag.CWSTagger

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.