-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
rule: | ||
if it is enclosed | ||
then its type is landlocked. | ||
|
||
rule: | ||
if it has a coastline | ||
then its type is not-landlocked. | ||
|
||
rule: | ||
if its type is landlocked and | ||
it is south-american and | ||
it is bordered-by-peru | ||
then it is bolivia. | ||
|
||
rule: | ||
if its type is landlocked and | ||
it is south-american | ||
then it is paraguay. | ||
|
||
rule: | ||
if its type is not-landlocked and | ||
it is south-american and | ||
it is big | ||
then it is brazil. | ||
|
||
rule: | ||
if its type is not-landlocked and | ||
it is south-american and | ||
it is independent and | ||
it is small | ||
then it is suriname. | ||
|
||
rule: | ||
if its type is not-landlocked and | ||
it is big | ||
then it is canada. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The domain choosen is a tiny subset of the countries of the World. The database can identify four countries, Bolivia, Paraguay, Brazil, Suriname and Canada by some very simple features. | ||
|
||
The only problem encounterd while creating the database was properly formating the rules and identifying the word types of each word. This was a small hump to get over for someone who is not a native speaker but after that, creating the database was straight forward. | ||
|
||
The word type definitions that we needed to add to 312-pess-grammer.pl were: | ||
|
||
n(type). | ||
n(paraguay). | ||
n(coastline). | ||
n(bolivia). | ||
n(brazil). | ||
n(suriname). | ||
n(canada). | ||
|
||
adj(enclosed). | ||
adj(landlocked). | ||
adj('not-landlocked'). | ||
adj('bordered-by-peru'). | ||
adj('south-american'). | ||
adj(big). | ||
adj(small). | ||
adj(independent). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
To allow the user to set the top level goal from the interpreter loop, assertz(rule(top_goal(X), [attr(is_a, X, [])])). was removed from the clear_db predicate and a new predicate was created: | ||
|
||
goal :- | ||
write('Enter the new goal, followed by a period: '), | ||
read_sentence(Y), | ||
process(['goal:'|Y]). | ||
|
||
Example: | ||
?- goal. | ||
Enter the new goal, followed by a period: what the heck is THAT. | ||
Understood: rule(top_goal(_G312),[attr(is_a,_G312,[])]) | ||
true. | ||
|
||
?- solve. | ||
Would you say that it has external tubular nostrils ?> no. | ||
Would you say that it has webbed feet ?> |: no. | ||
Would you say that it eats meat ?> |: no. | ||
Would you say that it has one long backward toe ?> |: yes. | ||
Would you say that it has flat bill ?> |: yes. | ||
Would you say that it eats flying insects ?> |: yes. | ||
Would you say that it has long rusty tail ?> |: yes. | ||
The answer is great crested flycatcher | ||
true . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
To allow the user to assert new facts and rules we simply create a new predicate: | ||
|
||
new_rule :- | ||
write('Enter a new rule, followed by a period: '), | ||
read_sentence(Y), | ||
process(['rule:'|Y]). | ||
|
||
Example: | ||
|
||
?- new_rule. | ||
Enter a new rule, followed by a period: if its neck is medium then it is goose. | ||
Understood: if it has medium neck then it is goose | ||
true. | ||
|
||
?- goal. | ||
Enter the new goal, followed by a period: what is it. | ||
Understood: rule(top_goal(_G288),[attr(is_a,_G288,[])]) | ||
true. | ||
|
||
?- solve. | ||
Would you say that it has external tubular nostrils ?> no. | ||
Would you say that it has webbed feet ?> |: no. | ||
Would you say that it eats meat ?> |: no. | ||
Would you say that it has one long backward toe ?> |: no. | ||
Would you say that it has medium neck ?> |: yes. | ||
The answer is goose | ||
true . |