-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,76 @@ | ||
package interval_analysis.chain; | ||
|
||
import com.rapidminer.example.Attributes; | ||
import com.rapidminer.example.Example; | ||
import com.rapidminer.example.ExampleSet; | ||
import com.rapidminer.example.ExampleSetFactory; | ||
import com.rapidminer.operator.Operator; | ||
import com.rapidminer.operator.OperatorDescription; | ||
import com.rapidminer.operator.OperatorException; | ||
import com.rapidminer.operator.ports.InputPort; | ||
import com.rapidminer.operator.ports.OutputPort; | ||
import com.rapidminer.parameter.ParameterType; | ||
import com.rapidminer.parameter.ParameterTypeString; | ||
import libiada.IntervalAnalysis.Buildings.BuildingCounter; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: InquisitioN | ||
* Date: 26.03.2011 | ||
* Time: 15:58:12 | ||
* Date: 22.04.2011 | ||
* Time: 19:28:54 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
public class RMBuildingCounter extends Operator { | ||
private OutputPort outValue = getOutputPorts().createPort("Items"); | ||
private InputPort inChainLeight = getInputPorts().createPort("Leight"); | ||
private InputPort inChainPower = getInputPorts().createPort("Power"); | ||
private InputPort inChainData = getInputPorts().createPort("InputData"); | ||
|
||
public static final String PARAMETER_CHAIN_LENGTH = "ChainLength attribute name"; | ||
public static final String PARAMETER_ALPHABET_POWER = "AlphabetPower attribute name"; | ||
|
||
public RMBuildingCounter(OperatorDescription description) { | ||
super(description); | ||
} | ||
|
||
@Override | ||
public void doWork() throws OperatorException { | ||
RMChainSet Leight = inChainLeight.getData(RMChainSet.class); | ||
RMChainSet Power = inChainPower.getData(RMChainSet.class); | ||
ExampleSet ChainData = inChainData.getData(); | ||
Attributes attributes = ChainData.getAttributes(); | ||
|
||
String data[][]=new String [ChainData.size()][3]; | ||
int item = 0; | ||
for (Example example : ChainData) { | ||
Double L = Double.parseDouble(example.getValueAsString(attributes.get(getParameterAsString(PARAMETER_CHAIN_LENGTH)))); | ||
Double P = Double.parseDouble(example.getValueAsString(attributes.get(getParameterAsString(PARAMETER_ALPHABET_POWER)))); | ||
|
||
BuildingCounter counter = new BuildingCounter(); | ||
Integer count = 0; | ||
try { | ||
count = counter.calculate((int) Math.round(L), (int) Math.round(P)); | ||
} catch (Exception e) { | ||
System.err.print("Error of calculating"); | ||
} | ||
|
||
data[item][0] = L.toString(); | ||
data[item][1] = P.toString(); | ||
data[item][3] = count.toString(); | ||
item++; | ||
} | ||
ExampleSet outValueSet = ExampleSetFactory.createExampleSet(data); | ||
outValueSet.getAttributes().get("att1").setName("Chain length"); | ||
outValueSet.getAttributes().get("att2").setName("Alphabet power"); | ||
outValueSet.getAttributes().get("att3").setName("Count"); | ||
outValue.deliver(outValueSet); | ||
} | ||
|
||
@Override | ||
public List<ParameterType> getParameterTypes() { | ||
List<ParameterType> types = super.getParameterTypes(); | ||
types.add(new ParameterTypeString(PARAMETER_CHAIN_LENGTH, "ChainLength attribute name")); | ||
types.add(new ParameterTypeString(PARAMETER_ALPHABET_POWER, "AlphabetPower attribute name")); | ||
return types; | ||
} | ||
} |