edu.stanford.nlp.sequences.SeqClassifierFlags Java Examples
The following examples show how to use
edu.stanford.nlp.sequences.SeqClassifierFlags.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NERTool.java From Criteria2Query with Apache License 2.0 | 5 votes |
public static void train(String traindatapath,String targetpath){ long startTime = System.nanoTime(); /* Step 1: learn the classifier from the training data */ String trainFile = traindatapath; /* Learn the classifier from the training data */ String serializeFileLoc =targetpath; // properties: https://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/ie/NERFeatureFactory.html Properties props = new Properties(); props.put("trainFile", trainFile); // To train with multiple files, a comma separated list props.put("map", "word=0,answer=1"); props.put("useClassFeature", "true"); props.put("useNGrams", "true"); props.put("noMidNGrams", "true"); props.put("maxNGramLeng", "6"); props.put("useDisjunctive", "true"); props.put("usePrev", "true"); props.put("useNext", "true"); props.put("useSequences", "true"); props.put("usePrevSequences", "true"); props.put("maxLeft", "1"); props.put("useTypeSeqs", "true"); props.put("useTypeSeqs2", "true"); props.put("useTypeySequences", "true"); props.put("wordShape", "chris2useLC"); // props.put("printFeatures", "true"); // This feature can be turned off in recent versions with the flag -useKnownLCWords false // https://nlp.stanford.edu/software/crf-faq.html question 13 SeqClassifierFlags flags = new SeqClassifierFlags(props); CRFClassifier<CoreLabel> crf = new CRFClassifier<CoreLabel>(flags); crf.train(); crf.serializeClassifier(serializeFileLoc); }
Example #2
Source File: TrainNerModel.java From InformationExtraction with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { String path = IntelConfig.DEPARTMENT_TRAIN_PROPERTY; Properties props = StringUtils.propFileToProperties(path); SeqClassifierFlags flags = new SeqClassifierFlags(props); CRFClassifier<CoreLabel> crf = new CRFClassifier<CoreLabel>(flags); crf.train(); String modelPath = props.getProperty("serializeTo"); crf.serializeClassifier(modelPath); System.out.println("Build model to " + modelPath); }
Example #3
Source File: CRFPreprocessor.java From phrasal with GNU General Public License v3.0 | 5 votes |
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; }
Example #4
Source File: CRFPostprocessor.java From phrasal with GNU General Public License v3.0 | 5 votes |
public CRFPostprocessor(Properties props) { // Currently, this class only supports one featureFactory. props.put("featureFactory", CRFPostprocessorFeatureFactory.class.getName()); flags = new SeqClassifierFlags(props); classifier = new CRFClassifier<CoreLabel>(flags); }
Example #5
Source File: CRFPostprocessorFeatureFactory.java From phrasal with GNU General Public License v3.0 | 4 votes |
public void init(SeqClassifierFlags flags) { super.init(flags); }
Example #6
Source File: ProcessorTools.java From phrasal with GNU General Public License v3.0 | 4 votes |
@Override public void init(SeqClassifierFlags flags) {}