Corrections on Data Guesser

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@85755 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2013-11-20 11:49:26 +00:00
parent 467d2074dc
commit 5764304911
1 changed files with 28 additions and 5 deletions

View File

@ -69,8 +69,12 @@ public class DataTypeRecognizer {
return false;
}
public static String guessType(ArrayList<String> elementlist) {
return guessType(elementlist,true);
}
public static String guessType(ArrayList<String> elementlist, boolean restricted) {
// 0 = String 1 = Boolean 2 = Decimal
int[] scores = new int[3];
@ -94,7 +98,18 @@ public class DataTypeRecognizer {
maxindex = i;
}
}
//restricted mode
if (restricted){
if (scores[0]>0)
maxindex=0;
else if ((scores[1]>0)&&(scores[2]==0))
maxindex=1;
else if ((scores[1]==0)&&(scores[2]>0))
maxindex=2;
else
maxindex=0;
}
// System.out.println("index " + maxindex + " max " + max);
String type = types[maxindex];
@ -105,10 +120,18 @@ public class DataTypeRecognizer {
public static void main(String[] args) throws ClassNotFoundException {
ArrayList<String> prova = new ArrayList<String>();
for (int i = 0; i < 5; i++) {
prova.add("1234");
/*
String[] elementsToGuess =
{"65952", "51809", "RUSI 600", "RUSI 9981", "USNM 00163126", "MNHN 1989-0806", "RUSI 57071", "BMNH 1939.7.4.1-3",
"22082", "8863", "65410", "76194", "76196"};
*/
String[] elementsToGuess = {"65952", "51809", "22082", "8863", "65410", "76194", "76196"};
for (int i = 0; i < elementsToGuess.length; i++) {
prova.add(elementsToGuess[i]);
}
String classtype = guessType(prova);
System.out.println(classtype);