protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
modelTags.add(posModel.getOutcome(i));
modelTags.add(posModel.getOutcome(i));