From 57643049115be87f7cf41e32656cf94657509c03 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Wed, 20 Nov 2013 11:49:26 +0000 Subject: [PATCH] Corrections on Data Guesser git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@85755 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../analysis/core/DataTypeRecognizer.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/contentmanagement/lexicalmatcher/analysis/core/DataTypeRecognizer.java b/src/main/java/org/gcube/contentmanagement/lexicalmatcher/analysis/core/DataTypeRecognizer.java index bad6828..d458648 100644 --- a/src/main/java/org/gcube/contentmanagement/lexicalmatcher/analysis/core/DataTypeRecognizer.java +++ b/src/main/java/org/gcube/contentmanagement/lexicalmatcher/analysis/core/DataTypeRecognizer.java @@ -69,8 +69,12 @@ public class DataTypeRecognizer { return false; } - + public static String guessType(ArrayList elementlist) { + return guessType(elementlist,true); + } + + public static String guessType(ArrayList 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 prova = new ArrayList(); - 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);