programr 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +64 -0
- data/Rakefile +2 -0
- data/conf/readOnlyTags.yaml +37 -0
- data/lib/programr.rb +5 -0
- data/lib/programr/aiml_elements.rb +352 -0
- data/lib/programr/aiml_parser.rb +269 -0
- data/lib/programr/environment.rb +75 -0
- data/lib/programr/facade.rb +65 -0
- data/lib/programr/graph_master.rb +110 -0
- data/lib/programr/history.rb +82 -0
- data/lib/programr/utils.rb +30 -0
- data/lib/programr/version.rb +3 -0
- data/programr.gemspec +17 -0
- data/test/data/1.aiml +125 -0
- data/test/data/facade.aiml +233 -0
- data/test/data/mixed/dir/badfile +1 -0
- data/test/data/mixed/dir/in_dir.aiml +9 -0
- data/test/data/mixed/dir/subdir/in_sub_dir.aiml +17 -0
- data/test/data/mixed/single.aiml +9 -0
- data/test/data/test.aiml +44 -0
- data/test/test_facade.rb +67 -0
- data/test/test_utils.rb +18 -0
- metadata +81 -0
@@ -0,0 +1 @@
|
|
1
|
+
badfile
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">
|
5
|
+
<category>
|
6
|
+
<pattern>in dir</pattern>
|
7
|
+
<template>OK</template>
|
8
|
+
</category>
|
9
|
+
</aiml>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">
|
5
|
+
<category>
|
6
|
+
<pattern>in sub dir</pattern>
|
7
|
+
<template>OK</template>
|
8
|
+
</category>
|
9
|
+
<category>
|
10
|
+
<pattern>in sub dir marco</pattern>
|
11
|
+
<template>ciao</template>
|
12
|
+
</category>
|
13
|
+
<category>
|
14
|
+
<pattern>in sub dir pippo</pattern>
|
15
|
+
<template>ciao</template>
|
16
|
+
</category>
|
17
|
+
</aiml>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">
|
5
|
+
<category>
|
6
|
+
<pattern>single file</pattern>
|
7
|
+
<template>OK</template>
|
8
|
+
</category>
|
9
|
+
</aiml>
|
data/test/data/test.aiml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">
|
5
|
+
<category>
|
6
|
+
<pattern>1 *</pattern>
|
7
|
+
<template>One what? </template>
|
8
|
+
</category>
|
9
|
+
|
10
|
+
<category>
|
11
|
+
<pattern>1 0</pattern>
|
12
|
+
<template>One. </template>
|
13
|
+
</category>
|
14
|
+
|
15
|
+
<category>
|
16
|
+
<pattern>very long pattern is this</pattern>
|
17
|
+
<template>very long</template>
|
18
|
+
</category>
|
19
|
+
|
20
|
+
<category>
|
21
|
+
<pattern>very long pattern is that over there</pattern>
|
22
|
+
<template>very very long</template>
|
23
|
+
</category>
|
24
|
+
|
25
|
+
<category>
|
26
|
+
<pattern>DATE TEST</pattern>
|
27
|
+
<template><date/></template>
|
28
|
+
</category>
|
29
|
+
|
30
|
+
<category>
|
31
|
+
<pattern>SIZE TEST</pattern>
|
32
|
+
<template><size/></template>
|
33
|
+
</category>
|
34
|
+
|
35
|
+
<category>
|
36
|
+
<pattern>SYSTEM TEST</pattern>
|
37
|
+
<template><system>whoami</system></template>
|
38
|
+
</category>
|
39
|
+
|
40
|
+
<category>
|
41
|
+
<pattern>SRAI TEST</pattern>
|
42
|
+
<template><srai>SIZE TEST</srai></template>
|
43
|
+
</category>
|
44
|
+
</aiml>
|
data/test/test_facade.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'programr/facade'
|
3
|
+
require 'programr/aiml_elements'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
class TestFacade < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@robot = ProgramR::Facade.new
|
9
|
+
@robot.learn('test/data/facade.aiml')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_stimula_reaction
|
13
|
+
assert_equal('test succeded', @robot.get_reaction('atomic test'), 'ATOMIC')
|
14
|
+
assert_equal('test succeded', @robot.get_reaction('srai test'), "SRAI")
|
15
|
+
assert_equal('new test succeded',@robot.get_reaction('atomic test'),"TOPIC")
|
16
|
+
assert_equal('that test 1', @robot.get_reaction('that test'), 'THAT 1')
|
17
|
+
assert_equal('that test 2', @robot.get_reaction('that test'), "THAT 2")
|
18
|
+
assert_equal('topic star test succeded OK',
|
19
|
+
@robot.get_reaction('atomic test'), "STAR TOPIC")
|
20
|
+
assert_equal('the UPPERCASE test', @robot.get_reaction('uppercase test'))
|
21
|
+
assert_equal('the lowercase test', @robot.get_reaction('LOWERCASE TEST'))
|
22
|
+
assert_equal(Date.today.to_s, @robot.get_reaction('DATE TEST'))
|
23
|
+
assert_equal('time:' + `date`.chomp, @robot.get_reaction('SYSTEM TEST'))
|
24
|
+
assert_equal(ProgramR::Category.cardinality.to_s,
|
25
|
+
@robot.get_reaction('SIZE TEST'))
|
26
|
+
assert_equal("TEST SPACE", @robot.get_reaction("SPACE TEST"))
|
27
|
+
assert_equal('tiresia', @robot.get_reaction('get test 1'))
|
28
|
+
assert_equal('TEST SPACE', @robot.get_reaction('justbeforethat tag test'))
|
29
|
+
assert_equal('TEST SPACE', @robot.get_reaction('that tag test'))
|
30
|
+
assert_equal('are you never tired to do the same things every day?',
|
31
|
+
@robot.get_reaction('question test'))
|
32
|
+
assert_equal('localhost', @robot.get_reaction('get test 2'))
|
33
|
+
assert_equal('ok.', @robot.get_reaction('think test. i am male'))
|
34
|
+
assert_equal('male.female.female', @robot.get_reaction('test set'))
|
35
|
+
assert_equal('You sound very attractive.',@robot.get_reaction('I AM BLOND'))
|
36
|
+
assert_equal('You sound very attractive.', @robot.get_reaction('I AM RED'))
|
37
|
+
assert_equal('You sound very attractive.',@robot.get_reaction('I AM BLACK'))
|
38
|
+
assert_equal('The sentence test', @robot.get_reaction('sentence test'))
|
39
|
+
assert_equal('The Formal Test', @robot.get_reaction('formal test'))
|
40
|
+
assert_equal('A', @robot.get_reaction('random test'))
|
41
|
+
assert_equal('RANDOM TEST.FORMAL TEST', @robot.get_reaction('test input'))
|
42
|
+
assert_equal(
|
43
|
+
'she told to him to take a hike but her ego was too much for him',
|
44
|
+
@robot.get_reaction('test gender'))
|
45
|
+
assert_equal('she TOLD to him',
|
46
|
+
@robot.get_reaction('gender test 2 he told to her'))
|
47
|
+
assert_equal(
|
48
|
+
'she TOLD MAURO EVERYTHING OK WITH her PROBLEM BUT i answers no',
|
49
|
+
@robot.get_reaction(
|
50
|
+
'i told mauro everything ok with my problem but he answers no'))
|
51
|
+
assert_equal('i say everything ok to you',
|
52
|
+
@robot.get_reaction('you say everything ok to me'))
|
53
|
+
assert_equal('star wins', @robot.get_reaction('This is her'))
|
54
|
+
assert_equal('underscore wins', @robot.get_reaction('This is you'))
|
55
|
+
assert_equal('explicit pattern wins',
|
56
|
+
@robot.get_reaction('This is clearly you'))
|
57
|
+
assert_equal('first star is ARE NEAT AND second star is GOOD AS',
|
58
|
+
@robot.get_reaction('These are neat and clearly good as them'))
|
59
|
+
assert_equal('WHAT IS YOUR FAVORITE FOOTBALL TEAM',
|
60
|
+
@robot.get_reaction('test thatstar'))
|
61
|
+
assert_equal('ALSO MINE IS AC MILAN', @robot.get_reaction('AC milan'))
|
62
|
+
assert_equal('WHAT IS YOUR FAVORITE FOOTBALL TEAM',
|
63
|
+
@robot.get_reaction('test thatstar'))
|
64
|
+
assert_equal('ok yes ALSO MINE IS AC MILAN',
|
65
|
+
@robot.get_reaction('yes AC milan'))
|
66
|
+
end
|
67
|
+
end
|
data/test/test_utils.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'programr/utils'
|
3
|
+
|
4
|
+
class TestFacade < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@robot = ProgramR::Facade.new
|
7
|
+
@robot.learn('test/data/facade.aiml')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_aiml_file_finder
|
11
|
+
actual = ProgramR::AimlFinder::find(['test/data/mixed/single.aiml',
|
12
|
+
'test/data/mixed/dir']).sort
|
13
|
+
expected = ['test/data/mixed/single.aiml',
|
14
|
+
'test/data/mixed/dir/in_dir.aiml',
|
15
|
+
'test/data/mixed/dir/subdir/in_sub_dir.aiml'].sort
|
16
|
+
assert_equal(expected, actual)
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: programr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mauro Cicio, Nicholas H.Tollervey, Ben Minton and Robert J Whitney
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Ruby interpreter for the AIML
|
15
|
+
email:
|
16
|
+
- robertj.whitney@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- conf/readOnlyTags.yaml
|
27
|
+
- lib/programr.rb
|
28
|
+
- lib/programr/aiml_elements.rb
|
29
|
+
- lib/programr/aiml_parser.rb
|
30
|
+
- lib/programr/environment.rb
|
31
|
+
- lib/programr/facade.rb
|
32
|
+
- lib/programr/graph_master.rb
|
33
|
+
- lib/programr/history.rb
|
34
|
+
- lib/programr/utils.rb
|
35
|
+
- lib/programr/version.rb
|
36
|
+
- programr.gemspec
|
37
|
+
- test/data/1.aiml
|
38
|
+
- test/data/facade.aiml
|
39
|
+
- test/data/mixed/dir/badfile
|
40
|
+
- test/data/mixed/dir/in_dir.aiml
|
41
|
+
- test/data/mixed/dir/subdir/in_sub_dir.aiml
|
42
|
+
- test/data/mixed/single.aiml
|
43
|
+
- test/data/test.aiml
|
44
|
+
- test/test_facade.rb
|
45
|
+
- test/test_utils.rb
|
46
|
+
homepage: http://aiml-programr.rubyforge.org/
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.11
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: ProgramR is a Ruby implementation of an interpreter for the Artificial Intelligence
|
70
|
+
Markup Language (AIML) based on the work of Dr. Wallace and defined by the Alicebot
|
71
|
+
and AIML Architecture Committee of the A.L.I.C.E. AI Foundation (http://alicebot.org
|
72
|
+
test_files:
|
73
|
+
- test/data/1.aiml
|
74
|
+
- test/data/facade.aiml
|
75
|
+
- test/data/mixed/dir/badfile
|
76
|
+
- test/data/mixed/dir/in_dir.aiml
|
77
|
+
- test/data/mixed/dir/subdir/in_sub_dir.aiml
|
78
|
+
- test/data/mixed/single.aiml
|
79
|
+
- test/data/test.aiml
|
80
|
+
- test/test_facade.rb
|
81
|
+
- test/test_utils.rb
|