git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@91563 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
118855a4f8
commit
69222243b3
|
@ -45,6 +45,7 @@ public class AlgorithmConfiguration extends LexicalEngineConfiguration implement
|
|||
public static String evaluatorsFile = "evaluators.properties";
|
||||
public static String clusterersFile = "clusterers.properties";
|
||||
public static String transducererFile = "transducerers.properties";
|
||||
public static String dynamicTransducerersFile = "dynamictransducerers.properties";
|
||||
public static String userperspectiveFile = "userperspective.properties";
|
||||
public static String RapidMinerOperatorsFile = "operators.xml";
|
||||
public static String StatisticalManagerService = "StatisticalManager";
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.dataanalysis.ecoengine.interfaces;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||
|
||||
public interface DynamicTransducer {
|
||||
|
||||
|
||||
public Map<String,Transducerer> getTransducers(AlgorithmConfiguration config);
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package org.gcube.dataanalysis.ecoengine.processing.factories;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.DynamicTransducer;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.Transducerer;
|
||||
|
||||
public class DynamicTransducerersFactory {
|
||||
|
||||
|
||||
public DynamicTransducerersFactory (){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Transducerer getTransducerer(AlgorithmConfiguration config) throws Exception {
|
||||
String agent = config.getAgent();
|
||||
Map<String,Transducerer> subTransducerers = getAllSubTransducerers(config);
|
||||
Transducerer trans = subTransducerers.get(agent);
|
||||
return trans;
|
||||
}
|
||||
|
||||
public static List<String> getTransducerersNames(AlgorithmConfiguration config) throws Exception {
|
||||
|
||||
Map<String,Transducerer> subTransducerers = getAllSubTransducerers(config);
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (String key:subTransducerers.keySet()){
|
||||
names.add(key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static List<String> getAllDynamicTransducerers(AlgorithmConfiguration config) throws Exception {
|
||||
List<String> trans = ProcessorsFactory.getClasses(config.getConfigPath() + AlgorithmConfiguration.dynamicTransducerersFile);
|
||||
return trans;
|
||||
}
|
||||
|
||||
public static Map<String,Transducerer> getAllSubTransducerers(AlgorithmConfiguration config) throws Exception {
|
||||
List<String> dynatransducers = getAllDynamicTransducerers(config);
|
||||
Map<String,Transducerer> transducerList = new LinkedHashMap<String,Transducerer>();
|
||||
for (String dynatransducer:dynatransducers){
|
||||
Object algclass = Class.forName(dynatransducer).newInstance();
|
||||
String prefix = dynatransducer;
|
||||
if (dynatransducer.length()>3)
|
||||
prefix = dynatransducer.substring(0,3);
|
||||
DynamicTransducer g = (DynamicTransducer) algclass;
|
||||
Map<String,Transducerer> subtrans = g.getTransducers(config);
|
||||
if (subtrans!=null){
|
||||
for (String stransK:subtrans.keySet()){
|
||||
Transducerer t = subtrans.get(stransK);
|
||||
t.setConfiguration(config);
|
||||
transducerList.put(prefix+"."+stransK,t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return transducerList;
|
||||
}
|
||||
|
||||
public static List<StatisticalType> getTransducerParameters(String configPath, String algorithmName) throws Exception {
|
||||
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.transducererFile, algorithmName);
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public static String getDescription(AlgorithmConfiguration config, String algorithmName) throws Exception{
|
||||
Map<String,Transducerer> subTransducerers = getAllSubTransducerers(config);
|
||||
Transducerer tr = subTransducerers.get(algorithmName);
|
||||
if (tr != null)
|
||||
return tr.getDescription();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -50,6 +50,7 @@ public class ProcessorsFactory {
|
|||
|
||||
Properties p = AlgorithmConfiguration.getProperties(file);
|
||||
String algorithmclass = p.getProperty(algorithmName);
|
||||
if (algorithmclass==null) return null;
|
||||
Object algclass = Class.forName(algorithmclass).newInstance();
|
||||
// if the algorithm is a generator itself then take it
|
||||
if (algclass instanceof Generator) {
|
||||
|
@ -77,6 +78,7 @@ public class ProcessorsFactory {
|
|||
|
||||
Properties p = AlgorithmConfiguration.getProperties(file);
|
||||
String algorithmclass = p.getProperty(algorithmName);
|
||||
if (algorithmclass==null) return null;
|
||||
Object algclass = Class.forName(algorithmclass).newInstance();
|
||||
// if the algorithm is a generator itself then take it
|
||||
if (algclass instanceof Generator) {
|
||||
|
@ -154,22 +156,22 @@ public class ProcessorsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
public static HashMap<String,List<String>> getAllFeatures(String configPath) throws Exception{
|
||||
public static HashMap<String,List<String>> getAllFeatures(AlgorithmConfiguration config) throws Exception{
|
||||
HashMap<String,List<String>> map = new HashMap<String, List<String>>();
|
||||
|
||||
map.put("DISTRIBUTIONS", GeneratorsFactory.getProbabilityDistributionAlgorithms(configPath));
|
||||
map.put("MODELS", ModelersFactory.getModels(configPath));
|
||||
map.put("EVALUATORS", EvaluatorsFactory.getAllEvaluators(configPath));
|
||||
map.put("CLUSTERERS", ClusterersFactory.getAllClusterers(configPath));
|
||||
map.put("TRANSDUCERS", TransducerersFactory.getAllTransducerers(configPath));
|
||||
map.put("DISTRIBUTIONS", GeneratorsFactory.getProbabilityDistributionAlgorithms(config.getConfigPath()));
|
||||
map.put("MODELS", ModelersFactory.getModels(config.getConfigPath()));
|
||||
map.put("EVALUATORS", EvaluatorsFactory.getAllEvaluators(config.getConfigPath()));
|
||||
map.put("CLUSTERERS", ClusterersFactory.getAllClusterers(config.getConfigPath()));
|
||||
map.put("TRANSDUCERS", TransducerersFactory.getAllTransducerers(config));
|
||||
map.put("TEMPORAL_ANALYSIS", new ArrayList<String>());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static HashMap<String,List<String>> getAllFeaturesUser(String configPath) throws Exception{
|
||||
public static HashMap<String,List<String>> getAllFeaturesUser(AlgorithmConfiguration config) throws Exception{
|
||||
|
||||
BufferedReader br = new BufferedReader(new FileReader(new File(configPath,AlgorithmConfiguration.userperspectiveFile)));
|
||||
BufferedReader br = new BufferedReader(new FileReader(new File(config.getConfigPath(),AlgorithmConfiguration.userperspectiveFile)));
|
||||
LinkedHashMap<String,List<String>> map = new LinkedHashMap<String, List<String>>();
|
||||
String line = br.readLine();
|
||||
while (line!=null){
|
||||
|
@ -181,6 +183,11 @@ public class ProcessorsFactory {
|
|||
map.put(key, list);
|
||||
line = br.readLine();
|
||||
}
|
||||
|
||||
List<String> externalAlgorithms = DynamicTransducerersFactory.getTransducerersNames(config);
|
||||
if (externalAlgorithms!=null && externalAlgorithms.size()>0)
|
||||
map.put("EXTERNAL", externalAlgorithms);
|
||||
|
||||
br.close();
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -9,36 +9,55 @@ import org.gcube.dataanalysis.ecoengine.interfaces.ComputationalAgent;
|
|||
import org.gcube.dataanalysis.ecoengine.interfaces.Transducerer;
|
||||
|
||||
public class TransducerersFactory {
|
||||
|
||||
public TransducerersFactory (){
|
||||
|
||||
}
|
||||
|
||||
public static Transducerer getTransducerer(AlgorithmConfiguration config) throws Exception {
|
||||
Transducerer tran = (Transducerer) ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.transducererFile);
|
||||
return tran;
|
||||
|
||||
public TransducerersFactory() {
|
||||
|
||||
}
|
||||
|
||||
public static List<String> getAllTransducerers(String configPath) throws Exception {
|
||||
List<String> trans = ProcessorsFactory.getClasses(configPath + AlgorithmConfiguration.transducererFile);
|
||||
public static Transducerer getTransducerer(AlgorithmConfiguration config) throws Exception {
|
||||
ComputationalAgent ca = ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.transducererFile);
|
||||
if (ca != null){
|
||||
ca.setConfiguration(config);
|
||||
return (Transducerer) ca;
|
||||
}
|
||||
else
|
||||
return DynamicTransducerersFactory.getTransducerer(config);
|
||||
}
|
||||
|
||||
public static List<String> getAllTransducerers(AlgorithmConfiguration config) throws Exception {
|
||||
List<String> trans = ProcessorsFactory.getClasses(config.getConfigPath() + AlgorithmConfiguration.transducererFile);
|
||||
List<String> dtrans = DynamicTransducerersFactory.getTransducerersNames(config);
|
||||
trans.addAll(dtrans);
|
||||
return trans;
|
||||
}
|
||||
|
||||
public static List<StatisticalType> getTransducerParameters(String configPath, String algorithmName) throws Exception {
|
||||
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.transducererFile, algorithmName);
|
||||
return inputs;
|
||||
public static List<StatisticalType> getTransducerParameters(AlgorithmConfiguration config, String algorithmName) throws Exception {
|
||||
List<StatisticalType> inputs = ProcessorsFactory.getParameters(config.getConfigPath() + AlgorithmConfiguration.transducererFile, algorithmName);
|
||||
if (inputs != null)
|
||||
return inputs;
|
||||
else {
|
||||
inputs = DynamicTransducerersFactory.getTransducerer(config).getInputParameters();
|
||||
return inputs;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDescription(String configPath, String algorithmName) throws Exception{
|
||||
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.transducererFile, algorithmName);
|
||||
return input;
|
||||
public static String getDescription(AlgorithmConfiguration config, String algorithmName) throws Exception {
|
||||
String input = ProcessorsFactory.getDescription(config.getConfigPath()+ AlgorithmConfiguration.transducererFile, algorithmName);
|
||||
if (input!=null)
|
||||
return input;
|
||||
else{
|
||||
input = DynamicTransducerersFactory.getTransducerer(config).getDescription();
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<ComputationalAgent> getTransducerers(AlgorithmConfiguration config) throws Exception {
|
||||
List<ComputationalAgent> trans = new ArrayList<ComputationalAgent>();
|
||||
trans.add(getTransducerer(config));
|
||||
ProcessorsFactory.addAgent2List(trans,GeneratorsFactory.getGenerator(config));
|
||||
|
||||
ProcessorsFactory.addAgent2List(trans, GeneratorsFactory.getGenerator(config));
|
||||
Transducerer dynamicTransducer = DynamicTransducerersFactory.getTransducerer(config);
|
||||
if (dynamicTransducer!=null)
|
||||
trans.add(dynamicTransducer);
|
||||
return trans;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.ComputationalAgent;
|
||||
|
@ -67,7 +68,9 @@ public static void main(String[] args) throws Exception {
|
|||
System.out.println("Database Default Values: "+eval);
|
||||
|
||||
System.out.println("\n***TEST 12- Get All Supported features***");
|
||||
HashMap<String,List<String>> features = ProcessorsFactory.getAllFeatures("./cfg/");
|
||||
AlgorithmConfiguration config = new AlgorithmConfiguration();
|
||||
config.setConfigPath("./cfg/");
|
||||
HashMap<String,List<String>> features = ProcessorsFactory.getAllFeatures(config);
|
||||
System.out.println("Database Default Values: "+features);
|
||||
|
||||
System.out.println("\n***TEST 13- Get All Clusterers***");
|
||||
|
@ -82,10 +85,10 @@ public static void main(String[] args) throws Exception {
|
|||
// System.out.println("Clusterers list: "+clus);
|
||||
|
||||
System.out.println("\n***TEST 16- Get All Transducerers***");
|
||||
System.out.println("All Transducers: "+TransducerersFactory.getAllTransducerers("./cfg/"));
|
||||
System.out.println("All Transducers: "+TransducerersFactory.getAllTransducerers(config));
|
||||
|
||||
System.out.println("\n***TEST 17- Get Transducerers Parameters ***");
|
||||
map = TransducerersFactory.getTransducerParameters("./cfg/","BIOCLIMATE_HSPEC");
|
||||
map = TransducerersFactory.getTransducerParameters(config,"BIOCLIMATE_HSPEC");
|
||||
System.out.println("Transducerers Params: "+map);
|
||||
|
||||
System.out.println("\n***TEST 18- Get Transducerers with a config***");
|
||||
|
@ -98,7 +101,7 @@ public static void main(String[] args) throws Exception {
|
|||
System.out.println("DESCRIPTION: "+desc);
|
||||
|
||||
System.out.println("\n***TEST 20- Get USER perspective***");
|
||||
Map m = ProcessorsFactory.getAllFeaturesUser("./cfg/");
|
||||
Map m = ProcessorsFactory.getAllFeaturesUser(config);
|
||||
System.out.println("USER PERSPECTIVE: "+m);
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception {
|
|||
Regressor.process(trans.get(0));
|
||||
trans = null;
|
||||
*/
|
||||
trans = TransducerersFactory.getTransducerers(testConfigLocal7());
|
||||
trans = TransducerersFactory.getTransducerers(testConfigLocal5());
|
||||
trans.get(0).init();
|
||||
Regressor.process(trans.get(0));
|
||||
trans = null;
|
||||
|
@ -56,8 +56,8 @@ public static void main(String[] args) throws Exception {
|
|||
|
||||
AlgorithmConfiguration config = Regressor.getConfig();
|
||||
config.setAgent("BIOCLIMATE_HSPEC");
|
||||
config.setParam("HSPEC_TABLE_LIST", "hspec_validation"+AlgorithmConfiguration.getListSeparator()+"hspec_validation2");
|
||||
config.setParam("HSPEC_TABLE_NAMES", "test"+AlgorithmConfiguration.getListSeparator()+"test");
|
||||
config.setParam("HSPEC_Table_List", "hspec_validation"+AlgorithmConfiguration.getListSeparator()+"hspec_validation2");
|
||||
config.setParam("HSPEC_Table_Names", "test"+AlgorithmConfiguration.getListSeparator()+"test");
|
||||
config.setParam("Threshold", "0.5");
|
||||
|
||||
return config;
|
||||
|
|
Loading…
Reference in New Issue