/** * @param modelFileName the file name of the model */ public Tagger(String modelFileName) { this(new Options(new String[]{"-model",modelFileName})); }
String[] pair = args[i].split(":"); if (pair[0].equals("--help")) explain(); else if (pair[0].equals("-train")) { train = true;
public static Tagger getTagger(File modelFile) { String[] argsT={"-model",modelFile.toString()}; return new Tagger(new is2.tag.Options(argsT)); }
@Override protected Tagger produceResource(URL aUrl) throws IOException { File modelFile = ResourceUtils.getUrlAsFile(aUrl, true); String[] args = { "-model", modelFile.getPath() }; Options option = new Options(args); Tagger tagger = new Tagger(option); // create a POSTagger HashMap<String, HashMap<String, Integer>> featureSet = tagger.mf.getFeatureSet(); SingletonTagset posTags = new SingletonTagset(POS.class, getResourceMetaData() .getProperty("pos.tagset")); HashMap<String, Integer> posTagFeatures = featureSet.get("POS"); posTags.addAll(posTagFeatures.keySet()); posTags.removeAll(asList("<None>", "<root-POS>")); addTagset(posTags); if (printTagSet) { getContext().getLogger().log(INFO, getTagset().toString()); } return tagger; } };
is2.tag.Options optsTagger = new is2.tag.Options(new String[]{"-model","models/tag-eng.model"}); Tagger tagger = new Tagger(optsTagger);
public static void main (String[] args) throws FileNotFoundException, Exception { long start = System.currentTimeMillis(); Options options = new Options(args); Tagger tagger = new Tagger(); if (options.train) { // depReader.normalizeOn=false; tagger.li = new Long2Int(options.hsize); tagger.pipe = new ExtractorT2 (options, tagger.mf= new MFO()); //tagger.pipe.li =tagger.li; InstancesTagger is = (InstancesTagger)tagger.pipe.createInstances(options.trainfile); tagger.params = new ParametersFloat(tagger.li.size()); tagger.train(options, tagger.pipe,tagger.params,is); tagger.writeModel(options, tagger.pipe, tagger.params); } if (options.test) { tagger.readModel(options); tagger.out(options,tagger.pipe, tagger.params); } System.out.println(); if (options.eval) { System.out.println("\nEVALUATION PERFORMANCE:"); Evaluator.evaluateTagger(options.goldfile, options.outfile,options.format); } long end = System.currentTimeMillis(); System.out.println("used time "+((float)((end-start)/100)/10)); }