factor4[5][0]="~ip"; factor4[5][1]="oc"; factor4[5][2]="fraud"; factor4[5][3]=0.98;
factor4[6][0]="~ip"; factor4[6][1]="oc"; factor4[6][2]="~fraud"; factor4[6][3]=0.99;
factor4[7][0]="~ip"; factor4[7][1]="~oc"; factor4[7][2]="fraud"; factor4[7][3]=0.989;
factor4[8][0]="~ip"; factor4[8][1]="~oc"; factor4[8][2]="~fraud"; factor4[8][3]=0.999;
factorList[3] = factor4;

orderedListOfHiddenVariables[0]="Trav";
orderedListOfHiddenVariables[1]="FP";
orderedListOfHiddenVariables[2]="Fraud";
orderedListOfHiddenVariables[3]="IP";
orderedListOfHiddenVariables[4]="OC";
orderedListOfHiddenVariables[5]="CRP";

for i in range(6):
    print "Factor No."+str(i+1)+":";
    printfactor(factorList[i]);
print "List of Elimination Order:";
alll = "";
for i in range(5):
    alll += orderedListOfHiddenVariables[i]+", ";
alll += orderedListOfHiddenVariables[5] + ";";
print alll;

m = raw_input("# of query variables: "); m = int(m);
queryVariables = [0 for x in range(m)];
ans = "";
lans = 0;
if (m != 0):
    ans = raw_input("     Please insert query variables seperated by a whitespace or a comma: ");
    lans = len(ans); i = 0;
    var = "";
    lans = 0;
    if (m != 0):
        ans = raw_input("     Please insert evidence values (only values which are assigned to the variables in the factor table) in the right order seperated by a whitespace or a comma:\n ");
        lans = len(ans); i = 0;
        var = "";
    eL = "evidenceList = {";
    for j in range(lans):
        if (ans[j] != "," and ans[j] != " "):
            var = var + ans[j];
            if (j != lans-1):
                if (ans[j+1] == " " or ans[j+1] == ","):
                    evidenceList[i] = var;
                    eL = eL + var + ", ";
                    var = "";
                    i = i + 1;
            else:
                evidenceList[i] = var;
                eL = eL + var;
                var = "";
                i = i + 1;
    eL = eL + "}";
    print "List of evidence values is ready.\n";

    res = inference(factorList,queryVariables,orderedListOfHiddenVariables,evidenceList);
    print "Here is the result:";
    printfactor(res);
    print "\n";
    agreed = raw_input("Do you have other query?(yes/no): ");

print "Thanks a lot!";