You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from experta import rule
from experta.engine import KnowledgeEngine
from experta.fieldconstraint import L
from experta.rule import Rule
from experta.fact import Fact, Field
from experta.deffacts import DefFacts
from experta.shortcuts import MATCH
from experta.conditionalelement import TEST
class animal(Fact):
name = Field(str, mandatory=True)
number = Field(int, mandatory=True)
class AnimalAnalysis(KnowledgeEngine):
@DefFacts()
def init_animal(self):
yield animal(name = 'dog',
number = 23)
yield animal(name = 'cat',
number = 5)
yield animal(name = 'snake',
number = 14)
@Rule(animal(name=MATCH.name, number=MATCH.number), TEST(lambda number: number > 10))
def animal_analysis(self, name, number):
return print(name, 'has more than 10 ', number)
I have this code, for animals:
from experta import rule
from experta.engine import KnowledgeEngine
from experta.fieldconstraint import L
from experta.rule import Rule
from experta.fact import Fact, Field
from experta.deffacts import DefFacts
from experta.shortcuts import MATCH
from experta.conditionalelement import TEST
class animal(Fact):
name = Field(str, mandatory=True)
number = Field(int, mandatory=True)
class AnimalAnalysis(KnowledgeEngine):
@DefFacts()
def init_animal(self):
yield animal(name = 'dog',
number = 23)
yield animal(name = 'cat',
number = 5)
yield animal(name = 'snake',
number = 14)
engine = AnimalAnalysis()
engine.reset()
engine.run()
Which result:
snake has more than 10 14
dog has more than 10 23
How can I import, at once, a complete excel or txt list of facts?
(Below: )
animal number
dog 23
cat 5
snake 14
dog 32
bird 78
cat 48
dog 52
dog 36
cat 28
bird 14
snake 24
snake 17
Thanks folks! :)
The text was updated successfully, but these errors were encountered: