/** * Returns a map with the score as a key in ascending order. * The value is a Set of categories with the score. * Many categories can have the same score, hence the Set as value * * @param text the input text to classify * @return the sorted score map */ @Override public SortedMap<Double, Set<String>> sortedScoreMap(String[] text) { SortedMap<Double, Set<String>> descendingMap = new TreeMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); double score = categorize[getIndex(category)]; if (descendingMap.containsKey(score)) { descendingMap.get(score).add(category); } else { Set<String> newset = new HashSet<>(); newset.add(category); descendingMap.put(score, newset); } } return descendingMap; }
/** * Returns a map in which the key is the category name and the value is the score * * @param text the input text to classify * @return the score map */ @Override public Map<String, Double> scoreMap(String[] text) { Map<String, Double> probDist = new HashMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); probDist.put(category, categorize[getIndex(category)]); } return probDist; }
/** * Returns a map with the score as a key in ascending order. * The value is a Set of categories with the score. * Many categories can have the same score, hence the Set as value * * @param text the input text to classify * @return the sorted score map */ @Override public SortedMap<Double, Set<String>> sortedScoreMap(String[] text) { SortedMap<Double, Set<String>> descendingMap = new TreeMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); double score = categorize[getIndex(category)]; if (descendingMap.containsKey(score)) { descendingMap.get(score).add(category); } else { Set<String> newset = new HashSet<>(); newset.add(category); descendingMap.put(score, newset); } } return descendingMap; }
/** * Returns a map with the score as a key in ascending order. * The value is a Set of categories with the score. * Many categories can have the same score, hence the Set as value * * @param text the input text to classify * @return the sorted score map */ @Override public SortedMap<Double, Set<String>> sortedScoreMap(String[] text) { SortedMap<Double, Set<String>> descendingMap = new TreeMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); double score = categorize[getIndex(category)]; if (descendingMap.containsKey(score)) { descendingMap.get(score).add(category); } else { Set<String> newset = new HashSet<>(); newset.add(category); descendingMap.put(score, newset); } } return descendingMap; }
/** * Returns a map in which the key is the category name and the value is the score * * @param text the input text to classify * @return the score map */ @Override public Map<String, Double> scoreMap(String[] text) { Map<String, Double> probDist = new HashMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); probDist.put(category, categorize[getIndex(category)]); } return probDist; }
/** * Returns a map in which the key is the category name and the value is the score * * @param text the input text to classify * @return the score map */ @Override public Map<String, Double> scoreMap(String[] text) { Map<String, Double> probDist = new HashMap<>(); double[] categorize = categorize(text); int catSize = getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = getCategory(i); probDist.put(category, categorize[getIndex(category)]); } return probDist; }
int catSize = documentCategorizerME.getNumberOfCategories(); for (int i = 0; i < catSize; i++) { String category = documentCategorizerME.getCategory(i); probDist.put(category, categorize[documentCategorizerME.getIndex(category)]);