-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRuleVariable.java
More file actions
51 lines (39 loc) · 1.38 KB
/
Copy pathRuleVariable.java
File metadata and controls
51 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
import java.awt.* ;
public class RuleVariable extends Variable {
public RuleVariable(String Name) {
super(Name);
clauseRefs = new Vector();
}
void setValue(String val) {
value = val;
updateClauses();
}
// prompt a user to provide a value for a variable during inferencing
String askUser() {
String answer = RuleApplet.waitForAnswer(promptText, getLabels()) ; // show dialog
RuleBase.appendText("\n !!! Looking for " + name + ". User entered: " + answer) ;
setValue(answer) ; // need to set value from textField here
return value ;
}
Vector clauseRefs ; // clauses which refer to this var
void addClauseRef(Clause ref) {
clauseRefs.addElement(ref) ;
}
void updateClauses() {
Enumeration enume = clauseRefs.elements() ;
while(enume.hasMoreElements())
((Clause)enume.nextElement()).check() ; // retest the truth condition
}
String promptText ; // used to prompt user for value
String ruleName ; // if value is inferred, null = user provided
void setRuleName(String rname) {
ruleName = rname;
}
void setPromptText(String text) {
promptText = text;
}
// these methods are not used in rule variables
public void computeStatistics(String inValue){} ;
public int normalize(String inValue, float[] outArray, int inx) {return inx;}
}