"""
Test program for rule based resolution.
"""
# Examples:
# Reference of the redshift => meta.ref
# Field center decl for J2000 => pos.eq.dec;meta.main, Problem: meta.main doesn't exist in the context; the shortage "decl" is not found, must be "declination".
# H selected default magnitude => phot.mag;em.IR.H, Problem: "em.IR.H" not in the context, because the token "h" is lower case and the ucd is upper case.
#Proper motion in RA => pos.pm;pos.eq.ra


#Uncertainty flag on V-I (1) => meta.code.error;phot.color;em.opt.V, Problem: to get phot.color in the context, there needs to be a rule that adds "phot.something" to the context if em. is there as well. 



from ucdresolve.rulebased import *

rules = [
#WordMatchingRule(predWordsStartWith("meta.ref"), actAddWordsAsHyp),
#Rule(predHasTok("ra"), actAddWordsAsHyp),
WordMatchingRule(predAnd(predWordsStartWith("meta.main"), predWordsStartWith("pos.eq")), actAppendWordToHyps),	
WordMatchingRule(predAnd(predWordsStartWith("meta"), predWordsContain("error")), actAddWordsAsHyp),
#Rule(predOr(predHasTok("limit"), predHasTok("error")), actAppendWord("test")), #=> action: nimm alle ucds vom Context, in denen "error" vorkommt
Rule(predHypStartsWith("meta.code"), actDelWordFromHyps("meta.code")),

WordMatchingRule(predAnd(predWordsStartWith("src."), predNot(predWordsContain("redshift"))),  actAddWordsAsHyp),

]
ctx = Context.fromDescription("b")
#ctx = Context.fromDescription("Uncertainty flag on V-I (1)")
#ctx = Context.fromDescription("Quality flag on the classification (G1)")
#ctx = Context.fromDescription("limit or method flag on z (4)")
#ctx = Context.fromDescription("Proper motion in RA")
#ctx = Context.fromDescription("H selected default magnitude")
#ctx = Context.fromDescription("Field center decl for J2000")
#ctx = Context.fromDescription("Reference of the redshift")


print ">>>>>>>>", ctx.words
for rule in rules:
	rule.apply(ctx)
	print ">>>>", ctx.hypotheses

