Skip to content

Instantly share code, notes, and snippets.

@ltddev
Created April 6, 2014 08:16
Show Gist options
  • Save ltddev/10002980 to your computer and use it in GitHub Desktop.
Save ltddev/10002980 to your computer and use it in GitHub Desktop.
test_aima
'''
test_aima.py - this is a simple test harness to test making a module
out of the aima python library (the library used in the book "Artificial
Intelligence - A Modern Approach, 3rd Edition, 2010") then calling a
single method in the logic.py composition unit in a Pythonista script.
If successful, I plan to do further experiments of machine learning. Note
that aima python is a pure python module with no special dependencies and
therefore is a module Pythonista can currently handle without numpy and
scipy which are not pure python libraries and Pythonista v1.4 cannot
make use of modules that have non-python dependencies.
Expected console outpu from running thi script is:
Input [hello] is a symbol? True
Input [89hello] is a symbol? True
Input [##hello] is a symbol? False
Input [Hello] is a symbol? True
Input [WORLD] is a symbol? True
Input [123] is a symbol? False
Input [+] is a symbol? False
Input [25.5] is a symbol? False
Input [Hello] is a symbol? True
Input [H#[[0] is a symbol? True
'''
from aima import logic
import console
def printIsASymbol(input, isSymbol):
print('Input [' + str(input) + '] is a symbol? ' + str(isSymbol))
input = 'hello'
isSymbol = logic.is_symbol(input)
console.clear()
printIsASymbol(input, isSymbol)
input = '89hello'
printIsASymbol(input, isSymbol)
isSymbol = logic.is_symbol(input)
input = '##hello'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input ='Hello'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input ='WORLD'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input = 123
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input ='+'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input = 25.5
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input ='Hello'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
input ='H#[[0'
isSymbol = logic.is_symbol(input)
printIsASymbol(input, isSymbol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment