Refactoring: simplify exchangeable Clustering(Algorithm) structure

parent 74c87baf
Pipeline #84567 failed with stage
in 43 seconds
package de.monticore.lang.monticar.generator.middleware.clustering;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import java.util.List;
import java.util.Set;
// creator if for clusterer factory
public abstract class Clusterer {
public List<Set<ExpandedComponentInstanceSymbol>> createClusters(ExpandedComponentInstanceSymbol component, int numberOfClusters) {
ClusteringAlgorithm clusteringAlgorithm = getClusteringAlgorithm();
return clusteringAlgorithm.cluster(component, numberOfClusters);
}
public abstract ClusteringAlgorithm getClusteringAlgorithm();
}
package de.monticore.lang.monticar.generator.middleware.clustering;
// creator for spectral clusterer
public class SpectralClusterer extends Clusterer {
@Override
public ClusteringAlgorithm getClusteringAlgorithm() {
return new SpectralClusteringAlgorithm();
}
}
package de.monticore.lang.monticar.generator.middleware.clustering;
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
......
package de.monticore.lang.monticar.generator.middleware.clustering;
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.clustering.algorithms.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
import smile.clustering.SpectralClustering;
......
......@@ -3,8 +3,8 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.algorithms.SpectralClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.SpectralClusterer;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
......@@ -98,8 +98,8 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("clustering.unambiguousCluster", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
SpectralClusterer spectralClusterer = new SpectralClusterer();
List<Set<ExpandedComponentInstanceSymbol>> clusters = spectralClusterer.createClusters(componentInstanceSymbol, 2);
SpectralClusteringAlgorithm spectralClusteringAlgorithm = new SpectralClusteringAlgorithm();
List<Set<ExpandedComponentInstanceSymbol>> clusters = spectralClusteringAlgorithm.cluster(componentInstanceSymbol, 2);
assertTrue(clusters.size() == 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment