Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
InqWi committed Apr 23, 2011
1 parent ec0c2d3 commit cc25421
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Jlibiada.iml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<orderEntry type="library" name="HMM" level="project" />
<orderEntry type="library" name="Rapidminer" level="project" />
<orderEntry type="library" name="BioJava" level="project" />
<orderEntry type="library" name="Bio" level="project" />
</component>
</module>

4 changes: 4 additions & 0 deletions resources/com/rapidminer/resources/OperatorsHMM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<class>interval_analysis.chain.BuildingsGeneratorRM</class>
</operator>
</group>
<operator>
<key>Buildings counter</key>
<class>interval_analysis.chain.RMBuildingCounter</class>
</operator>
<operator>
<key>Mixed_converter</key>
<class>interval_analysis.chain.MixedConverterRM</class>
Expand Down
58 changes: 52 additions & 6 deletions src/interval_analysis/chain/RMBuildingCounter.java
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;
}
}

0 comments on commit cc25421

Please sign in to comment.