Menu

SDT API / Blog: Recent posts

Use DecisionTable and pass it to a vector of DecisionRule

transform a String matrix [ ][ ] to DecisionTable

/**
 * Gets the rules test.
 * @author: Yan Tang, VUB, 2009
 * @return the rules test
 */
public static void getRulesTest() {
    String[][] content = new String[][] { { "CONDITION", "", "", "", "" },
            { "C1", "Y", "N", "Y", "N" }, { "C2", "Y", "Y", "N", "N" },
            { "ACTION", "", "", "", "" }, { "A1", "/", "*", "/", "/" },
            { "A2", "*", "*", "/", "/" } };
    DecisionTable table = new DecisionTable();
    Vector<DecisionRule> rules = table.getRules(content);
    for (int i = 0; i < rules.size(); i++)
        rules.get(i).printToConsole();
}
Posted by Yan Tang Demey 2013-03-11

How to save an SDT in an XML file?

Use Jaxb to marshal SDT in an XML file.

// step1: create the jaxb context
JAXBContext jaxbContext = JAXBContext.newInstance("sdt.xml");

// step2: create the marshaller
Marshaller marshaller = jaxbContext.createMarshaller();

// set xml file output format: line breaks and indentation will appear
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));... read more

Posted by Yan Tang Demey 2013-03-11

how to remove irrelevant condition stubs?

A relevant condition stub is a condition stub that cannot be removed safely. If you remove it, your decision table will not be complete.
When we say a condition stub is irrelevant, it means that the decision rules won't change if we remove this condition stub from the decision table.


Vector<decisionrule> rules = makeExample();</decisionrule>

IrrelevantConditionStubRemover remover = new IrrelevantConditionStubRemover(
rules);
rules = remover.removeIrrelevantConditionStubs(new String[] { "C1" });
System.err.println("-----------result-----------" + rules.size());
for (int i = 0; i < rules.size(); i++)
System.err.println(rules.get(i).getInfo());

Posted by Yan Tang Demey 2012-10-18

get relevant condition stubs

A relevant condition stub is a condition stub that cannot be removed safely. If you remove it, your decision table will not be complete.

When we say a condition stub is irrelevant, it means that the decision rules won't change if we remove this condition stub from the decision table.


            /**
             *@author: Yan Tang, VUB, 2009
             */

            Vector<DecisionRule> rules = makeExample();... [read more](/p/sdtapi/blog/2012/10/get-relevant-condition-stubs/)
Posted by Yan Tang Demey 2012-10-18

How to use ValueRange?

to check whether a statement, e.g., "<-1000,99" is a value range of Integer or Float.

/**
 * Checks if is range or value test_ float.
     * @author: Yan Tang, VUB, 2009
 */
public static void isRangeOrValueTest_Float() {
    ValueRange range = new ValueRange("<=100");
    boolean isRangeOrValue = range.isFloatRangeOrValue();
    System.out.println(range.getInput() + " isRangeOrValue = "
            + isRangeOrValue);
    System.err.print(range.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-valuerange/)
Posted by Yan Tang Demey 2012-10-18

How to use StringManager?

1) remove empty spaces from a string, 2) get sub-string from a string

/**
 * Removes the empty spaces begin and end test.
     * @author: Yan Tang, VUB, 2009
 */
public static void removeEmptySpacesBeginAndEndTest() {
    String s = "1234";
    StringManager manager = new StringManager(s);
    manager.removeEmptySpacesBeginAndEnd();
    System.out.println(manager.getString());

    s = " 1234 ";
    manager.setString(s);
    manager.removeEmptySpacesBeginAndEnd();
    System.out.println(manager.getString());... [read more](/p/sdtapi/blog/2012/10/how-to-use-stringmanager/)
Posted by Yan Tang Demey 2012-10-18

How to use StringArrayVector

to reverse a string

/**
 * Reverse test.
     * @author: Yan Tang, VUB, 2009
 */
public static void reverseTest() {
    StringArrayVector vector = new StringArrayVector();
    Vector<String[]> v = new Vector<String[]>();
    v.add(new String[] { "1", "2", "3" });
    v.add(new String[] { "3", "4", "5" });
    vector.printToconsole(v);
    v = vector.reverse(v);
    vector.printToconsole(v);
}
Posted by Yan Tang Demey 2012-10-18

How to use StringArray?

1) test whether it contains a sub-StringArray, 2) get a sub array, 3) test whether two StringArray's overlap each other, 4) test whether two StringArray's are same

/**
 * Contains test.
 * @author: Yan Tang, VUB, 2009
 */
public static void containsTest() {
    StringArray array = new StringArray(new String[] { "0", "1", "2", " ",
            "", "4", "*" });
    String containingComponent = " ";
    boolean contains = array.contains(containingComponent, 1, 5);
    System.out
            .println("contains=" + contains + "\ninfo=" + array.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-stringarray/)
Posted by Yan Tang Demey 2012-10-18

How to use SemanticDecisionTable from an xml file?

get all columns from an XML file and pass the parameters into a vector of String array, or a String matrix [ ] [ ]

      /**
 * Gets the all columns test.
 * @author: Yan Tang, VUB, 2009
 * @return the all columns test
 */



public static void getAllColumnsTest() {
    openSDTfile file = new openSDTfile();
    String filePathName = "C:\\SDT\\DT in XML files\\Nokeos_ERM_exampleRearrange00.xml";
    SDT sdt = file.openSDTXMLFile(filePathName);
    SemanticDecisionTable table = new SemanticDecisionTable(sdt);
    Vector<String[]> columns = table.getAllColumns();
    for (int i = 0; i < columns.size(); i++) {
        String[] array = columns.get(i);
        StringArray sa = new StringArray(array);
        sa.printArrayToConsole();
    }
    System.out.println(table.getProcessInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-semanticdecisiontable/)
Posted by Yan Tang Demey 2012-10-18

How to use SDTMatrix to

-get a particular column,check whether a column exists,check whether a part of table exists, get a part of a decision column,reverse a decision table (columns become rows),remove a column from a decision table


/**
 * Gets the column test.
 * @author: Yan Tang, VUB, 2009
 * @return the column test
 */
public static void getColumnTest() {
    String[][] matrix = new String[][] { { "C1", "1", "2", "1", "2" },
            { "C2", "1", "1", "2", "2" }, { "A1", "*", "", "", "" } };
    SDTMatrix m = new SDTMatrix(matrix);... [read more](/p/sdtapi/blog/2012/10/how-to-use-sdtmatrix/)
Posted by Yan Tang Demey 2012-10-18

How to use RuleFiller?

to fill empty decision columns based on known rules

/**
 * Make example.
 * @author: Yan Tang, VUB, 2009
 * @return the vector
 */
private static Vector<DecisionRule> makeExample() {
    // Originally first c1 then c2, start building a decision table
    Vector<DecisionRule> rules = new Vector<DecisionRule>();
    // column 1
    DecisionRule rule = new DecisionRule();
    rule.addCondition(new ConditionPair("C1", "Y"));
    rule.addCondition(new ConditionPair("C2", "N"));
    rule.addAction(new ActionPair("A1", "*"));
    rule.addAction(new ActionPair("A2", "/"));
    rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-rowfiller/)
Posted by Yan Tang Demey 2012-10-18

How to use RowShifter?

/**
 * Make example.
 *
 * @return the vector
 */
private static Vector<DecisionRule> makeExample() {
    // Originally first c1 then c2, start building a decision table
    Vector<DecisionRule> rules = new Vector<DecisionRule>();
    // column 1
    DecisionRule rule = new DecisionRule();
    rule.addCondition(new ConditionPair("C1", "Y"));
    rule.addCondition(new ConditionPair("C2", "N"));
    rule.addAction(new ActionPair("A1", "*"));
    rule.addAction(new ActionPair("A2", "/"));
    rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-rowshifter/)
Posted by Yan Tang Demey 2012-10-18

How to use EmptyTableGetter?

Get a decision table layout, which does not contain any decision rules yet.

    /**
 * Make example.
 * @author: Yan Tang, VUB, 2009
 * @return the vector
 */
private static Vector<DecisionRule> makeExample() {
    // Originally first c1 then c2, start building a decision table
    Vector<DecisionRule> rules = new Vector<DecisionRule>();
    // column 1
    DecisionRule rule = new DecisionRule();
    rule.addCondition(new ConditionPair("C1", "Y"));
    rule.addCondition(new ConditionPair("C2", "N"));
    rule.addAction(new ActionPair("A1", "*"));
    rule.addAction(new ActionPair("A2", "/"));
    rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-emptytablegetter/)
Posted by Yan Tang Demey 2012-10-18

How to use DecisionRulePropagator

Get propagated decision columns (decision rules), discover empty entries

/**
 * Gets the nbr of empty entries test.
 * @author: Yan Tang, VUB, 2009
 * @return the nbr of empty entries test
 */
public static void getNbrOfEmptyEntriesTest() {
    DecisonRulePropagator p = new DecisonRulePropagator("J", "N");
    String[] column = new String[] { "", "J", "J", "", "*", "" };
    int start = 1;
    int end = 2;
    String emptyToken = "";
    Integer[] ids = p.getNbrOfEmptyEntries(column, start, end, emptyToken);
    System.out.println(p.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisionrulepropagator/)
Posted by Yan Tang Demey 2012-10-18

DecisionTable: create a default decision table layout

Create a default decision table layout on given condition stubs, condition entries and action stubs.

/**
    *@author: Yan Tang, VUB, 2009
*/



public static void getTableLayoutTest() {
    DecisionTable dt = new DecisionTable();
    Vector<String> conEntries = new Vector<String>();
    conEntries.add("Yes");
    conEntries.add("No");
    conEntries.add(" ");
    DTCondition con1 = new DTCondition("c1", conEntries);
    DTCondition con2 = (new DTCondition("c2", conEntries));
    dt.addCondition(con1);
    dt.addCondition(con2);
    dt.addActionStub("a1");
    dt.addActionStub("a2");... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisiontable/)
Posted by Yan Tang Demey 2012-10-18 Labels: decision table

use DecisionRuleVector as a decision table container

To check whether a vector of decision rules contain a decision rule.

This method can be used to check whether or not a decision rule column exists in a decision table


/*
* Make example.
* @author Yan Tang, 2009
* @return the vector
/

private static Vector<DecisionRule> makeExample() {
    // Originally first c1 then c2, start building a decision table
    Vector<DecisionRule> rules = new Vector<DecisionRule>();
    // column 1
    DecisionRule rule = new DecisionRule();
    rule.addCondition(new ConditionPair("C1", "Y"));
    rule.addCondition(new ConditionPair("C2", "N"));
    rule.addAction(new ActionPair("A1", "*"));
    rule.addAction(new ActionPair("A2", "/"));
    rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisionrulevector/)
Posted by Yan Tang Demey 2012-10-18 Labels: DecisionRuleVector;DecisionRule

How to use class DecisionRule

In the examples, you will find how to check whether or not 1) a condition, e.g., C1-Y, exists in a decision rule (a column in a decision table); 2)an action, e.g., A1-, exists in a decision rule; 3) two conditions are same, e.g, C-Y and C-Y are same ; 4) two actions are same, e.g. A-/, A- are not same.


/
* Condition pair exists test.
@author: Yan Tang, 2009
/
public static void conditionPairExistsTest() {
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));... read more

Posted by Yan Tang Demey 2012-10-18 Labels: DecisionRule
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.