public SequenceValidator<String> getSequenceValidator() { return new DefaultPOSSequenceValidator(getTagDictionary()); }
/** * Initializes the current instance with the provided model. * * @param model */ public POSTaggerME(POSModel model) { POSTaggerFactory factory = model.getFactory(); int beamSize = POSTaggerME.DEFAULT_BEAM_SIZE; String beamSizeString = model.getManifestProperty(BeamSearch.BEAM_SIZE_PARAMETER); if (beamSizeString != null) { beamSize = Integer.parseInt(beamSizeString); } modelPackage = model; contextGen = factory.getPOSContextGenerator(beamSize); tagDictionary = factory.getTagDictionary(); size = beamSize; sequenceValidator = factory.getSequenceValidator(); if (model.getPosSequenceModel() != null) { this.model = model.getPosSequenceModel(); } else { this.model = new opennlp.tools.ml.BeamSearch<>(beamSize, model.getPosModel(), 0); } }
@Test public void testPOSTaggerWithDefaultFactory() throws IOException { POSDictionary posDict = POSDictionary.create(POSDictionaryTest.class .getResourceAsStream("TagDictionaryCaseSensitive.xml")); POSModel posModel = trainPOSModel(new POSTaggerFactory(null, null, posDict)); POSTaggerFactory factory = posModel.getFactory(); Assert.assertTrue(factory.getTagDictionary() instanceof POSDictionary); Assert.assertTrue(factory.getPOSContextGenerator() != null); Assert.assertTrue(factory.getSequenceValidator() instanceof DefaultPOSSequenceValidator); ByteArrayOutputStream out = new ByteArrayOutputStream(); posModel.serialize(out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); POSModel fromSerialized = new POSModel(in); factory = fromSerialized.getFactory(); Assert.assertTrue(factory.getTagDictionary() instanceof POSDictionary); Assert.assertTrue(factory.getPOSContextGenerator() != null); Assert.assertTrue(factory.getSequenceValidator() instanceof DefaultPOSSequenceValidator); }
@Test public void testPOSTaggerWithCustomFactory() throws IOException { DummyPOSDictionary posDict = new DummyPOSDictionary( POSDictionary.create(POSDictionaryTest.class .getResourceAsStream("TagDictionaryCaseSensitive.xml"))); POSModel posModel = trainPOSModel(new DummyPOSTaggerFactory(posDict)); POSTaggerFactory factory = posModel.getFactory(); Assert.assertTrue(factory.getTagDictionary() instanceof DummyPOSDictionary); Assert.assertTrue(factory.getPOSContextGenerator() instanceof DummyPOSContextGenerator); Assert.assertTrue(factory.getSequenceValidator() instanceof DummyPOSSequenceValidator); ByteArrayOutputStream out = new ByteArrayOutputStream(); posModel.serialize(out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); POSModel fromSerialized = new POSModel(in); factory = fromSerialized.getFactory(); Assert.assertTrue(factory.getTagDictionary() instanceof DummyPOSDictionary); Assert.assertTrue(factory.getPOSContextGenerator() instanceof DummyPOSContextGenerator); Assert.assertTrue(factory.getSequenceValidator() instanceof DummyPOSSequenceValidator); }
&& this.factory.getTagDictionary() == null) { this.factory.setTagDictionary(this.factory .createTagDictionary(tagDictionaryFile)); dict = this.factory.getTagDictionary(); if (dict == null) { dict = this.factory.createEmptyTagDictionary();
public SequenceValidator<String> getSequenceValidator() { return new DefaultPOSSequenceValidator(getTagDictionary()); }
public SequenceValidator<String> getSequenceValidator() { return new DefaultPOSSequenceValidator(getTagDictionary()); }
TagDictionary dict = postaggerFactory.getTagDictionary(); if (dict == null) { dict = postaggerFactory.createEmptyTagDictionary();
if (aDictCutOff != Flags.DEFAULT_DICT_CUTOFF) { try { TagDictionary dict = getPosTaggerFactory().getTagDictionary(); if (dict == null) { dict = getPosTaggerFactory().createEmptyTagDictionary();
/** * Initializes the current instance with the provided model. * * @param model */ public POSTaggerME(POSModel model) { POSTaggerFactory factory = model.getFactory(); int beamSize = POSTaggerME.DEFAULT_BEAM_SIZE; String beamSizeString = model.getManifestProperty(BeamSearch.BEAM_SIZE_PARAMETER); if (beamSizeString != null) { beamSize = Integer.parseInt(beamSizeString); } modelPackage = model; contextGen = factory.getPOSContextGenerator(beamSize); tagDictionary = factory.getTagDictionary(); size = beamSize; sequenceValidator = factory.getSequenceValidator(); if (model.getPosSequenceModel() != null) { this.model = model.getPosSequenceModel(); } else { this.model = new opennlp.tools.ml.BeamSearch<>(beamSize, model.getPosModel(), 0); } }
/** * Initializes the current instance with the provided model. * * @param model */ public POSTaggerME(POSModel model) { POSTaggerFactory factory = model.getFactory(); int beamSize = POSTaggerME.DEFAULT_BEAM_SIZE; String beamSizeString = model.getManifestProperty(BeamSearch.BEAM_SIZE_PARAMETER); if (beamSizeString != null) { beamSize = Integer.parseInt(beamSizeString); } modelPackage = model; contextGen = factory.getPOSContextGenerator(beamSize); tagDictionary = factory.getTagDictionary(); size = beamSize; sequenceValidator = factory.getSequenceValidator(); if (model.getPosSequenceModel() != null) { this.model = model.getPosSequenceModel(); } else { this.model = new opennlp.tools.ml.BeamSearch<>(beamSize, model.getPosModel(), 0); } }
&& this.factory.getTagDictionary() == null) { this.factory.setTagDictionary(this.factory .createTagDictionary(tagDictionaryFile)); dict = this.factory.getTagDictionary(); if (dict == null) { dict = this.factory.createEmptyTagDictionary();
&& this.factory.getTagDictionary() == null) { this.factory.setTagDictionary(this.factory .createTagDictionary(tagDictionaryFile)); dict = this.factory.getTagDictionary(); if (dict == null) { dict = this.factory.createEmptyTagDictionary();
TagDictionary dict = postaggerFactory.getTagDictionary(); if (dict == null) { dict = postaggerFactory.createEmptyTagDictionary();
TagDictionary dict = postaggerFactory.getTagDictionary(); if (dict == null) { dict = postaggerFactory.createEmptyTagDictionary();