2016-12-26 94 views

回答

0
try { 
     propFile = new File(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/propfile.prop"); 
     properties = new Properties(); 
     properties.load(new FileInputStream(propFile)); 

     String to = properties.getProperty("serializeTo"); 

     properties.setProperty("serializeTo", "ner-customModel.ser.gz"); 
     properties.setProperty("trainFile",System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/outputTokenized.tsv"); 
     CRFClassifier crf = new CRFClassifier(properties); 
     crf.train(); 
     String s2 = "apples are apples"; 

     System.out.println(crf.classifyToString(s2)); 

     crf.serializeClassifier(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/ner-customModel.ser.gz"); 

    } catch (IOException e) { 
     e.printStackTrace(); 
    } 

並聲明培訓文件和屬性文件中的其他屬性。 這對我有用:)

相關問題