Мне приходится работать с этой базой и удалять дубликаты.
(deffacts MAIN::requirements "Expert Commitee" (softgoalElement (sgId gen104) (sgQualityAttribute "quality") (sgSujectObject "review") (sgGoalId gen98) (sgActorName "reviewer") (sgBhId gen2)) (softgoalElement (sgId gen107) (sgQualityAttribute "quality") (sgSujectObject "review") (sgGoalId gen96) (sgActorName "chair") (sgBhId gen20)) (softgoalElement (sgId gen109) (sgQualityAttribute "quality") (sgSujectObject "review") (sgGoalId gen97) (sgActorName "committe") (sgBhId gen26)) (softgoalElement (sgId gen110) (sgQualityAttribute "quality") (sgSujectObject "review") (sgGoalId gen98) (sgActorName "reviewer") (sgBhId gen34)) (softgoalElement (sgId gen113) (sgQualityAttribute "quality") (sgSujectObject "article") (sgGoalId gen96) (sgActorName "chair") (sgBhId gen50)))
Это извлеченные дубликаты данных:
(gen113)quality [article]
(gen111)honest [review]
(gen110)quality[review]
(gen109)quality [review]
(gen108)acknowledge [committee]
(gen107)quality [review]
(gen105)punctuality [plubication]
(gen104)quality [review]
Я использую это правило:
(defrule Deleting::ruleDeleteSoftgoal "This rule deletes duplicate softagoal found in the facts base."
(declare (salience 58))
?fact <- (softgoalElement
(sgId ?sgId1)
(sgSujectObject ?SubjectObjectSg1)
(sgQualityAttribute ?QualityAttributeSg1)
(sgGoalId ?GoalIdSg1 )
(sgActorName ?ActorNameSg1 )
)
?fact2 <- (softgoalElement
(sgId ?sgId2)
(sgSujectObject ?SubjectObjectSg2)
(sgQualityAttribute ?QualityAttributeSg2)
(sgGoalId ?GoalIdSg2 )
(sgActorName ?ActorNameSg2 )
)
(test (and (neq ?sgId1 ?sgId2)(eq ?SubjectObjectSg2 ?SubjectObjectSg1)(eq ?QualityAttributeSg2 ?QualityAttributeSg1)
(neq ?GoalIdSg2 ?GoalIdSg1 )(neq ?ActorNameSg2 ?ActorNameSg1 )))
=>
(retract ?fact2) )
Однако существуют в той же базе (sgActorName) и я не смог удалить, оставив только запись в конец: я должен был бы выглядеть так:
(gen113)quality [article]
(gen111)honest [review]
(gen110)quality [review]
(gen108)acknowledge [committee]
(gen105)punctuality [plubication]
Могу ли я помочь мне?
Гэри,
Я пытался устранить повторы, исходя из этого, правило удаляет одни повторяющиеся комбинации, а другие нет, я проверил правило и не нашел ничего, что мешает исключению. Можешь мне снова помочь?
данные:
(deftemplate synonymoustype "Gets the Type of softgoal"
(slot type (type STRING) )
(slot syntype (type STRING) )
)
(deftemplate synonymoustopic "Gets the topic of softgoal"
(slot topic (type STRING) )
(slot syntopic (type STRING) )
)
правило исключения:
(defrule ruleDeleteSoftgoal ""
(declare (salience 50))
(synSoftgoal
(ttId ?ttId1)
(synTopic ?syntopic1)
(synType ?syntype1))
?fact2 <- (synSoftgoal
(ttId ?ttId2)
(synTopic ?syntopic2)
(synType ?syntype2))
(test (and (neq ?ttId1 ?ttId2)
(eq ?syntopic2 ?syntopic1)
(eq ?syntype2 ?syntype1)))
=>
(retract ?fact2))
Основание:
(deffacts synonymtype
(synonymoustype (type "correct") (syntype "equitable ") )
(synonymoustype (type "correct") (syntype "legitimate ") )
(synonymoustype (type "correct") (syntype "proper ") )
(synonymoustype (type "correct") (syntype "true ") )
(synonymoustype (type "fair") (syntype "equitable") )
(synonymoustype (type "fair") (syntype "legitimate") )
(synonymoustype (type "fair") (syntype "sincere") )
(synonymoustype (type "fair") (syntype "straightforward ") )
(synonymoustype (type "fair") (syntype "trustworthy") )
(synonymoustype (type "honest") (syntype "sincere") )
(synonymoustype (type "honest") (syntype "straightforward") )
(synonymoustype (type "honest") (syntype "true") )
(synonymoustype (type "honest") (syntype "trustworthy") )
(synonymoustype (type "acknowledge") (syntype "accept") ))
(deffacts synonymtopic
(synonymoustopic (topic "evaluation") (syntopic "appraisal") )
(synonymoustopic (topic "review") (syntopic "analysis") )
(synonymoustopic (topic "review") (syntopic "audit") ) )
Результат:
(gen42)accept [appraisal]
(gen41)trustworthy [appraisal] - DEVERIA TER UMA SÓ
(gen40)true [appraisal] - DEVERIA TER UMA SÓ
(gen39)straightforward [appraisal] - DEVERIA TER UMA SÓ
(gen38)sincere [appraisal] - DEVERIA TER UMA SÓ
(gen37)trustworthy [appraisal]
(gen36)straightforward [appraisal]
(gen35)sincere [appraisal]
(gen34)legitimate [appraisal] - DEVERIA TER UMA SÓ
(gen33)equitable [appraisal] -DEVERIA TER UMA SÓ
(gen32)true [appraisal]
(gen31)proper [appraisal]
(gen30)legitimate [appraisal]
(gen29)equitable [appraisal]
(gen28)accept [analysis]
(gen27)trustworthy [analysis
Спасибо еще раз.