module AltsIn where import "TripleData" import "Utils" import "Observe" -- Author: G.Naudts. Mail: naudts_vannoten@yahoo.com. functionListI = [] -- first tripleset is goal; second is from db altsIn :: (TripleSet,TripleSet) -> (TripleSet, TripleSet) altsIn (ts1, ts2) = (ts3, ts4) where (ts3, ts4, _) = fLoop (ts1, ts2, functionListI) fLoop (ts1, ts2, []) = (ts1, ts2, []) fLoop (ts1, ts2, functionList@(x:xs)) = fLoop (ts3, ts4, xs) where (ts3, ts4) = x (ts1, ts2) noLoop :: (TripleSet, TripleSet) -> (TripleSet, TripleSet) -- if no rule take :norec triple away. -- if 'the' rule make goal [] noLoop ([], []) = ([], []) noLoop ([], ts2) = ([], ts2) noLoop (ts1, []) = (ts1, []) noLoop (ts1, ts2) = (checkNoRec ts1 ts2, ts2) where checkNoRec [] _ = [] checkNoRec (x:xs) ts2 | bv3 && bv1 && bv2 = [] -- x:checkNoRec xs ts2 | bv1 = checkNoRec xs ts2 | otherwise = x:checkNoRec xs ts2 where Triple (s, p, v) = x URI s2 = p (bool, s1, r) = parseUntil ' ' s2 bv1 = s1 == ":norec" Literal s3 = s nr1 = stringToInt s3 bv2 = nr == nr1 testRule (Rule r) = True testRule t = False bv3 = testRule (head ts2) Rule (_, _, nr) = head ts2 -- this checks whether a predicate has a certain value checkPredicate :: Triple -> String -> Bool checkPredicate x sIn | bv3 = False | bv1 = True | otherwise = False where Triple (s, p, v) = x URI s2 = p (bool, s1, r) = parseUntil ' ' s2 bv1 = s1 == sIn testRule (Rule r) = True testRule t = False bv3 = testRule x