@Override
protected void validateArtifactMap() throws InvalidFormatException {
super.validateArtifactMap();
if (!(artifactMap.get(POS_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
throw new InvalidFormatException("POS model is incomplete!");
}
// Ensure that the tag dictionary is compatible with the model
Object tagdictEntry = artifactMap.get(TAG_DICTIONARY_ENTRY_NAME);
if (tagdictEntry != null) {
if (tagdictEntry instanceof POSDictionary) {
POSDictionary posDict = (POSDictionary) tagdictEntry;
Set<String> dictTags = new HashSet<String>();
for (String word : posDict) {
Collections.addAll(dictTags, posDict.getTags(word));
}
Set<String> modelTags = new HashSet<String>();
AbstractModel posModel = getPosModel();
for (int i = 0; i < posModel.getNumOutcomes(); i++) {
modelTags.add(posModel.getOutcome(i));
}
if (!modelTags.containsAll(dictTags)) {
throw new InvalidFormatException("Tag dictioinary contains tags " +
"which are unkown by the model!");
}
}
else {
throw new InvalidFormatException("Abbreviations dictionary has wrong type!");
}
}
Object ngramDictEntry = artifactMap.get(NGRAM_DICTIONARY_ENTRY_NAME);
if (ngramDictEntry != null && !(ngramDictEntry instanceof Dictionary)) {
throw new InvalidFormatException("NGram dictionary has wrong type!");
}
}