avoid exception if there is only one extension in the whole archive

git-svn-id: http://google-refine.googlecode.com/svn/trunk@385 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-05 21:36:27 +00:00
parent 9dfdd1e351
commit 771810bc0d

View File

@ -228,6 +228,9 @@ public class CreateProjectCommand extends Command {
HashSet<String> exts = new HashSet<String>(); HashSet<String> exts = new HashSet<String>();
// find the extension that is most frequent or those who share the highest frequency value // find the extension that is most frequent or those who share the highest frequency value
if (values.size() == 1) {
exts.add(values.get(0).getKey());
} else {
Entry<String,Integer> most_frequent = values.get(0); Entry<String,Integer> most_frequent = values.get(0);
Entry<String,Integer> second_most_frequent = values.get(1); Entry<String,Integer> second_most_frequent = values.get(1);
if (most_frequent.getValue() > second_most_frequent.getValue()) { // we have a winner if (most_frequent.getValue() > second_most_frequent.getValue()) { // we have a winner
@ -240,6 +243,7 @@ public class CreateProjectCommand extends Command {
} }
} }
} }
}
Gridworks.log("Most frequent extensions: " + exts.toString()); Gridworks.log("Most frequent extensions: " + exts.toString());
// second pass, load the data for real // second pass, load the data for real