Skip to content

Commit

Permalink
compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnaber committed Jun 15, 2015
1 parent ca661d0 commit ca03480
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -31,10 +31,7 @@
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.Objects;
import java.util.Set;


/** /**
* Dump the occurrences of homophone 3grams to STDOUT. Useful to have a more * Dump the occurrences of homophone 3grams to STDOUT. Useful to have a more
Expand Down Expand Up @@ -83,7 +80,7 @@ private void run(String confusionSetPath) throws IOException {
System.err.println("Loading confusion sets from " + confusionSetPath + ", minimum occurrence: " + MIN_COUNT); System.err.println("Loading confusion sets from " + confusionSetPath + ", minimum occurrence: " + MIN_COUNT);
ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader(); ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader();
InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(confusionSetPath); InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(confusionSetPath);
Map<String,ConfusionSet> map = confusionSetLoader.loadConfusionSet(inputStream); Map<String,List<ConfusionSet>> map = confusionSetLoader.loadConfusionSet(inputStream);
Set<String> confusionTerms = map.keySet(); Set<String> confusionTerms = map.keySet();
dumpOccurrences(confusionTerms); dumpOccurrences(confusionTerms);
} }
Expand Down
Expand Up @@ -56,21 +56,24 @@ public RuleCreator(float minErrorProb) {
private void run(File homophoneOccurrences, String homophonePath) throws IOException { private void run(File homophoneOccurrences, String homophonePath) throws IOException {
ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader(); ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader();
InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(homophonePath); InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(homophonePath);
Map<String,ConfusionSet> confusionSetMap = confusionSetLoader.loadConfusionSet(inputStream); Map<String,List<ConfusionSet>> confusionSetMap = confusionSetLoader.loadConfusionSet(inputStream);
initMaps(homophoneOccurrences); initMaps(homophoneOccurrences);
int groupCount = 0; int groupCount = 0;
if (XML_MODE) { if (XML_MODE) {
System.out.println("<rules lang='en'>\n"); System.out.println("<rules lang='en'>\n");
System.out.println("<category name='Auto-generated rules'>\n"); System.out.println("<category name='Auto-generated rules'>\n");
} }
for (Map.Entry<String, ConfusionSet> entry : confusionSetMap.entrySet()) { for (Map.Entry<String, List<ConfusionSet>> entry : confusionSetMap.entrySet()) {
System.err.println(" === " + entry + " === "); System.err.println(" === " + entry + " === ");
if (entry.getValue().size() > 1) {
System.err.println("WARN: will use only first pair of " + entry.getValue().size() + ": " + entry.getValue().get(0));
}
List<OccurrenceInfo> infos = occurrenceInfos.get(entry.getKey()); List<OccurrenceInfo> infos = occurrenceInfos.get(entry.getKey());
if (infos == null) { if (infos == null) {
System.err.println("Could not find occurrence infos for '" + entry.getKey() + "', skipping"); System.err.println("Could not find occurrence infos for '" + entry.getKey() + "', skipping");
continue; continue;
} }
Set cleanSet = new HashSet<>(entry.getValue().getSet()); Set cleanSet = new HashSet<>(entry.getValue().get(0).getSet());
cleanSet.remove(entry.getKey()); cleanSet.remove(entry.getKey());
String name = StringUtils.join(cleanSet, "/") + " -> " + entry.getKey(); String name = StringUtils.join(cleanSet, "/") + " -> " + entry.getKey();
if (XML_MODE) { if (XML_MODE) {
Expand All @@ -79,7 +82,7 @@ private void run(File homophoneOccurrences, String homophonePath) throws IOExcep
groupCount++; groupCount++;
for (OccurrenceInfo occurrenceInfo : infos) { for (OccurrenceInfo occurrenceInfo : infos) {
String[] parts = occurrenceInfo.ngram.split(" "); String[] parts = occurrenceInfo.ngram.split(" ");
for (ConfusionString variant : entry.getValue().getSet()) { for (ConfusionString variant : entry.getValue().get(0).getSet()) {
if (variant.getString().equals(entry.getKey())) { if (variant.getString().equals(entry.getKey())) {
continue; continue;
} }
Expand Down

0 comments on commit ca03480

Please sign in to comment.