/** * Retrieves the version string. * * The {@link #parse(String)} method can create an instance * of {@link Version} with the returned version value string. * * @return the version value string */ @Override public String toString() { return Integer.toString(getMajor()) + "." + Integer.toString(getMinor()) + "." + Integer.toString(getRevision()) + (isSnapshot() ? SNAPSHOT_MARKER : ""); }
@Override public int hashCode() { return Objects.hash(getMajor(), getMinor(), getRevision(), isSnapshot()); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Version) { Version version = (Version) obj; return getMajor() == version.getMajor() && getMinor() == version.getMinor() && getRevision() == version.getRevision() && isSnapshot() == version.isSnapshot(); } return false; }
@Override protected void createArtifactSerializers( Map<String, ArtifactSerializer> serializers) { super.createArtifactSerializers(serializers); // In 1.6.x the headrules artifact is serialized with the new API // which uses the Serializeable interface // This change is not backward compatible with the 1.5.x models. // In order to laod 1.5.x model the English headrules serializer must be // put on the serializer map. if (getVersion().getMajor() == 1 && getVersion().getMinor() == 5) { serializers.put("headrules", new HeadRulesSerializer()); } serializers.put("postagger", new POSModelSerializer()); serializers.put("chunker", new ChunkerModelSerializer()); }
public POSContextGenerator getPOSContextGenerator(int cacheSize) { if (artifactProvider != null) { Properties manifest = (Properties) artifactProvider.getArtifact("manifest.properties"); String version = manifest.getProperty("OpenNLP-Version"); if (Version.parse(version).getMinor() < 8) { return new DefaultPOSContextGenerator(cacheSize, getDictionary()); } } return new ConfigurablePOSContextGenerator(cacheSize, createFeatureGenerators()); }
@Override protected void validateArtifactMap() throws InvalidFormatException { super.validateArtifactMap(); if (!(artifactMap.get(CHUNKER_MODEL_ENTRY_NAME) instanceof AbstractModel)) { throw new InvalidFormatException("Chunker model is incomplete!"); } // Since 1.8.0 we changed the ChunkerFactory signature. This will check the if the model // declares a not default factory, and if yes, check if it was created before 1.8 if ( (getManifestProperty(FACTORY_NAME) != null && !getManifestProperty(FACTORY_NAME).equals("opennlp.tools.chunker.ChunkerFactory") ) && this.getVersion().getMajor() <= 1 && this.getVersion().getMinor() < 8) { throw new InvalidFormatException("The Chunker factory '" + getManifestProperty(FACTORY_NAME) + "' is no longer compatible. Please update it to match the latest ChunkerFactory."); } }
public POSModel create(InputStream in) throws IOException { POSModel posModel = new POSModel(new UncloseableInputStream(in)); // The 1.6.x models write the non-default beam size into the model itself. // In 1.5.x the parser configured the beam size when the model was loaded, // this is not possible anymore with the new APIs Version version = posModel.getVersion(); if (version.getMajor() == 1 && version.getMinor() == 5) { if (posModel.getManifestProperty(BeamSearch.BEAM_SIZE_PARAMETER) == null) { Map<String, String> manifestInfoEntries = new HashMap<>(); // The version in the model must be correct or otherwise version // dependent code branches in other places fail manifestInfoEntries.put("OpenNLP-Version", "1.5.0"); posModel = new POSModel(posModel.getLanguage(), posModel.getPosModel(), 10, manifestInfoEntries, posModel.getFactory()); } } return posModel; }
public ChunkerModel create(InputStream in) throws IOException { ChunkerModel model = new ChunkerModel(new UncloseableInputStream(in)); Version version = model.getVersion(); if (version.getMajor() == 1 && version.getMinor() == 5) { model = new ChunkerModel(model.getLanguage(), model.getChunkerModel(), new ParserChunkerFactory()); } return model; }
/** * Retrieves the version string. * * The {@link #parse(String)} method can create an instance * of {@link Version} with the returned version value string. * * @return the version value string */ @Override public String toString() { return Integer.toString(getMajor()) + "." + Integer.toString(getMinor()) + "." + Integer.toString(getRevision()) + (isSnapshot() ? SNAPSHOT_MARKER : ""); }
/** * Retrieves the version string. * * The {@link #parse(String)} method can create an instance * of {@link Version} with the returned version value string. * * @return the version value string */ @Override public String toString() { return Integer.toString(getMajor()) + "." + Integer.toString(getMinor()) + "." + Integer.toString(getRevision()) + (isSnapshot() ? SNAPSHOT_MARKER : ""); }
@Override public int hashCode() { return Objects.hash(getMajor(), getMinor(), getRevision(), isSnapshot()); }
@Override public int hashCode() { return Objects.hash(getMajor(), getMinor(), getRevision(), isSnapshot()); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Version) { Version version = (Version) obj; return getMajor() == version.getMajor() && getMinor() == version.getMinor() && getRevision() == version.getRevision() && isSnapshot() == version.isSnapshot(); } return false; }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Version) { Version version = (Version) obj; return getMajor() == version.getMajor() && getMinor() == version.getMinor() && getRevision() == version.getRevision() && isSnapshot() == version.isSnapshot(); } return false; }
@Override protected void createArtifactSerializers( Map<String, ArtifactSerializer> serializers) { super.createArtifactSerializers(serializers); // In 1.6.x the headrules artifact is serialized with the new API // which uses the Serializeable interface // This change is not backward compatible with the 1.5.x models. // In order to laod 1.5.x model the English headrules serializer must be // put on the serializer map. if (getVersion().getMajor() == 1 && getVersion().getMinor() == 5) { serializers.put("headrules", new HeadRulesSerializer()); } serializers.put("postagger", new POSModelSerializer()); serializers.put("chunker", new ChunkerModelSerializer()); }
public POSContextGenerator getPOSContextGenerator(int cacheSize) { if (artifactProvider != null) { Properties manifest = (Properties) artifactProvider.getArtifact("manifest.properties"); String version = manifest.getProperty("OpenNLP-Version"); if (Version.parse(version).getMinor() < 8) { return new DefaultPOSContextGenerator(cacheSize, getDictionary()); } } return new ConfigurablePOSContextGenerator(cacheSize, createFeatureGenerators()); }
public POSContextGenerator getPOSContextGenerator(int cacheSize) { if (artifactProvider != null) { Properties manifest = (Properties) artifactProvider.getArtifact("manifest.properties"); String version = manifest.getProperty("OpenNLP-Version"); if (Version.parse(version).getMinor() < 8) { return new DefaultPOSContextGenerator(cacheSize, getDictionary()); } } return new ConfigurablePOSContextGenerator(cacheSize, createFeatureGenerators()); }
public ChunkerModel create(InputStream in) throws IOException { ChunkerModel model = new ChunkerModel(new UncloseableInputStream(in)); Version version = model.getVersion(); if (version.getMajor() == 1 && version.getMinor() == 5) { model = new ChunkerModel(model.getLanguage(), model.getChunkerModel(), new ParserChunkerFactory()); } return model; }
public ChunkerModel create(InputStream in) throws IOException { ChunkerModel model = new ChunkerModel(new UncloseableInputStream(in)); Version version = model.getVersion(); if (version.getMajor() == 1 && version.getMinor() == 5) { model = new ChunkerModel(model.getLanguage(), model.getChunkerModel(), new ParserChunkerFactory()); } return model; }