本文整理汇总了Java中edu.stanford.nlp.ie.crf.CRFClassifier.loadClassifierNoExceptions方法的典型用法代码示例。如果您正苦于以下问题:Java CRFClassifier.loadClassifierNoExceptions方法的具体用法?Java CRFClassifier.loadClassifierNoExceptions怎么用?Java CRFClassifier.loadClassifierNoExceptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ie.crf.CRFClassifier
的用法示例。
在下文中一共展示了CRFClassifier.loadClassifierNoExceptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception{
args=new String[]{"chi-sen.deseg"};
Properties props = new Properties();
//props.setProperty("sighanCorporaDict", "data");
// String dir="/home/users0/anders/storage/backuped/demos/SRLDemos/models/chi/stanford-chinese-segmenter-2008-05-21";
String dir="/home/users0/anders/storage/scratch/anders/stanford-segmenter-2013-06-20/";
props.setProperty("sighanCorporaDict", dir+"/data");
// props.setProperty("NormalizationTable", "data/norm.simp.utf8");
// props.setProperty("normTableEncoding", "UTF-8");
// below is needed because CTBSegDocumentIteratorFactory accesses it
//props.setProperty("serDictionary","data/dict-chris6.ser.gz");
props.setProperty("serDictionary",dir+"/data/dict-chris6.ser.gz");
//props.setProperty("testFile", args[0]);
props.setProperty("inputEncoding", "UTF-8");
props.setProperty("sighanPostProcessing", "true");
CRFClassifier<CoreLabel> classifier = new CRFClassifier<CoreLabel>(props);
//classifier.loadClassifierNoExceptions("data/ctb.gz", props);
classifier.loadClassifierNoExceptions(dir+"/data/ctb.gz", props);
// flags must be re-set after data is loaded
classifier.flags.setProperties(props);
//classifier.writeAnswers(classifier.test(args[0]));
//classifier.testAndWriteAnswers(args[0]);
//ObjectBank<List<CoreLabel>> documents = classifier.makeObjectBank(args[0]);
List<String> forms=classifier.segmentString("上海浦东近年来颁布实行了涉及经济、贸易、建设、规划、科技、文教等领域的七十一件法规性文件,确保了浦东开发的有序进行。");
for(String form:forms)
System.out.println(form);
}
示例2: loadClassifier
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public static CRFClassifier<CoreLabel> loadClassifier(String options) throws IllegalArgumentException {
String[] inputFlags = options.split(" ");
Properties props = StringUtils.argsToProperties(inputFlags);
SeqClassifierFlags flags = new SeqClassifierFlags(props);
CRFClassifier<CoreLabel> crfSegmenter = new CRFClassifier<>(flags);
if(flags.loadClassifier == null) {
throw new IllegalArgumentException("missing -loadClassifier flag for CRF preprocessor.");
}
crfSegmenter.loadClassifierNoExceptions(flags.loadClassifier, props);
crfSegmenter.loadTagIndex();
return crfSegmenter;
}
示例3: setSegmentor
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public void setSegmentor()
{
Properties props = new Properties();
props.setProperty("sighanCorporaDict", "segment");
props.setProperty("serDictionary","segment/dict-chris6.ser.gz");
props.setProperty("inputEncoding", "UTF-8");
props.setProperty("sighanPostProcessing", "true");
segmentor = new CRFClassifier(props);
segmentor.loadClassifierNoExceptions("segment/ctb.gz", props);
segmentor.flags.setProperties(props);
}