Package uk.org.ogsadai.activity

Examples of uk.org.ogsadai.activity.MockInputPipe


{
    @Test
    public void testSimple() throws Exception
    {
       
        MockInputPipe inputTemplate = new MockInputPipe("Hello $REPLACE(A)$, hello $REPLACE(B)$!");
       
        ColumnMetadata colA = new SimpleColumnMetadata("A", TupleTypes._STRING, 0, 0, 0);
        ColumnMetadata colB = new SimpleColumnMetadata("B", TupleTypes._DOUBLE, 0, 0, 0);
        TupleMetadata metadata = new SimpleTupleMetadata(Arrays.asList(colA, colB));
        Tuple tuple1 = new SimpleTuple(Arrays.<Object>asList("Amy", 0));
        Tuple tuple2 = new SimpleTuple(Arrays.<Object>asList("Ally", 1.0));
        Tuple tuple3 = new SimpleTuple(Arrays.<Object>asList("Radek", 2.0));
        MockInputPipe inputData = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                new MetadataWrapper(metadata),
                tuple1, tuple2, tuple3,
                ControlBlock.LIST_END
        });
View Full Code Here


        properties.put(
                BuildClassifierActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.M5P");
        activity.configureActivity(properties);

        MockInputPipe dataInput = new MockInputPipe(table.toArray());
        activity.addInput(BuildClassifierActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {0});
        activity.addInput(BuildClassifierActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe optionsInput = new MockInputPipe(new Object[] {" "});
        activity.addInput(BuildClassifierActivity.INPUT_OPTIONS, optionsInput);

        MockInputPipe nominalColumnsInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierActivity.INPUT_COLUMN_INDICES, nominalColumnsInput);

        MockInputPipe nominalValuesInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nominalValuesInput);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierActivity.CLASSIFIER_OUTPUT, output);
       
        activity.process();
       
        TupleClassifier classifier = (TupleClassifier)output.getActualBlocks().get(0);
       
        ClassifyActivity classify = new ClassifyActivity();
        MockInputPipe inputClassifier = new MockInputPipe(classifier);
        classify.addInput(ClassifyActivity.INPUT_CLASSIFIER, inputClassifier);

        MockInputPipe inputData = new MockInputPipe(table.toArray());
        classify.addInput(ClassifyActivity.INPUT_DATA, inputData);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
View Full Code Here

   
    @Test
    public void testUnknownColumn() throws Exception
    {
       
        MockInputPipe inputTemplate = new MockInputPipe("Hello $REPLACE(A)$, hello $REPLACE(B)$!");
       
        ColumnMetadata colA = new SimpleColumnMetadata("A", TupleTypes._STRING, 0, 0, 0);
        TupleMetadata metadata = new SimpleTupleMetadata(Arrays.asList(colA));
        Tuple tuple1 = new SimpleTuple(Arrays.<Object>asList("Amy", 0));
        Tuple tuple2 = new SimpleTuple(Arrays.<Object>asList("Ally", 1.0));
        Tuple tuple3 = new SimpleTuple(Arrays.<Object>asList("Radek", 2.0));
        MockInputPipe inputData = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                new MetadataWrapper(metadata),
                tuple1, tuple2, tuple3,
                ControlBlock.LIST_END
        });
View Full Code Here

        properties.put(
                BuildClassifierActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        MockInputPipe dataInput = new MockInputPipe(new Object[] {});
        activity.addInput(BuildClassifierActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe colIndicesInput = new MockInputPipe(new Object[] {});
        activity.addInput(BuildClassifierActivity.INPUT_COLUMN_INDICES, colIndicesInput);

        MockInputPipe nomValInput = new MockInputPipe(new Object[] {});
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nomValInput);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierActivity.CLASSIFIER_OUTPUT, output);
       
View Full Code Here

                BuildClassifierActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        List<Object> table = buildInputTable();
        MockInputPipe dataInput = new MockInputPipe(table.toArray());
        activity.addInput(BuildClassifierActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe colIndicesInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "X", ControlBlock.LIST_END });
        activity.addInput(BuildClassifierActivity.INPUT_COLUMN_INDICES, colIndicesInput);

        MockInputPipe nomValInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                ControlBlock.LIST_BEGIN, "sunny", "overcast", "rain",
                ControlBlock.LIST_END,
                ControlBlock.LIST_END
        });
View Full Code Here

                BuildClassifierActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        List<Object> table = buildInputTable();
        MockInputPipe dataInput = new MockInputPipe(table.toArray());
        activity.addInput(BuildClassifierActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe colIndicesInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, 25, ControlBlock.LIST_END });
        activity.addInput(BuildClassifierActivity.INPUT_COLUMN_INDICES, colIndicesInput);

        MockInputPipe nomValInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                ControlBlock.LIST_BEGIN, "sunny", "overcast", "rain",
                ControlBlock.LIST_END,
                ControlBlock.LIST_END
        });
View Full Code Here

                BuildClassifierActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        List<Object> table = buildInputTable();
        MockInputPipe dataInput = new MockInputPipe(table.toArray());
        activity.addInput(BuildClassifierActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe colIndicesInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, 0, ControlBlock.LIST_END });
        activity.addInput(BuildClassifierActivity.INPUT_COLUMN_INDICES, colIndicesInput);

        MockInputPipe nomValInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                ControlBlock.LIST_BEGIN
        });
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nomValInput);
View Full Code Here

        {
            "A test string",
            "Some other test string",
            new SimpleTuple(Arrays.asList(1, 2, 3, 4, 5))
        };
        MockInputPipe input = new MockInputPipe(data);
        serialiser.addInput(SerialiserActivity.INPUT_DATA, input);
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        serialiser.addOutput(SerialiserActivity.OUTPUT_RESULT, output);
        serialiser.process();
        MockInputPipe input2 = new MockInputPipe(output.getActualBlocks().toArray());
        DeserialiserActivity deserialiser = new DeserialiserActivity();
        deserialiser.addInput(DeserialiserActivity.INPUT_DATA, input2);
        MockOutputPipe output2 = new MockOutputPipe(data);
        deserialiser.addOutput(DeserialiserActivity.OUTPUT_RESULT, output2);
        deserialiser.process();
View Full Code Here

        for (int i=0; i<1000; i++)
        {
            buf.append("Test").append(i);
        }
        Object[] data = { buf.toString() };
        MockInputPipe input = new MockInputPipe(data);
        serialiser.addInput(SerialiserActivity.INPUT_DATA, input);
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        serialiser.addOutput(SerialiserActivity.OUTPUT_RESULT, output);
        serialiser.process();
        MockInputPipe input2 = new MockInputPipe(output.getActualBlocks().toArray());
        DeserialiserActivity deserialiser = new DeserialiserActivity();
        deserialiser.addInput(DeserialiserActivity.INPUT_DATA, input2);
        MockOutputPipe output2 = new MockOutputPipe(data);
        deserialiser.addOutput(DeserialiserActivity.OUTPUT_RESULT, output2);
        deserialiser.process();
View Full Code Here

        FilterActivity activity = new FilterActivity();
       
        Tuple tuple1 = createTuple(new Object[] {1, 3});
        Tuple tuple2 = createTuple(new Object[] {4, 5});
        Tuple tuple3 = createTuple(new Object[] {10, 100});
        MockInputPipe dataInput = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        createTupleMetadata(),
                        tuple1,
                        createTuple(new Object[] {5, 1}),
                        tuple2,
                        createTuple(new Object[] {6, -5}),
                        tuple3,
                        ControlBlock.LIST_END });
        MockInputPipe expressionInput = new MockInputPipe("X < Y");
        activity.addInput("data", dataInput);
        activity.addInput("expression", expressionInput);
       
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput("output", output);
View Full Code Here

TOP

Related Classes of uk.org.ogsadai.activity.MockInputPipe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.