fromJSON method
Restores this instance from the given JSON object.
Implementation
FuzzyRule fromJSON(Map<String,dynamic> json, Map<String,FuzzySet> fuzzySets ) {
parseTerm( termJSON ) {
if (termJSON is String ) {
// atomic term -> FuzzySet
final uuid = termJSON;
return fuzzySets[uuid];
}
else {
// composite term
final type = termJSON['type'];
dynamic term;
switch ( type ) {
case 'FuzzyAND':
term = FuzzyAND();
break;
case 'FuzzyOR':
term = FuzzyOR();
break;
case 'FuzzyVERY':
term = FuzzyVERY();
break;
case 'FuzzyFAIRLY':
term = FuzzyFAIRLY();
break;
default:
yukaConsole.error( 'YUKA.FuzzyRule: Unsupported operator type: $type' );
return;
}
final termsJSON = termJSON.terms;
for ( int i = 0, l = termsJSON.length; i < l; i ++ ) {
// recursively parse all subordinate terms
term.terms.add( parseTerm( termsJSON[ i ] ) );
}
return term;
}
}
antecedent = parseTerm( json['antecedent'] );
consequence = parseTerm( json['consequence'] );
return this;
}