Comments (1)
You can do it with standard python methods:
For example, assign the values to the KE object itself.
from pyknow import *
class Greetings(KnowledgeEngine):
@DefFacts()
def _initial_action(self):
yield Fact(action="greet")
@Rule(Fact(action='greet'),
NOT(Fact(name=W())))
def ask_name(self):
self.declare(Fact(name=input("What's your name? ")))
@Rule(Fact(action='greet'),
NOT(Fact(location=W())))
def ask_location(self):
self.declare(Fact(location=input("Where are you? ")))
@Rule(Fact(action='greet'),
Fact(name="name" << W()),
Fact(location="location" << W()))
def greet(self, name, location):
print("Hi %s! How is the weather in %s?" % (name, location))
self.name = name
self.location = location
engine = Greetings()
engine.reset() # Prepare the engine for the execution.
engine.run() # Run it!
print(engine.name)
print(engine.location)
Not sure if current tests still do it, but old ones took advantage of variable scope to retrieve values.
from pyknow.
Related Issues (20)
- Matching list content using `CONTAINS` HOT 2
- Modules in Pyknow HOT 2
- Load rule set dynamically in KnowledgeEngine HOT 9
- Document Engine-Matcher interaction and dynamic rule creation strategies HOT 11
- teminal HOT 1
- Explanation Module HOT 1
- Got a AttributeError: 'Rule' object has no attribute '__name__' HOT 2
- Rules called on already retracted facts HOT 5
- what can i do if i want the return value of the P function ? HOT 1
- Is it needed for creating a shared OrdinaryMatchNode? HOT 1
- watch() raises KeyError HOT 2
- Return of value HOT 2
- Current time
- Declare new fact in RHS function? HOT 1
- Long execution time
- Little issue with PyPi HOT 5
- what is role of MATCH and AS HOT 1
- Thank you so much! HOT 1
- Exporting and importing the rules to and from PyKnow HOT 1
- Suggest to loosen the dependency on schema HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyknow.