diff --git a/ai-engine-test/.classpath b/ai-engine-test/.classpath
new file mode 100644
index 00000000..273b5db3
--- /dev/null
+++ b/ai-engine-test/.classpath
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine-test/.gitignore b/ai-engine-test/.gitignore
new file mode 100644
index 00000000..56f9ff19
--- /dev/null
+++ b/ai-engine-test/.gitignore
@@ -0,0 +1,6 @@
+/build
+/javadoc
+/.metadata
+*.err.*
+*.log.*
+/bin/
diff --git a/ai-engine-test/.project b/ai-engine-test/.project
new file mode 100644
index 00000000..936ba606
--- /dev/null
+++ b/ai-engine-test/.project
@@ -0,0 +1,17 @@
+
+
+ Bot Libre - Testing
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/ai-engine-test/.settings/org.eclipse.core.resources.prefs b/ai-engine-test/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..c6d08313
--- /dev/null
+++ b/ai-engine-test/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//source/org/botlibre/test/Test.java=UTF-8
diff --git a/ai-engine-test/build.bat b/ai-engine-test/build.bat
new file mode 100644
index 00000000..59b09c9c
--- /dev/null
+++ b/ai-engine-test/build.bat
@@ -0,0 +1 @@
+ant
diff --git a/ai-engine-test/build.xml b/ai-engine-test/build.xml
new file mode 100644
index 00000000..32c5974d
--- /dev/null
+++ b/ai-engine-test/build.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine-test/gui.bat b/ai-engine-test/gui.bat
new file mode 100644
index 00000000..f5956ccb
--- /dev/null
+++ b/ai-engine-test/gui.bat
@@ -0,0 +1 @@
+ant gui
\ No newline at end of file
diff --git a/ai-engine-test/lib/.gitignore b/ai-engine-test/lib/.gitignore
new file mode 100644
index 00000000..79702272
--- /dev/null
+++ b/ai-engine-test/lib/.gitignore
@@ -0,0 +1 @@
+/Bot.jar
diff --git a/ai-engine-test/lib/botlibre-ai-test.jar b/ai-engine-test/lib/botlibre-ai-test.jar
new file mode 100644
index 00000000..3b6e91ff
Binary files /dev/null and b/ai-engine-test/lib/botlibre-ai-test.jar differ
diff --git a/ai-engine-test/lib/botlibre-ai.jar b/ai-engine-test/lib/botlibre-ai.jar
new file mode 100644
index 00000000..5b614835
Binary files /dev/null and b/ai-engine-test/lib/botlibre-ai.jar differ
diff --git a/ai-engine-test/lib/facebook/facebook4j-core-2.2.2.jar b/ai-engine-test/lib/facebook/facebook4j-core-2.2.2.jar
new file mode 100644
index 00000000..b114d345
Binary files /dev/null and b/ai-engine-test/lib/facebook/facebook4j-core-2.2.2.jar differ
diff --git a/ai-engine-test/lib/freebase/LICENSE.txt b/ai-engine-test/lib/freebase/LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/ai-engine-test/lib/freebase/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ai-engine-test/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar b/ai-engine-test/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar
new file mode 100644
index 00000000..5608dfd4
Binary files /dev/null and b/ai-engine-test/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar differ
diff --git a/ai-engine-test/lib/html/htmlcleaner.licence.txt b/ai-engine-test/lib/html/htmlcleaner.licence.txt
new file mode 100644
index 00000000..028bd119
--- /dev/null
+++ b/ai-engine-test/lib/html/htmlcleaner.licence.txt
@@ -0,0 +1,35 @@
+Copyright (c) 2006-2008, Vladimir Nikic
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
+conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* The name of HtmlCleaner may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+You can contact Vladimir Nikic by sending e-mail to
+nikic_vladimir@yahoo.com. Please include the word "HtmlCleaner" in the
+subject line.
\ No newline at end of file
diff --git a/ai-engine-test/lib/html/htmlcleaner2_1.jar b/ai-engine-test/lib/html/htmlcleaner2_1.jar
new file mode 100644
index 00000000..ca14f056
Binary files /dev/null and b/ai-engine-test/lib/html/htmlcleaner2_1.jar differ
diff --git a/ai-engine-test/lib/irc/Relay-IRC-LICENSE.txt b/ai-engine-test/lib/irc/Relay-IRC-LICENSE.txt
new file mode 100644
index 00000000..f984802b
--- /dev/null
+++ b/ai-engine-test/lib/irc/Relay-IRC-LICENSE.txt
@@ -0,0 +1,361 @@
+ MOZILLA PUBLIC LICENSE
+ Version 1.0
+
+ ----------------
+
+1. Definitions.
+
+ 1.1. ``Contributor'' means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. ``Contributor Version'' means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. ``Covered Code'' means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. ``Electronic Distribution Mechanism'' means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. ``Executable'' means Covered Code in any form other than Source
+ Code.
+
+ 1.6. ``Initial Developer'' means the individual or entity identified as
+ the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. ``Larger Work'' means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. ``License'' means this document.
+
+ 1.9. ``Modifications'' means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. ``Original Code'' means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this License
+ is not already Covered Code governed by this License.
+
+ 1.11. ``Source Code'' means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus any
+ associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or a list of source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. ``You'' means an individual or a legal entity exercising rights
+ under, and complying with all of the terms of, this License or a future
+ version of this License issued under Section 6.1. For legal entities,
+ ``You'' includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this definition,
+ ``control'' means (a) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of fifty percent (50%) or more of the
+ outstanding shares or beneficial ownership of such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+
+ (a) to use, reproduce, modify, display, perform, sublicense and
+ distribute the Original Code (or portions thereof) with or without
+ Modifications, or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by Initial
+ Developer, to make, have made, use and sell (``Utilize'') the
+ Original Code (or portions thereof), but solely to the extent that
+ any such patent is reasonably necessary to enable You to Utilize
+ the Original Code (or portions thereof) and not to any greater
+ extent that may be necessary to Utilize further Modifications or
+ combinations.
+
+ 2.2. Contributor Grant.
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+
+ (a) to use, reproduce, modify, display, perform, sublicense and
+ distribute the Modifications created by such Contributor (or
+ portions thereof) either on an unmodified basis, with other
+ Modifications, as Covered Code or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by
+ Contributor, to Utilize the Contributor Version (or portions
+ thereof), but solely to the extent that any such patent is
+ reasonably necessary to enable You to Utilize the Contributor
+ Version (or portions thereof), and not to any greater extent that
+ may be necessary to Utilize further Modifications or combinations.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be distributed
+ only under the terms of this License or a future version of this
+ License released under Section 6.1, and You must include a copy of this
+ License with every copy of the Source Code You distribute. You may not
+ offer or impose any terms on any Source Code version that alters or
+ restricts the applicable version of this License or the recipients'
+ rights hereunder. However, You may include an additional document
+ offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which you contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that the
+ Modification is derived, directly or indirectly, from Original Code
+ provided by the Initial Developer and including the name of the Initial
+ Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+
+ (a) Third Party Claims.
+ If You have knowledge that a party claims an intellectual property
+ right in particular functionality or code (or its utilization
+ under this License), you must include a text file with the source
+ code distribution titled ``LEGAL'' which describes the claim and
+ the party making the claim in sufficient detail that a recipient
+ will know whom to contact. If you obtain such knowledge after You
+ make Your Modification available as described in Section 3.2, You
+ shall promptly modify the LEGAL file in all copies You make
+ available thereafter and shall take other steps (such as notifying
+ appropriate mailing lists or newsgroups) reasonably calculated to
+ inform those who received the Covered Code that new knowledge has
+ been obtained.
+
+ (b) Contributor APIs.
+ If Your Modification is an application programming interface and
+ You own or control patents which are reasonably necessary to
+ implement that API, you must also include this information in the
+ LEGAL file.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code, and this License in any documentation for the Source Code, where
+ You describe recipients' rights relating to Covered Code. If You
+ created one or more Modification(s), You may add your name as a
+ Contributor to the notice described in Exhibit A. If it is not possible
+ to put such notice in a particular Source Code file due to its
+ structure, then you must include such notice in a location (such as a
+ relevant directory file) where a user would be likely to look for such
+ a notice. You may choose to offer, and to charge a fee for, warranty,
+ support, indemnity or liability obligations to one or more recipients
+ of Covered Code. However, You may do so only on Your own behalf, and
+ not on behalf of the Initial Developer or any Contributor. You must
+ make it absolutely clear than any such warranty, support, indemnity or
+ liability obligation is offered by You alone, and You hereby agree to
+ indemnify the Initial Developer and every Contributor for any liability
+ incurred by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of the
+ Covered Code is available under the terms of this License, including a
+ description of how and where You have fulfilled the obligations of
+ Section 3.2. The notice must be conspicuously included in any notice in
+ an Executable version, related documentation or collateral in which You
+ describe recipients' rights relating to the Covered Code. You may
+ distribute the Executable version of Covered Code under a license of
+ Your choice, which may contain terms different from this License,
+ provided that You are in compliance with the terms of this License and
+ that the license for the Executable version does not attempt to limit
+ or alter the recipient's rights in the Source Code version from the
+ rights set forth in this License. If You distribute the Executable
+ version under a different license You must make it absolutely clear
+ that any terms which differ from this License are offered by You alone,
+ not by the Initial Developer or any Contributor. You hereby agree to
+ indemnify the Initial Developer and every Contributor for any liability
+ incurred by the Initial Developer or such Contributor as a result of
+ any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to statute
+ or regulation then You must: (a) comply with the terms of this License
+ to the maximum extent possible; and (b) describe the limitations and
+ the code they affect. Such description must be included in the LEGAL
+ file described in Section 3.4 and must be included with all
+ distributions of the Source Code. Except to the extent prohibited by
+ statute or regulation, such description must be sufficiently detailed
+ for a recipient of ordinary skill to be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A, and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation (``Netscape'') may publish revised
+ and/or new versions of the License from time to time. Each version will
+ be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If you create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), you must (a) rename Your license so that the
+ phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or
+ any confusingly similar phrase do not appear anywhere in your license
+ and (b) otherwise make it clear that your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial Developer,
+ Original Code or Contributor in the notice described in Exhibit A shall
+ not of themselves be deemed to be modifications of this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER
+ PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
+ GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND
+ ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE
+ BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT
+ EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a ``commercial item,'' as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer
+ software'' and ``commercial computer software documentation,'' as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if any,
+ provides otherwise), excluding its conflict-of-law provisions. With
+ respect to disputes in which at least one party is a citizen of, or an
+ entity chartered or registered to do business in, the United States of
+ America: (a) unless otherwise agreed in writing, all disputes relating
+ to this License (excepting any dispute relating to intellectual
+ property rights) shall be subject to final and binding arbitration,
+ with the losing party paying all costs of arbitration; (b) any
+ arbitration relating to this Agreement shall be held in Santa Clara
+ County, California, under the auspices of JAMS/EndDispute; and (c) any
+ litigation relating to this Agreement shall be subject to the
+ jurisdiction of the Federal Courts of the Northern District of
+ California, with venue lying in Santa Clara County, California, with
+ the losing party responsible for costs, including without limitation,
+ court costs and reasonable attorneys fees and expenses. The application
+ of the United Nations Convention on Contracts for the International
+ Sale of Goods is expressly excluded. Any law or regulation which
+ provides that the language of a contract shall be construed against the
+ drafter shall not apply to this License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ Except in cases where another Contributor has failed to comply with
+ Section 3.4, You are responsible for damages arising, directly or
+ indirectly, out of Your utilization of rights under this License, based
+ on the number of copies of Covered Code you made available, the
+ revenues you received from utilizing such rights, and other relevant
+ factors. You agree to work with affected parties to distribute
+ responsibility on an equitable basis.
+
+EXHIBIT A.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.0 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.''
+
diff --git a/ai-engine-test/lib/irc/chatengine.jar b/ai-engine-test/lib/irc/chatengine.jar
new file mode 100644
index 00000000..aca66edf
Binary files /dev/null and b/ai-engine-test/lib/irc/chatengine.jar differ
diff --git a/ai-engine-test/lib/jpa/eclipselink.jar b/ai-engine-test/lib/jpa/eclipselink.jar
new file mode 100644
index 00000000..497a61c1
Binary files /dev/null and b/ai-engine-test/lib/jpa/eclipselink.jar differ
diff --git a/ai-engine-test/lib/jpa/eclipselink.license.html b/ai-engine-test/lib/jpa/eclipselink.license.html
new file mode 100644
index 00000000..3a0ba713
--- /dev/null
+++ b/ai-engine-test/lib/jpa/eclipselink.license.html
@@ -0,0 +1,361 @@
+
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor’s license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL and EDL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.
+
+
1. DEFINITIONS
+
+
"Contribution" means:
+
+
a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+
i)
+changes to the Program, and
+
+
ii)
+additions to the Program;
+
+
where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+
"Contributor" means any person or
+entity that distributes the Program.
+
+
"Licensed Patents " mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program.
+
+
"Program" means the Contributions
+distributed in accordance with this Agreement.
+
+
"Recipient" means anyone who
+receives the Program under this Agreement, including all Contributors.
+
+
2. GRANT OF RIGHTS
+
+
a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license toreproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.
+
+
b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+
c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.
+
+
d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement.
+
+
3. REQUIREMENTS
+
+
A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:
+
+
+
a)
+it complies with the terms and conditions of this Agreement; and
+
+
b)
+its license agreement:
+
+
i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose;
+
+
ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits;
+
+
iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and
+
+
iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.
+
+
When the Program is made available in source
+code form:
+
+
a)
+it must be made available under this Agreement; and
+
+
b) a
+copy of this Agreement must be included with each copy of the Program.
+
+
Contributors may not remove or alter any
+copyright notices contained within the Program.
+
+
Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution.
+
+
4. COMMERCIAL DISTRIBUTION
+
+
Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor ("Commercial
+Contributor") hereby agrees to defend and indemnify every other
+Contributor ("Indemnified Contributor") against any losses, damages and
+costs (collectively "Losses") arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.
+
+
For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.
+
+
5. NO WARRANTY
+
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations.
+
+
6. DISCLAIMER OF LIABILITY
+
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+
7. GENERAL
+
+
If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+
If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed.
+
+
All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.
+
+
Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+
This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
+
+
All rights reserved.
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+
Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
Neither the name of the Eclipse Foundation, Inc. nor the names of its
+contributors may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
\ No newline at end of file
diff --git a/ai-engine-test/lib/jpa/persistence.jar b/ai-engine-test/lib/jpa/persistence.jar
new file mode 100644
index 00000000..c3923889
Binary files /dev/null and b/ai-engine-test/lib/jpa/persistence.jar differ
diff --git a/ai-engine-test/lib/jpa/postgresql-9.0-801.jdbc4.jar b/ai-engine-test/lib/jpa/postgresql-9.0-801.jdbc4.jar
new file mode 100644
index 00000000..63e54165
Binary files /dev/null and b/ai-engine-test/lib/jpa/postgresql-9.0-801.jdbc4.jar differ
diff --git a/ai-engine-test/lib/json/commons-LICENSE.txt b/ai-engine-test/lib/json/commons-LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/ai-engine-test/lib/json/commons-LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ai-engine-test/lib/json/commons-beanutils-1.8.0.jar b/ai-engine-test/lib/json/commons-beanutils-1.8.0.jar
new file mode 100644
index 00000000..caf7ae33
Binary files /dev/null and b/ai-engine-test/lib/json/commons-beanutils-1.8.0.jar differ
diff --git a/ai-engine-test/lib/json/commons-collections-3.2.1.jar b/ai-engine-test/lib/json/commons-collections-3.2.1.jar
new file mode 100644
index 00000000..c35fa1fe
Binary files /dev/null and b/ai-engine-test/lib/json/commons-collections-3.2.1.jar differ
diff --git a/ai-engine-test/lib/json/commons-lang-2.4.jar b/ai-engine-test/lib/json/commons-lang-2.4.jar
new file mode 100644
index 00000000..532939ec
Binary files /dev/null and b/ai-engine-test/lib/json/commons-lang-2.4.jar differ
diff --git a/ai-engine-test/lib/json/commons-logging-1.1.1.jar b/ai-engine-test/lib/json/commons-logging-1.1.1.jar
new file mode 100644
index 00000000..8758a96b
Binary files /dev/null and b/ai-engine-test/lib/json/commons-logging-1.1.1.jar differ
diff --git a/ai-engine-test/lib/json/ezmorph-1.0.6.jar b/ai-engine-test/lib/json/ezmorph-1.0.6.jar
new file mode 100644
index 00000000..30fad12d
Binary files /dev/null and b/ai-engine-test/lib/json/ezmorph-1.0.6.jar differ
diff --git a/ai-engine-test/lib/json/json-lib-2.3-jdk15.jar b/ai-engine-test/lib/json/json-lib-2.3-jdk15.jar
new file mode 100644
index 00000000..29d59b99
Binary files /dev/null and b/ai-engine-test/lib/json/json-lib-2.3-jdk15.jar differ
diff --git a/ai-engine-test/lib/junit/junit.jar b/ai-engine-test/lib/junit/junit.jar
new file mode 100644
index 00000000..322bd6f0
Binary files /dev/null and b/ai-engine-test/lib/junit/junit.jar differ
diff --git a/ai-engine-test/lib/mail/dsn-1.5.1.jar b/ai-engine-test/lib/mail/dsn-1.5.1.jar
new file mode 100644
index 00000000..1bcde124
Binary files /dev/null and b/ai-engine-test/lib/mail/dsn-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/gimap-1.5.1.jar b/ai-engine-test/lib/mail/gimap-1.5.1.jar
new file mode 100644
index 00000000..6f193247
Binary files /dev/null and b/ai-engine-test/lib/mail/gimap-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/imap-1.5.1.jar b/ai-engine-test/lib/mail/imap-1.5.1.jar
new file mode 100644
index 00000000..8af7f493
Binary files /dev/null and b/ai-engine-test/lib/mail/imap-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/javax.mail-1.5.1.jar b/ai-engine-test/lib/mail/javax.mail-1.5.1.jar
new file mode 100644
index 00000000..0c5ac396
Binary files /dev/null and b/ai-engine-test/lib/mail/javax.mail-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/javax.mail-api-1.5.1.jar b/ai-engine-test/lib/mail/javax.mail-api-1.5.1.jar
new file mode 100644
index 00000000..2a72d65f
Binary files /dev/null and b/ai-engine-test/lib/mail/javax.mail-api-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/mailapi-1.5.1.jar b/ai-engine-test/lib/mail/mailapi-1.5.1.jar
new file mode 100644
index 00000000..e6f135a5
Binary files /dev/null and b/ai-engine-test/lib/mail/mailapi-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/pop3-1.5.1.jar b/ai-engine-test/lib/mail/pop3-1.5.1.jar
new file mode 100644
index 00000000..ce67d267
Binary files /dev/null and b/ai-engine-test/lib/mail/pop3-1.5.1.jar differ
diff --git a/ai-engine-test/lib/mail/smtp-1.5.1.jar b/ai-engine-test/lib/mail/smtp-1.5.1.jar
new file mode 100644
index 00000000..2dd9f30d
Binary files /dev/null and b/ai-engine-test/lib/mail/smtp-1.5.1.jar differ
diff --git a/ai-engine-test/lib/oswap/COPYING.txt b/ai-engine-test/lib/oswap/COPYING.txt
new file mode 100644
index 00000000..379d6e41
--- /dev/null
+++ b/ai-engine-test/lib/oswap/COPYING.txt
@@ -0,0 +1,234 @@
+You may use under either the Apache License Version 2.0 or the BSD
+3-Clause License.
+
+------------------------------------------------------------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+------------------------------------------------------------------
+
+Copyright (c) 2011, Mike Samuel
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ai-engine-test/lib/oswap/encoder-1.2.jar b/ai-engine-test/lib/oswap/encoder-1.2.jar
new file mode 100644
index 00000000..0e88d3b9
Binary files /dev/null and b/ai-engine-test/lib/oswap/encoder-1.2.jar differ
diff --git a/ai-engine-test/lib/oswap/guava.jar b/ai-engine-test/lib/oswap/guava.jar
new file mode 100644
index 00000000..c8c8d5dd
Binary files /dev/null and b/ai-engine-test/lib/oswap/guava.jar differ
diff --git a/ai-engine-test/lib/oswap/jsr305.jar b/ai-engine-test/lib/oswap/jsr305.jar
new file mode 100644
index 00000000..0de0870d
Binary files /dev/null and b/ai-engine-test/lib/oswap/jsr305.jar differ
diff --git a/ai-engine-test/lib/oswap/owasp-java-html-sanitizer.jar b/ai-engine-test/lib/oswap/owasp-java-html-sanitizer.jar
new file mode 100644
index 00000000..808775a0
Binary files /dev/null and b/ai-engine-test/lib/oswap/owasp-java-html-sanitizer.jar differ
diff --git a/ai-engine-test/lib/twitter/LICENSE.txt b/ai-engine-test/lib/twitter/LICENSE.txt
new file mode 100644
index 00000000..6b5c2d52
--- /dev/null
+++ b/ai-engine-test/lib/twitter/LICENSE.txt
@@ -0,0 +1,179 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+Twitter4J SUBCOMPONENTS:
+
+Twitter4J includes software from JSON.org to parse JSON response from the Twitter API. You can see the license term at http://www.JSON.org/license.html
\ No newline at end of file
diff --git a/ai-engine-test/lib/twitter/twitter4j-core-3.0.4.jar b/ai-engine-test/lib/twitter/twitter4j-core-3.0.4.jar
new file mode 100644
index 00000000..b2f12b8e
Binary files /dev/null and b/ai-engine-test/lib/twitter/twitter4j-core-3.0.4.jar differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/Bot.gif b/ai-engine-test/source/org/botlibre/client/gui/Bot.gif
new file mode 100644
index 00000000..43a553ca
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/Bot.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/BotFrame.java b/ai-engine-test/source/org/botlibre/client/gui/BotFrame.java
new file mode 100644
index 00000000..56380994
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/BotFrame.java
@@ -0,0 +1,461 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import javax.swing.WindowConstants;
+
+import org.botlibre.Bot;
+import org.botlibre.knowledge.Bootstrap;
+import org.botlibre.sense.text.TextEntry;
+import org.botlibre.thought.language.Language;
+import org.botlibre.thought.language.Language.LearningMode;
+
+/**
+ * Defines the client GUI interface.
+ * Enables communication, inspection and debugging of Bot.
+ */
+
+public class BotFrame extends JFrame {
+ private static final long serialVersionUID = 1L;
+ public static File lastDirectory;
+
+ /** Reference to Bot instance. **/
+ protected Bot bot;
+
+ private JMenuBar menuBar;
+ private BotPanel BotPanel;
+
+ public class ExitAction extends WindowAdapter implements ActionListener {
+
+ public void actionPerformed(ActionEvent event) {
+ int value = JOptionPane.showConfirmDialog(BotFrame.this, "Do you wish the shutdown Bot?", "Shutdown", JOptionPane.YES_NO_CANCEL_OPTION);
+ if (value == JOptionPane.CANCEL_OPTION) {
+ return;
+ }
+ if (value == JOptionPane.YES_OPTION) {
+ getBot().shutdown();
+ dispose();
+ System.exit(0);
+ }
+ dispose();
+ }
+
+ public void windowClosing(WindowEvent event) {
+ actionPerformed(null);
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ }
+ }
+
+ public class ShutdownAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ getBot().shutdown();
+ }
+ }
+
+ public class StartupAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ setBot(Bot.createInstance());
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Startup failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class ImportAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ String database = (String)JOptionPane.showInputDialog(
+ BotFrame.this,
+ "Enter database name to import:",
+ "Import Dialog",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ null,
+ "");
+ if (database == null) {
+ return;
+ }
+ try {
+ getBot().memory().importMemory(database);
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Import failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class LoadChatFileAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Select chat log file:");
+ if (lastDirectory == null) {
+ lastDirectory = new File(".");
+ }
+ chooser.setCurrentDirectory(lastDirectory);
+ int value = chooser.showOpenDialog(BotFrame.this);
+ if (value != JFileChooser.APPROVE_OPTION) {
+ return;
+ }
+ File file = chooser.getSelectedFile();
+ lastDirectory = file.getParentFile();
+ try {
+ if (file.getName().contains("aiml")) {
+ Language language = getBot().mind().getThought(Language.class);
+ if (language != null) {
+ language.loadAIMLFileAsLog(file, "", false);
+ }
+ } else {
+ getBot().awareness().getSense(TextEntry.class).loadChatFile(file, "Chat Log", "", true, false);
+ }
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Import failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class LoadSelfFileAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Select Self file:");
+ if (lastDirectory == null) {
+ lastDirectory = new File(".");
+ }
+ chooser.setCurrentDirectory(lastDirectory);
+ int value = chooser.showOpenDialog(BotFrame.this);
+ if (value != JFileChooser.APPROVE_OPTION) {
+ return;
+ }
+ File file = chooser.getSelectedFile();
+ lastDirectory = file.getParentFile();
+ try {
+ if (file.getName().contains("aiml")) {
+ getBot().mind().getThought(Language.class).loadAIMLFile(file, true, false, "");
+ } else {
+ getBot().mind().getThought(Language.class).loadSelfFile(file, "", true);
+ }
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Import failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class SwitchAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ String database = (String)JOptionPane.showInputDialog(
+ BotFrame.this,
+ "Enter database to switch to:",
+ "Instance Switch Dialog",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ null,
+ "");
+ if (database == null) {
+ return;
+ }
+ try {
+ setBot(Bot.createInstanceFromPool(database));
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Switch failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class CreateAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ String database = (String)JOptionPane.showInputDialog(
+ BotFrame.this,
+ "Enter database to create:",
+ "Creation Dialog",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ null,
+ "");
+ if (database == null) {
+ return;
+ }
+ try {
+ getBot().memory().createMemory(database);
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Creation failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class DestroyAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ String database = (String)JOptionPane.showInputDialog(
+ BotFrame.this,
+ "Enter database to destoy *** CAUTION THIS WILL DELETE ALL DATA ***:",
+ "Destruction Dialog",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ null,
+ "");
+ if (database == null) {
+ return;
+ }
+ try {
+ getBot().memory().destroyMemory(database);
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Destruction failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class BootstrapAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ new Bootstrap().bootstrapSystem(getBot(), true);
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Bootstrap failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class RebootstrapAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ new Bootstrap().rebootstrapMemory(getBot().memory());
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ JOptionPane.showMessageDialog(BotFrame.this,
+ failed.toString(),
+ "Bootstrap failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class DeleteAllAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ int option = JOptionPane.showConfirmDialog(
+ BotFrame.this,
+ "*** CAUTION THIS WILL DELETE ALL DATA ***",
+ "Delete all content dialog",
+ JOptionPane.WARNING_MESSAGE);
+ if (option != 0) {
+ return;
+ }
+ if (getBot().memory().getMemoryName().equals("cache")) {
+ Bot.systemCache.shutdown();
+ Bot.systemCache = null;
+ }
+ getBot().memory().deleteMemory();
+ getBot().shutdown();
+ if (getBot().memory().getMemoryName().equals("cache")) {
+ Bot.systemCache = Bot.createInstance(Bot.CONFIG_FILE, "cache");
+ }
+ setBot(Bot.createInstance(Bot.CONFIG_FILE, getBot().memory().getMemoryName()));
+ }
+ }
+
+ public class SpawnAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ BotFrame frame = new BotFrame();
+ frame.setVisible(true);
+ }
+ }
+
+ public static void main(String args[]) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception ignore) {}
+
+ try {
+ BotFrame frame = new BotFrame();
+ frame.setVisible(true);
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ System.exit(0);
+ }
+ }
+
+ public BotFrame() {
+ super("Bot");
+
+ Bot.systemCache = Bot.createInstance(Bot.CONFIG_FILE, "cache");
+
+ setBot(Bot.createInstance());
+
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ setBounds(screenSize.width / 8, screenSize.height / 8, (int)(screenSize.width / 1.5), (int)(screenSize.height / 1.5));
+ setIconImage(new ImageIcon(getClass().getResource("Bot.gif")).getImage());
+ addWindowListener(new ExitAction());
+
+ buildMenus();
+ buildContent();
+ }
+
+ protected void buildContent() {
+ this.BotPanel = new BotPanel(getBot());
+ getContentPane().setLayout(new GridBagLayout());
+ getContentPane().add(this.BotPanel, new GridBagConstraints(0,0,1,1, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));
+ }
+
+ protected void buildMenus() {
+ this.menuBar = new JMenuBar();
+ this.menuBar.setOpaque(true);
+ JMenu fileMenu = buildFileMenu();
+ JMenu editMenu = new JMenu("Edit");
+ JMenu helpMenu = new JMenu("Help");
+
+ this.menuBar.add(fileMenu);
+ this.menuBar.add(editMenu);
+ this.menuBar.add(helpMenu);
+
+ setJMenuBar(this.menuBar);
+ }
+
+ protected JMenu buildFileMenu() {
+ JMenu fileMenu = new JMenu("Bot");
+
+ JMenuItem spawnMenuItem = new JMenuItem("Spawn");
+ spawnMenuItem.addActionListener(new SpawnAction());
+
+ JMenuItem bootstrapMenuItem = new JMenuItem("Bootstrap");
+ bootstrapMenuItem.addActionListener(new BootstrapAction());
+
+ JMenuItem rebootstrapMenuItem = new JMenuItem("Rebootstrap");
+ rebootstrapMenuItem.addActionListener(new RebootstrapAction());
+
+ JMenuItem deleteMenuItem = new JMenuItem("Delete all content");
+ deleteMenuItem.addActionListener(new DeleteAllAction());
+
+ JMenuItem createMenuItem = new JMenuItem("Create...");
+ createMenuItem.addActionListener(new CreateAction());
+
+ JMenuItem destroyMenuItem = new JMenuItem("Destroy...");
+ destroyMenuItem.addActionListener(new DestroyAction());
+
+ JMenuItem importMenuItem = new JMenuItem("Import...");
+ importMenuItem.addActionListener(new ImportAction());
+
+ JMenuItem switchMenuItem = new JMenuItem("Switch...");
+ switchMenuItem.addActionListener(new SwitchAction());
+
+ JMenuItem startupMenuItem = new JMenuItem("Startup");
+ startupMenuItem.addActionListener(new StartupAction());
+
+ JMenuItem shutdownMenuItem = new JMenuItem("Shutdown");
+ shutdownMenuItem.addActionListener(new ShutdownAction());
+
+ JMenuItem loadChatLogMenuItem = new JMenuItem("Load chat log...");
+ loadChatLogMenuItem.addActionListener(new LoadChatFileAction());
+
+ JMenuItem loadSelfFileMenuItem = new JMenuItem("Load Self file...");
+ loadSelfFileMenuItem.addActionListener(new LoadSelfFileAction());
+
+ JMenuItem exitMenuItem = new JMenuItem("Exit");
+ exitMenuItem.addActionListener(new ExitAction());
+
+ fileMenu.add(spawnMenuItem);
+ fileMenu.add(bootstrapMenuItem);
+ fileMenu.add(rebootstrapMenuItem);
+ fileMenu.add(deleteMenuItem);
+ fileMenu.addSeparator();
+ fileMenu.add(createMenuItem);
+ fileMenu.add(destroyMenuItem);
+ fileMenu.add(importMenuItem);
+ fileMenu.add(switchMenuItem);
+ fileMenu.addSeparator();
+ fileMenu.add(startupMenuItem);
+ fileMenu.add(shutdownMenuItem);
+ fileMenu.addSeparator();
+ fileMenu.add(loadChatLogMenuItem);
+ fileMenu.add(loadSelfFileMenuItem);
+ fileMenu.addSeparator();
+ fileMenu.add(exitMenuItem);
+
+ return fileMenu;
+ }
+
+ /**
+ * Return the associated Bot instance.
+ */
+ public Bot getBot() {
+ return bot;
+ }
+
+ /**
+ * Set the associated Bot instance.
+ */
+ public void setBot(Bot bot) {
+ this.bot = bot;
+ this.bot.mind().getThought(Language.class).setLearningMode(LearningMode.Disabled);
+ if (this.BotPanel != null) {
+ this.BotPanel.setBot(bot);
+ }
+ }
+
+ public void exit() {
+ dispose();
+ System.exit(0);
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/client/gui/BotPanel.java b/ai-engine-test/source/org/botlibre/client/gui/BotPanel.java
new file mode 100644
index 00000000..cbdc1c4a
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/BotPanel.java
@@ -0,0 +1,114 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.Insets;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.ImageIcon;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+import org.botlibre.Bot;
+
+public class BotPanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Reference to Bot instance. **/
+ protected Bot bot;
+
+ protected List childPanels = new ArrayList();
+
+ private JTabbedPane tabPane;
+
+ public BotPanel(Bot bot)
+ {
+ setBot(bot);
+ buildContent();
+ }
+
+ protected void buildContent() {
+ buildTabPane();
+ setLayout(new GridBagLayout());
+ add(tabPane, new GridBagConstraints(0,0,1,1, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));
+ }
+
+ protected void buildTabPane() {
+ this.tabPane = new JTabbedPane();
+ this.tabPane.setTabPlacement(JTabbedPane.RIGHT);
+ ImageIcon icon = new ImageIcon(getClass().getResource("typing.gif"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Text", icon, new TextPanel(this));
+ icon = new ImageIcon(getClass().getResource("chat.jpg"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("IRC", icon, new IRCPanel(this));
+ icon = new ImageIcon(getClass().getResource("www.png"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Http", icon, new HttpPanel(this));
+ icon = new ImageIcon(getClass().getResource("Email.png"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Email", icon, new EmailPanel(this));
+ icon = new ImageIcon(getClass().getResource("twitter.png"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Twitter", icon, new TwitterPanel(this));
+ icon = new ImageIcon(getClass().getResource("eye.gif"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Vision", icon, new JPanel());
+ icon = new ImageIcon(getClass().getResource("brain.gif"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Bot", icon, new ContextPanel(this));
+ icon = new ImageIcon(getClass().getResource("DrawingHands.jpg"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Self", icon, new SelfPanel(this));
+ icon = new ImageIcon(getClass().getResource("log-icon.png"));
+ icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
+ this.tabPane.addTab("Log", icon, new StatusPanel(this));
+ }
+
+ /**
+ * Return the associated Bot instance.
+ */
+ public Bot getBot() {
+ return bot;
+ }
+
+ /**
+ * Set the associated Bot instance.
+ */
+ public void setBot(Bot bot) {
+ this.bot = bot;
+ for (ChildPanel child : getChildPanels()) {
+ child.resetBotInstance();
+ }
+ }
+
+ public List getChildPanels() {
+ return childPanels;
+ }
+
+ public void setChildPanels(List childPanels) {
+ this.childPanels = childPanels;
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/client/gui/ChildPanel.java b/ai-engine-test/source/org/botlibre/client/gui/ChildPanel.java
new file mode 100644
index 00000000..9d6682d9
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/ChildPanel.java
@@ -0,0 +1,52 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import javax.swing.JPanel;
+
+import org.botlibre.Bot;
+
+public abstract class ChildPanel extends JPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ public ChildPanel(BotPanel BotPanel)
+ {
+ this.BotPanel = BotPanel;
+ this.BotPanel.getChildPanels().add(this);
+ buildContent();
+ }
+
+ protected abstract void buildContent();
+
+ /**
+ * Return the associated Bot instance.
+ */
+ public Bot getBot() {
+ return this.BotPanel.getBot();
+ }
+
+ /**
+ * Reset any state specific to the Bot instance when changed.
+ */
+ public void resetBotInstance() {
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/ContextPanel.java b/ai-engine-test/source/org/botlibre/client/gui/ContextPanel.java
new file mode 100644
index 00000000..50657348
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/ContextPanel.java
@@ -0,0 +1,447 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTree;
+import javax.swing.KeyStroke;
+import javax.swing.border.LineBorder;
+import javax.swing.event.TreeModelListener;
+import javax.swing.text.Keymap;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.sense.context.Context;
+import org.botlibre.sense.context.Selector;
+
+public class ContextPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ protected JTree treePane;
+ protected JLabel selectedLabel;
+ protected JTextArea selectedPane;
+ protected JLabel relationshipLabel;
+ protected JTextArea relationshipPane;
+ protected JLabel filterLabel;
+ protected JTextArea filterPane;
+ protected JScrollPane scrollPane;
+ protected JButton selectButton;
+ protected JButton relationshipButton;
+ protected JButton associateButton;
+ protected JButton instantiateButton;
+ protected JButton refreshButton;
+ protected JButton deleteButton;
+ protected JButton referencesButton;
+ protected JRadioButton shortTermButton;
+ protected JRadioButton longTermButton;
+
+ protected Vertex selection;
+ protected Vertex relationship;
+
+ public class SelectAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (treePane.getSelectionPath() == null) {
+ return;
+ }
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ if (selected instanceof Relationship) {
+ selection = ((Relationship)selected).getTarget();
+ } else if (selected instanceof Vertex) {
+ selection = (Vertex)selected;
+ }
+ if (selection != null) {
+ selectedPane.setText(selection.toString());
+ getBot().awareness().getSense(Context.class.getName()).input(selection);
+ }
+ }
+ }
+
+ public class RelationshipAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (treePane.getSelectionPath() == null) {
+ return;
+ }
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ if (selected instanceof Relationship) {
+ relationship = ((Relationship)selected).getTarget();
+ } else if (selected instanceof Vertex) {
+ relationship = (Vertex)selected;
+ }
+ if (relationship != null) {
+ relationshipPane.setText(relationship.toString());
+ }
+ }
+ }
+
+ public class DeleteAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (treePane.getSelectionPath() == null) {
+ return;
+ }
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ if (selected instanceof Relationship) {
+ Relationship relationship = (Relationship)selected;
+ relationship.getSource().internalRemoveRelationship(relationship);
+ } else if (selected instanceof Vertex) {
+ Vertex vertex = (Vertex)selected;
+ getSelectedNetwork().removeVertexAndReferences(vertex);
+ }
+ getBot().memory().save();
+ }
+ }
+
+ /**
+ * Create a new vertex that is an instance of the current selection.
+ */
+ public class InstantiateAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (treePane.getSelectionPath() == null) {
+ return;
+ }
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ Vertex classification = null;
+ if (selected instanceof Relationship) {
+ classification = ((Relationship)selected).getTarget();
+ } else if (selected instanceof Vertex) {
+ classification = (Vertex)selected;
+ }
+ if (classification != null) {
+ Network network = getBot().memory().getShortTermMemory();
+ Vertex instance = network.createVertex();
+ Vertex instantiationType = network.createVertex(Primitive.INSTANTIATION);
+ classification = network.createVertex(classification);
+ instance.addRelationship(instantiationType, classification);
+ selection = instance;
+ selectedPane.setText(selection.toString());
+ getBot().memory().save();
+ getBot().awareness().getSense(Context.class.getName()).input(selection);
+ }
+ }
+ }
+
+ /**
+ * Associate the selected vertex with the selected relationship, with the current selection as target.
+ */
+ public class AssociateAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ Vertex target = null;
+ if (selected instanceof Relationship) {
+ target = ((Relationship)selected).getTarget();
+ } else if (selected instanceof Vertex) {
+ target = (Vertex)selected;
+ }
+ if ((target != null) && (relationship != null) && (selection != null)) {
+ Network network = getBot().memory().getShortTermMemory();
+ Vertex source = network.createVertex(selection);
+ Vertex relationshipType = network.createVertex(relationship);
+ target = network.createVertex(target);
+ source.addRelationship(relationshipType, target);
+ getBot().memory().save();
+ }
+ }
+ }
+
+ public class RefreshAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ getSelectedNetwork().clear();
+ resetState();
+ }
+ }
+
+ public class ReferencesAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ if (treePane.getSelectionPath() == null) {
+ return;
+ }
+ Object selected = treePane.getSelectionPath().getLastPathComponent();
+ if (!(selected instanceof Vertex)) {
+ return;
+ }
+ long id = ((Vertex)selected).getId();
+ filterPane.setText("jpql: Select v from Vertex v join v.allRelationships r where r.target.id = " + id);
+ resetState();
+ }
+ }
+
+ public class ShortTermAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ shortTermButton.setSelected(true);
+ longTermButton.setSelected(false);
+ resetState();
+ }
+ }
+
+ public class LongTermAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ longTermButton.setSelected(true);
+ shortTermButton.setSelected(false);
+ resetState();
+ }
+ }
+
+ public ContextPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public Network getSelectedNetwork() {
+ if (this.longTermButton.isSelected()) {
+ return getBot().memory().getLongTermMemory();
+ } else {
+ return getBot().memory().getShortTermMemory();
+ }
+ }
+
+ public void resetState() {
+ TreeModel model = new TreeModel() {
+ /** Stores list of root vertices. */
+ List vertices;
+ /** Stores list of relationships per vertex. */
+ Map> relationships = new HashMap>();
+
+ @SuppressWarnings("unchecked")
+ List getVertices() {
+ if (this.vertices == null) {
+ this.vertices = new ArrayList();
+ List result = null;
+ String filter = filterPane.getText().trim();
+ if ((filter.length() > 5) && (filter.substring(0, 5).equals("jpql:"))) {
+ result = getSelectedNetwork().findAllQuery(filter.substring(5, filter.length()));
+ } else if (filter.length() > 0) {
+ result = getSelectedNetwork().findAllLike(filter);
+ } else {
+ result = getSelectedNetwork().findAll();
+ }
+ this.vertices.addAll(result);
+ }
+ return this.vertices;
+ }
+
+ List getRelationships(Vertex vertex) {
+ List parentRelationships = this.relationships.get(vertex);
+ if (parentRelationships == null) {
+ parentRelationships = new ArrayList();
+ Iterator iterator = vertex.orderedAllRelationships();
+ while (iterator.hasNext()) {
+ parentRelationships.add(iterator.next());
+ }
+ this.relationships.put(vertex, parentRelationships);
+ }
+ return parentRelationships;
+ }
+
+ public Object getRoot() {
+ return getBot().memory();
+ }
+
+ public Object getChild(Object parent, int index) {
+ Object child = null;
+ if (parent == getBot().memory()) {
+ child = getVertices().get(index);
+ } else if (parent instanceof Relationship) {
+ if (index == 0) {
+ child = ((Relationship)parent).getType();
+ } else if (index == 1) {
+ child = ((Relationship)parent).getTarget();
+ } else {
+ child = ((Relationship)parent).getMeta();
+ }
+ } else if (parent instanceof Vertex) {
+ child = getRelationships((Vertex)parent).get(index);
+ }
+ return child;
+ }
+
+ public int getChildCount(Object parent) {
+ int count = 0;
+ if (parent == getBot().memory()) {
+ count = getVertices().size();
+ } else if (parent instanceof Relationship) {
+ if (((Relationship)parent).getMeta() != null) {
+ count = 3;
+ } else {
+ count = 2;
+ }
+ } else if (parent instanceof Vertex) {
+ count = getRelationships((Vertex)parent).size();
+ }
+ return count;
+ }
+ public boolean isLeaf(Object node) {
+ return false;
+ }
+
+ public void valueForPathChanged(TreePath path, Object newValue) {
+
+ }
+
+ public int getIndexOfChild(Object parent, Object child) {
+ int index = -1;
+ if (parent == getBot().memory()) {
+ index = getVertices().indexOf(child);
+ } else if (parent instanceof Relationship) {
+ if (child == ((Relationship)parent).getType()) {
+ index = 0;
+ } else if (child == ((Relationship)parent).getTarget()) {
+ index = 1;
+ } else {
+ index = 2;
+ }
+ } else if (parent instanceof Vertex) {
+ index = getRelationships((Vertex)parent).indexOf(child);
+ }
+ return index;
+ }
+
+ public void addTreeModelListener(TreeModelListener l) {
+
+ }
+
+ public void removeTreeModelListener(TreeModelListener l) {
+
+ }
+
+ };
+ this.treePane.setModel(model);
+ }
+
+ public void initKeyMap(JTextArea text) {
+ Keymap keyMap = JTextArea.addKeymap("EnterSubmit", text.getKeymap());
+ KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
+ keyMap.addActionForKeyStroke(key, new RefreshAction());
+ text.setKeymap(keyMap);
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.treePane = new JTree();
+ this.scrollPane = new JScrollPane(this.treePane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.selectedPane = new JTextArea();
+ this.selectedPane.setEditable(false);
+ this.selectedPane.setBorder(LineBorder.createGrayLineBorder());
+
+ this.selectedLabel = new JLabel();
+ this.selectedLabel.setText("Selection:");
+
+ this.relationshipPane = new JTextArea();
+ this.relationshipPane.setEditable(false);
+ this.relationshipPane.setBorder(LineBorder.createGrayLineBorder());
+
+ this.relationshipLabel = new JLabel();
+ this.relationshipLabel.setText("Relationship:");
+
+ this.filterPane = new JTextArea();
+ initKeyMap(this.filterPane);
+ this.filterPane.setBorder(LineBorder.createGrayLineBorder());
+
+ this.filterLabel = new JLabel();
+ this.filterLabel.setText("Filter:");
+
+ this.selectButton = new JButton("Select");
+ this.selectButton.addActionListener(new SelectAction());
+
+ this.relationshipButton = new JButton("Relationship");
+ this.relationshipButton.addActionListener(new RelationshipAction());
+
+ this.associateButton = new JButton("Associate");
+ this.associateButton.addActionListener(new AssociateAction());
+
+ this.instantiateButton = new JButton("Instantiate");
+ this.instantiateButton.addActionListener(new InstantiateAction());
+
+ this.refreshButton = new JButton("Refresh");
+ this.refreshButton.addActionListener(new RefreshAction());
+
+ this.referencesButton = new JButton("References");
+ this.referencesButton.addActionListener(new ReferencesAction());
+
+ this.deleteButton = new JButton("Delete");
+ this.deleteButton.addActionListener(new DeleteAction());
+
+ this.shortTermButton = new JRadioButton("Short Term");
+ this.shortTermButton.addActionListener(new ShortTermAction());
+ this.shortTermButton.setSelected(true);
+
+ this.longTermButton = new JRadioButton("Long Term");
+ this.longTermButton.addActionListener(new LongTermAction());
+
+ add(this.scrollPane, new GridBagConstraints(0,0,2,10, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.selectedLabel, new GridBagConstraints(0,11,1,1, 0,0, GridBagConstraints.WEST,GridBagConstraints.NONE, new Insets(4,4,4,4), 0,0));
+ add(this.selectedPane, new GridBagConstraints(1,11,1,1, 1.0,0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.relationshipLabel, new GridBagConstraints(0,12,1,1, 0,0, GridBagConstraints.WEST,GridBagConstraints.NONE, new Insets(4,4,4,4), 0,0));
+ add(this.relationshipPane, new GridBagConstraints(1,12,1,1, 1.0,0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.filterLabel, new GridBagConstraints(0,13,1,1, 0,0, GridBagConstraints.WEST,GridBagConstraints.NONE, new Insets(4,4,4,4), 0,0));
+ add(this.filterPane, new GridBagConstraints(1,13,1,1, 1.0,0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.shortTermButton, new GridBagConstraints(2,0,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.longTermButton, new GridBagConstraints(2,1,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.refreshButton, new GridBagConstraints(2,2,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.referencesButton, new GridBagConstraints(2,3,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.selectButton, new GridBagConstraints(2,4,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.relationshipButton, new GridBagConstraints(2,5,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.associateButton, new GridBagConstraints(2,6,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.instantiateButton, new GridBagConstraints(2,7,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.deleteButton, new GridBagConstraints(2,8,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetBotInstance();
+ }
+
+ /**
+ * Reset any state specific to the Bot instance when changed.
+ */
+ public void resetBotInstance() {
+ Context sense = (Context)getBot().awareness().getSense(Context.class.getName());
+ sense.setSelector(new Selector() {
+ public Object getSelection() {
+ return selection;
+ }
+
+ public void setSelection(Object selection) {
+
+ }
+ });
+ resetState();
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/DrawingHands.jpg b/ai-engine-test/source/org/botlibre/client/gui/DrawingHands.jpg
new file mode 100644
index 00000000..8a9f2ff0
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/DrawingHands.jpg differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/Email.png b/ai-engine-test/source/org/botlibre/client/gui/Email.png
new file mode 100644
index 00000000..c87d1bb2
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/Email.png differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/EmailPanel.java b/ai-engine-test/source/org/botlibre/client/gui/EmailPanel.java
new file mode 100644
index 00000000..25a855d5
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/EmailPanel.java
@@ -0,0 +1,141 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.botlibre.sense.email.Email;
+
+public class EmailPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ protected JCheckBox enabledCheckBox;
+ protected JTextField emailAddressText;
+ protected JTextField incomingHostText;
+ protected JTextField incomingPortText;
+ protected JTextField outgoingHostText;
+ protected JTextField outgoingPortText;
+ protected JTextField protocolText;
+ protected JCheckBox isSSLRequiredCheckBox;
+ protected JTextField usernameText;
+ protected JTextField passwordText;
+ protected JTextArea signatureText;
+
+ public class EnableAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ Email email = getBot().awareness().getSense(Email.class);
+ email.setEmailAddress(EmailPanel.this.emailAddressText.getText());
+ email.setIncomingHost(EmailPanel.this.incomingHostText.getText());
+ email.setIncomingPort(Integer.valueOf(EmailPanel.this.incomingPortText.getText()));
+ email.setOutgoingHost(EmailPanel.this.outgoingHostText.getText());
+ email.setOutgoingPort(Integer.valueOf(EmailPanel.this.outgoingPortText.getText()));
+ email.setProtocol(EmailPanel.this.protocolText.getText());
+ email.setUsername(EmailPanel.this.usernameText.getText());
+ email.setPassword(EmailPanel.this.passwordText.getText());
+ email.setSignature(EmailPanel.this.signatureText.getText());
+ email.setSSLRequired(EmailPanel.this.isSSLRequiredCheckBox.isSelected());
+ if (email != null) {
+ email.setIsEnabled(EmailPanel.this.enabledCheckBox.isSelected());
+ }
+ } catch (NumberFormatException exception) {
+ getBot().log(this, exception);
+ resetState();
+ }
+ }
+ }
+
+ public EmailPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void resetState() {
+ Email email = getBot().awareness().getSense(Email.class);
+ if (email != null) {
+ this.enabledCheckBox.setSelected(email.isEnabled());
+ this.emailAddressText.setText(email.getEmailAddress());
+ this.incomingHostText.setText(email.getIncomingHost());
+ this.incomingPortText.setText(String.valueOf(email.getIncomingPort()));
+ this.outgoingHostText.setText(email.getOutgoingHost());
+ this.outgoingPortText.setText(String.valueOf(email.getOutgoingPort()));
+ this.usernameText.setText(email.getUsername());
+ this.passwordText.setText(email.getPassword());
+ this.protocolText.setText(email.getProtocol());
+ this.isSSLRequiredCheckBox.setSelected(email.isSSLRequired());
+ this.signatureText.setText(email.getSignature());
+ }
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.enabledCheckBox = new JCheckBox();
+ this.enabledCheckBox.setText("Email Enabled");
+ this.enabledCheckBox.addActionListener(new EnableAction());
+
+ this.emailAddressText = new JTextField();
+ this.incomingHostText = new JTextField();
+ this.incomingPortText = new JTextField();
+ this.outgoingHostText = new JTextField();
+ this.outgoingPortText = new JTextField();
+ this.protocolText = new JTextField();
+ this.usernameText = new JTextField();
+ this.passwordText = new JTextField();
+
+ this.signatureText = new JTextArea();
+ JScrollPane signatureScrollPane = new JScrollPane(this.signatureText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+
+ this.isSSLRequiredCheckBox = new JCheckBox();
+ this.isSSLRequiredCheckBox.setText("SSL");
+
+ add(this.enabledCheckBox, new GridBagConstraints(0,0,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Email Address:"), new GridBagConstraints(0,1,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.emailAddressText, new GridBagConstraints(1,1,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Incoming Host:"), new GridBagConstraints(0,2,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.incomingHostText, new GridBagConstraints(1,2,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Incoming Port:"), new GridBagConstraints(0,3,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.incomingPortText, new GridBagConstraints(1,3,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Outgoing Host:"), new GridBagConstraints(0,4,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.outgoingHostText, new GridBagConstraints(1,4,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Outgoing Port:"), new GridBagConstraints(0,5,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.outgoingPortText, new GridBagConstraints(1,5,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Protocol:"), new GridBagConstraints(0,6,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.protocolText, new GridBagConstraints(1,6,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.isSSLRequiredCheckBox, new GridBagConstraints(0,7,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Username:"), new GridBagConstraints(0,8,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.usernameText, new GridBagConstraints(1,8,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Password:"), new GridBagConstraints(0,9,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.passwordText, new GridBagConstraints(1,9,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Signature:"), new GridBagConstraints(0,10,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(signatureScrollPane, new GridBagConstraints(0,11,3,3, 1.0,1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetState();
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/HttpPanel.java b/ai-engine-test/source/org/botlibre/client/gui/HttpPanel.java
new file mode 100644
index 00000000..cc054d09
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/HttpPanel.java
@@ -0,0 +1,116 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+import javax.swing.text.Keymap;
+
+import org.botlibre.api.sense.Sense;
+import org.botlibre.sense.http.Http;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class HttpPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ protected JComboBox websiteComboBox;
+ protected JTextArea outputTextPane;
+ protected JScrollPane outputScrollPane;
+ protected JButton submitButton;
+
+ public class SubmitAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ inputWebsite();
+ }
+ }
+
+ public HttpPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void initKeyMap(JTextArea text) {
+ Keymap keyMap = JTextArea.addKeymap("EnterSubmit", text.getKeymap());
+ KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
+ keyMap.addActionForKeyStroke(key, new SubmitAction());
+ text.setKeymap(keyMap);
+ }
+
+ /**
+ * Input the website.
+ */
+ public void inputWebsite() {
+ String input = ((String)websiteComboBox.getSelectedItem()).trim();
+ if (input.length() == 0) {
+ return;
+ }
+ if (input.indexOf("http://") == -1 && input.indexOf("https://") == -1) {
+ input = "http://" + input;
+ }
+ try {
+ final URL url = new URL(input);
+ final Sense sense = getBot().awareness().getSense(Http.class);
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ sense.input(url);
+ }
+ };
+ thread.start();
+ } catch (Exception badURL) {
+ getBot().log(this, badURL);
+ return;
+ }
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.websiteComboBox = new JComboBox();
+ this.websiteComboBox.addItem("https://en.wiktionary.org/wiki/");
+ this.websiteComboBox.addItem("http://www.freebase.com/view/en/");
+ this.websiteComboBox.addItem("http://www.");
+ this.websiteComboBox.setEditable(true);
+ //initKeyMap(this.websiteComboBox);
+
+ this.outputTextPane = new JTextArea();
+ this.outputTextPane.setEditable(false);
+ this.outputScrollPane = new JScrollPane(this.outputTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.submitButton = new JButton("Submit");
+ this.submitButton.addActionListener(new SubmitAction());
+
+ add(this.outputScrollPane, new GridBagConstraints(0,1,1,5, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.websiteComboBox, new GridBagConstraints(0,0,1,1, 1.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.submitButton, new GridBagConstraints(1,0,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/IRCPanel.java b/ai-engine-test/source/org/botlibre/client/gui/IRCPanel.java
new file mode 100644
index 00000000..5318e676
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/IRCPanel.java
@@ -0,0 +1,181 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.botlibre.sense.chat.IRC;
+import org.botlibre.thought.language.Language.LanguageState;
+import org.relayirc.chatengine.ChannelAdapter;
+import org.relayirc.chatengine.ChannelEvent;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class IRCPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ protected int maxLog = 10000;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ protected JTextArea outputTextPane;
+ protected JScrollPane outputScrollPane;
+ protected JComboBox stateComboBox;
+ protected JButton connectButton;
+ protected JButton disconnectButton;
+ protected JButton clearButton;
+ protected JComboBox serverComboBox;
+ protected JComboBox channelComboBox;
+ protected JTextField nickText;
+
+ public class ClearAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ outputTextPane.setText("");
+ }
+ }
+
+ public class ConnectAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ // Default to listening.
+ IRC sense = (IRC)getBot().awareness().getSense(IRC.class.getName());
+ stateComboBox.setSelectedItem(sense.getLanguageState());
+ sense.setServerName(((String)serverComboBox.getSelectedItem()).trim());
+ sense.setChannelName(((String)channelComboBox.getSelectedItem()).trim());
+ String nick = nickText.getText().trim();
+ sense.setNick(nick);
+ sense.setNickAlt(nick + "_");
+ sense.setUserName(nick);
+ sense.setRealName(nick);
+ sense.connect();
+ }
+ }
+
+ public class DisconnectAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ IRC sense = (IRC)getBot().awareness().getSense(IRC.class.getName());
+ sense.disconnect();
+ }
+ }
+
+ public class StateChangedAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ LanguageState state = (LanguageState)stateComboBox.getSelectedItem();
+
+ IRC sense = (IRC)getBot().awareness().getSense(IRC.class.getName());
+ sense.setLanguageState(state);
+ }
+ }
+
+ public IRCPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void resetState() {
+ IRC sense = (IRC)getBot().awareness().getSense(IRC.class.getName());
+ stateComboBox.setSelectedItem(sense.getLanguageState());
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.outputTextPane = new JTextArea();
+ this.outputTextPane.setEditable(false);
+ this.outputScrollPane = new JScrollPane(this.outputTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.stateComboBox = new JComboBox(LanguageState.values());
+ this.stateComboBox.addActionListener(new StateChangedAction());
+
+ this.connectButton = new JButton("Connect");
+ this.connectButton.addActionListener(new ConnectAction());
+
+ this.disconnectButton = new JButton("Disconnect");
+ this.disconnectButton.addActionListener(new DisconnectAction());
+
+ this.clearButton = new JButton("Clear");
+ this.clearButton.addActionListener(new ClearAction());
+
+ this.serverComboBox = new JComboBox();
+ this.serverComboBox.setEditable(true);
+ this.serverComboBox.addItem("irc.freenode.org");
+ this.serverComboBox.addItem("irc.icq.com");
+ this.serverComboBox.addItem("irc.quakenet.org");
+ this.serverComboBox.addItem("irc.efnet.org");
+ this.serverComboBox.addItem("irc.undernet.org");
+ this.channelComboBox = new JComboBox();
+ this.channelComboBox.setEditable(true);
+ this.channelComboBox.addItem("#Bot");
+ this.channelComboBox.addItem("#ai");
+ this.channelComboBox.addItem("##linux");
+ this.channelComboBox.addItem("##politics");
+ this.channelComboBox.addItem("#teens");
+ this.channelComboBox.addItem("#20_something");
+ this.channelComboBox.addItem("#30_something");
+ this.channelComboBox.addItem("#40_something");
+ this.channelComboBox.addItem("#christianity");
+ this.channelComboBox.addItem("#buddhism");
+
+ this.nickText = new JTextField();
+
+ add(this.outputScrollPane, new GridBagConstraints(0,0,1,15, 1.0,0.5, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.connectButton, new GridBagConstraints(1,0,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.disconnectButton, new GridBagConstraints(1,1,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.clearButton, new GridBagConstraints(1,2,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.stateComboBox, new GridBagConstraints(1,3,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Server:"), new GridBagConstraints(1,4,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.serverComboBox, new GridBagConstraints(1,5,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Channel:"), new GridBagConstraints(1,6,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.channelComboBox, new GridBagConstraints(1,7,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Nick:"), new GridBagConstraints(1,8,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.nickText, new GridBagConstraints(1,9,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetBotInstance();
+ }
+
+ /**
+ * Reset any state specific to the Bot instance when changed.
+ */
+ public void resetBotInstance() {
+ // Set a writer on the text entry into the text sense.
+ final IRC sense = (IRC)getBot().awareness().getSense(IRC.class.getName());
+ this.nickText.setText(sense.getNick());
+ sense.getChannelListeners().add(new ChannelAdapter() {
+ public void onMessage(ChannelEvent event) {
+ String text = outputTextPane.getText();
+ if (text.length() > maxLog) {
+ text = text.substring(text.length() - maxLog);
+ }
+ outputTextPane.setText(text + "\n"
+ + event.getOriginNick() + ": " + sense.trimSpecialChars((String)event.getValue()));
+ resetState();
+ }
+ });
+ resetState();
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/SelfPanel.java b/ai-engine-test/source/org/botlibre/client/gui/SelfPanel.java
new file mode 100644
index 00000000..42a1cd15
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/SelfPanel.java
@@ -0,0 +1,227 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.AbstractAction;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.self.SelfCompiler;
+import org.botlibre.self.SelfDecompiler;
+import org.botlibre.thought.language.Comprehension;
+import org.botlibre.thought.language.Language;
+import org.botlibre.thought.language.Language.LearningMode;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class SelfPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ protected JTextArea codeTextPane;
+ protected JScrollPane scrollPane;
+ protected JTextArea errorTextPane;
+ protected JScrollPane errorScrollPane;
+ protected JButton newButton;
+ protected JButton deleteButton;
+ protected JButton resetButton;
+ protected JComboBox stateMachineComboBox;
+ protected JCheckBox comprehensionCheckBox;
+ protected JCheckBox learningCheckBox;
+
+ public class DeleteAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ Vertex stateMachine = (Vertex)stateMachineComboBox.getSelectedItem();
+ if (stateMachine == null) {
+ resetState();
+ return;
+ }
+ Network memory = getBot().memory().newMemory();
+ try {
+ Vertex language = memory.createVertex(Language.class);
+ stateMachine = memory.createVertex(stateMachine);
+ stateMachine.setPinned(false);
+ for (Relationship relationship : language.getRelationships(Primitive.STATE)) {
+ if (relationship.getTarget().equals(stateMachine)) {
+ language.internalRemoveRelationship(relationship);
+ break;
+ }
+ }
+ memory.save();
+ resetState();
+ } catch (Exception failed) {
+ memory.clear();
+ errorTextPane.setText(failed.getMessage());
+ return;
+ }
+ errorTextPane.setText("");
+ }
+ }
+
+ public class ResetAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ resetState();
+ }
+ }
+
+ public class ComprehensionAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ getBot().mind().getThought(Comprehension.class).setEnabled(comprehensionCheckBox.isSelected());
+ }
+ }
+
+ public class LearningAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ if (learningCheckBox.isSelected()) {
+ getBot().mind().getThought(Language.class).setLearningMode(LearningMode.Everyone);
+ } else {
+ getBot().mind().getThought(Language.class).setLearningMode(LearningMode.Disabled);
+ }
+ }
+ }
+
+ public class NewAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ String code = codeTextPane.getText();
+ Network memory = getBot().memory().newMemory();
+ try {
+ Vertex stateMachine = SelfCompiler.getCompiler().parseStateMachine(code, true, memory);
+ //stateMachine.pinDescendants();
+ Vertex language = memory.createVertex(Language.class);
+ language.addRelationship(Primitive.STATE, stateMachine);
+ memory.save();
+ errorTextPane.setText("");
+ resetState();
+ } catch (Exception failed) {
+ memory.clear();
+ errorTextPane.setText(failed.getMessage());
+ getBot().log(this, failed);
+ return;
+ }
+ errorTextPane.setText("");
+ }
+ }
+
+ public class StateChangedAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ Vertex stateMachine = (Vertex)stateMachineComboBox.getSelectedItem();
+ if (stateMachine == null) {
+ return;
+ }
+ codeTextPane.setText(SelfDecompiler.getDecompiler().decompileStateMachine(stateMachine, stateMachine.getNetwork()));
+ } catch (Exception failed) {
+ failed.printStackTrace();
+ errorTextPane.setText(failed.getMessage());
+ return;
+ }
+ errorTextPane.setText("");
+ }
+ }
+
+ public SelfPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void resetState() {
+ try {
+ Vector states = new Vector();
+ Network memory = getBot().memory().newMemory();
+ List relationships = memory.createVertex(Language.class).orderedRelationships(Primitive.STATE);
+ if (relationships != null) {
+ for (Relationship relationship : relationships) {
+ states.add(relationship.getTarget());
+ }
+ }
+ this.stateMachineComboBox.setModel(new DefaultComboBoxModel(states));
+ } catch (Exception failed) {
+ errorTextPane.setText(failed.getMessage());
+ return;
+ }
+ errorTextPane.setText("");
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.codeTextPane = new JTextArea();
+ this.scrollPane = new JScrollPane(this.codeTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.errorTextPane = new JTextArea();
+ this.errorTextPane.setEditable(false);
+ this.errorScrollPane = new JScrollPane(this.errorTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.deleteButton = new JButton("Remove state machine");
+ this.deleteButton.addActionListener(new DeleteAction());
+
+ this.newButton = new JButton("New state machine");
+ this.newButton.addActionListener(new NewAction());
+
+ this.resetButton = new JButton("Refresh");
+ this.resetButton.addActionListener(new ResetAction());
+
+ this.comprehensionCheckBox = new JCheckBox("Comprehension");
+ this.comprehensionCheckBox.addActionListener(new ComprehensionAction());
+ this.comprehensionCheckBox.setSelected(true);
+ this.learningCheckBox = new JCheckBox("Learning");
+ this.learningCheckBox.addActionListener(new LearningAction());
+ this.learningCheckBox.setSelected(false);
+
+ this.stateMachineComboBox = new JComboBox();
+ this.stateMachineComboBox.addActionListener(new StateChangedAction());
+
+ add(this.scrollPane, new GridBagConstraints(0,0,1,7, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.errorScrollPane, new GridBagConstraints(0,7,1,6, 1.0,0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,100));
+ add(this.newButton, new GridBagConstraints(1,0,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.deleteButton, new GridBagConstraints(1,1,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.resetButton, new GridBagConstraints(1,2,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.stateMachineComboBox, new GridBagConstraints(1,3,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.comprehensionCheckBox, new GridBagConstraints(1,4,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.learningCheckBox, new GridBagConstraints(1,5,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetState();
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/StatusPanel.java b/ai-engine-test/source/org/botlibre/client/gui/StatusPanel.java
new file mode 100644
index 00000000..6f5aa0b9
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/StatusPanel.java
@@ -0,0 +1,174 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Calendar;
+import java.util.logging.Level;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.botlibre.LogListener;
+import org.botlibre.Bot;
+import org.botlibre.util.Utils;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class StatusPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ protected int maxLog = 10000;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ protected JButton dumpStatusButton;
+ protected JButton dumpMemoryButton;
+ protected JButton clearButton;
+ protected JTextArea textPane;
+ protected JScrollPane scrollPane;
+ protected JComboBox logLevelComboBox;
+
+ public class ClearAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ textPane.setText("");
+ }
+ }
+
+ public class LogLevelAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ getBot().setDebugLevel((Level)logLevelComboBox.getSelectedItem());
+ }
+ }
+
+ public class DumpMemoryAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (textPane.getText().length() > 0) {
+ textPane.setText(textPane.getText() + "\n");
+ }
+ textPane.setText(textPane.getText() + "Active Memory:\n");
+ synchronized (getBot().memory()) {
+ textPane.setText(textPane.getText() + getBot().memory().getActiveMemory().toString());
+ textPane.setText(textPane.getText() + "\nShort Term Memory:\n");
+ textPane.setText(textPane.getText() + getBot().memory().getShortTermMemory().toString());
+ textPane.setText(textPane.getText() + "\nLong Term Memory:\n");
+ textPane.setText(textPane.getText() + getBot().memory().getLongTermMemory().toString());
+ }
+ }
+ }
+
+ public class DumpStatusAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ if (textPane.getText().length() > 0) {
+ textPane.setText(textPane.getText() + "\n");
+ }
+ textPane.setText(textPane.getText() + "Bot:\n");
+ textPane.setText(textPane.getText() + getBot().fullToString());
+ }
+ }
+
+ public StatusPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.dumpStatusButton = new JButton("Dump Status");
+ this.dumpStatusButton.addActionListener(new DumpStatusAction());
+
+ this.dumpMemoryButton = new JButton("Dump Memory");
+ this.dumpMemoryButton.addActionListener(new DumpMemoryAction());
+
+ this.clearButton = new JButton("Clear");
+ this.clearButton.addActionListener(new ClearAction());
+
+ this.logLevelComboBox = new JComboBox();
+ for (Level level : Bot.LEVELS) {
+ this.logLevelComboBox.addItem(level);
+ }
+ this.logLevelComboBox.setSelectedItem(getBot().getDebugLevel());
+ this.logLevelComboBox.addActionListener(new LogLevelAction());
+
+ JLabel logLevelLabel = new JLabel();
+ logLevelLabel.setText("Log Level:");
+
+ this.textPane = new JTextArea();
+ this.textPane.setEditable(false);
+ this.scrollPane = new JScrollPane(this.textPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ add(this.scrollPane, new GridBagConstraints(0,0,1,6, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.dumpStatusButton, new GridBagConstraints(1,0,1,1, 0,0, GridBagConstraints.EAST,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.dumpMemoryButton, new GridBagConstraints(1,1,1,1, 0,0, GridBagConstraints.EAST,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.clearButton, new GridBagConstraints(1,2,1,1, 0,0, GridBagConstraints.EAST,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(logLevelLabel, new GridBagConstraints(1,3,1,1, 0,0, GridBagConstraints.EAST,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.logLevelComboBox, new GridBagConstraints(1,4,1,1, 0,0, GridBagConstraints.EAST,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetBotInstance();
+ }
+
+ /**
+ * Reset any state specific to the Bot instance when changed.
+ */
+ public void resetBotInstance() {
+ getBot().addLogListener(new LogListener() {
+
+ /**
+ * Notify a logging level change.
+ */
+ public void logLevelChange(Level level) {
+
+ }
+
+ @Override
+ public void log(Object source, String message, Level level, Object[] arguments) {
+ StatusPanel.this.textPane.append(Utils.printDate(Calendar.getInstance()) + " - " + level + " -- " + source + ":" + message);
+ for (Object argument : arguments) {
+ StatusPanel.this.textPane.append(" - " + argument);
+ }
+ StatusPanel.this.textPane.append("\n");
+ }
+
+ @Override
+ public void log(Throwable error) {
+ StatusPanel.this.textPane.append(Utils.printDate(Calendar.getInstance()) + " - " + Level.SEVERE + " -- " + error.getMessage() + "\n");
+ StringWriter writer = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(writer);
+ error.printStackTrace(printWriter);
+ printWriter.flush();
+ writer.flush();
+ String logText = writer.toString();
+ if (logText.length() > StatusPanel.this.maxLog) {
+ logText = logText.substring(logText.length() - StatusPanel.this.maxLog);
+ }
+ StatusPanel.this.textPane.append(writer.toString() + "\n");
+ }
+
+ });
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/TextPanel.java b/ai-engine-test/source/org/botlibre/client/gui/TextPanel.java
new file mode 100644
index 00000000..353704dc
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/TextPanel.java
@@ -0,0 +1,248 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.io.Writer;
+
+import javax.swing.AbstractAction;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+import javax.swing.text.Keymap;
+
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.emotion.EmotionalState;
+import org.botlibre.knowledge.ImageData;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.self.SelfCompiler;
+import org.botlibre.sense.text.TextEntry;
+import org.botlibre.sense.text.TextInput;
+import org.botlibre.thought.language.Language.LanguageState;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class TextPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ protected JTextArea inputTextPane;
+ protected JTextArea outputTextPane;
+ protected JScrollPane inputScrollPane;
+ protected JScrollPane outputScrollPane;
+ protected JButton submitButton;
+ protected JButton clearButton;
+ protected JCheckBox correctionCheckBox;
+ protected JCheckBox offensiveCheckBox;
+ protected JComboBox stateComboBox;
+ protected JComboBox emotionComboBox;
+ protected JLabel avatarLabel;
+
+ public class ClearAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ inputTextPane.setText("");
+ outputTextPane.setText("");
+ }
+ }
+
+ public class SubmitAction extends AbstractAction implements ActionListener {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent event) {
+ try {
+ String text = inputTextPane.getText();
+ TextEntry sense = getBot().awareness().getSense(TextEntry.class);
+ if ((text.length() > 3) && text.substring(0, 2).equals("&&")) {
+ // Allow Self script execution.
+ Network memory = getBot().memory().newMemory();
+ Vertex result = SelfCompiler.getCompiler().evaluateEquation(
+ text.substring(2, text.length()), sense.getUser(memory), memory.createVertex(Primitive.SELF), false, memory);
+ memory.save();
+ outputTextPane.append("Script:");
+ outputTextPane.append(text.substring(2, text.length()));
+ outputTextPane.append("\n");
+ outputTextPane.append("Result:");
+ outputTextPane.append(result.toString());
+ outputTextPane.append("\n");
+ } else {
+ outputTextPane.append("You:");
+ outputTextPane.append(text);
+ outputTextPane.append("\n");
+
+ TextInput textInput = new TextInput(text);
+ textInput.setCorrection(correctionCheckBox.isSelected());
+ textInput.setOffended(offensiveCheckBox.isSelected());
+ sense.input(textInput);
+ }
+ inputTextPane.setText("");
+ correctionCheckBox.setSelected(false);
+ offensiveCheckBox.setSelected(false);
+ outputScrollPane.getVerticalScrollBar().setValue(outputScrollPane.getVerticalScrollBar().getMaximum());
+ } catch (Exception exception) {
+ JOptionPane.showMessageDialog(TextPanel.this,
+ exception.getMessage(),
+ "Input error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public class StateChangedAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ LanguageState state = (LanguageState)stateComboBox.getSelectedItem();
+
+ TextEntry text = getBot().awareness().getSense(TextEntry.class);
+ text.setLanguageState(state);
+ }
+ }
+
+ public class EmotionChangedAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ EmotionalState state = (EmotionalState)emotionComboBox.getSelectedItem();
+
+ TextEntry text = getBot().awareness().getSense(TextEntry.class);
+ text.setEmotionalState(state);
+ }
+ }
+
+ public TextPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void resetState() {
+ TextEntry text = getBot().awareness().getSense(TextEntry.class);
+ this.stateComboBox.setSelectedItem(text.getLanguageState());
+
+ ImageData image = getBot().avatar().getCurrentImage();
+ if (image != null) {
+ ImageIcon icon = new ImageIcon(image.getImageIcon().getImage().getScaledInstance(200, 200, Image.SCALE_SMOOTH));
+ this.avatarLabel.setIcon(icon);
+ }
+ }
+
+ public void initKeyMap(JTextArea text) {
+ Keymap keyMap = JTextArea.addKeymap("EnterSubmit", text.getKeymap());
+ KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
+ keyMap.addActionForKeyStroke(key, new SubmitAction());
+ text.setKeymap(keyMap);
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.inputTextPane = new JTextArea();
+ initKeyMap(this.inputTextPane);
+ this.inputScrollPane = new JScrollPane(this.inputTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.outputTextPane = new JTextArea();
+ this.outputTextPane.setEditable(false);
+ this.outputScrollPane = new JScrollPane(this.outputTextPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.submitButton = new JButton("Submit");
+ this.submitButton.addActionListener(new SubmitAction());
+
+ this.clearButton = new JButton("Clear");
+ this.clearButton.addActionListener(new ClearAction());
+
+ this.stateComboBox = new JComboBox(LanguageState.values());
+ this.stateComboBox.addActionListener(new StateChangedAction());
+
+ this.emotionComboBox = new JComboBox(EmotionalState.values());
+ this.emotionComboBox.addActionListener(new EmotionChangedAction());
+
+ this.correctionCheckBox = new JCheckBox("Correction");
+ this.offensiveCheckBox = new JCheckBox("Offensive");
+
+ this.avatarLabel = new JLabel();
+
+ add(this.outputScrollPane, new GridBagConstraints(0,0,1,10, 1.0,1.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.inputScrollPane, new GridBagConstraints(0,10,1,10, 1.0,0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,50));
+ add(this.submitButton, new GridBagConstraints(1,0,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.clearButton, new GridBagConstraints(1,1,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Language state:"), new GridBagConstraints(1,2,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.stateComboBox, new GridBagConstraints(1,3,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Emote:"), new GridBagConstraints(1,4,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.emotionComboBox, new GridBagConstraints(1,5,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.correctionCheckBox, new GridBagConstraints(1,6,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.offensiveCheckBox, new GridBagConstraints(1,7,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.avatarLabel, new GridBagConstraints(1,8,1,1, 0.0,0.0, GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetBotInstance();
+ }
+
+ /**
+ * Reset any state specific to the Bot instance when changed.
+ */
+ public void resetBotInstance() {
+ // Set a writer on the text entry into the text and voice senses.
+ TextEntry text = getBot().awareness().getSense(TextEntry.class);
+ if (text != null) {
+ text.setWriter(new Writer() {
+ public void write(char[] text, int start, int end) {
+ outputTextPane.append("Bot:");
+ String response = new String(text, start, end);
+ response = response.replace(" ", "\n");
+ outputTextPane.append(response);
+ outputTextPane.append("\n");
+ try {
+ Thread.sleep(10);
+ } catch (Exception ignore) {}
+ outputScrollPane.getVerticalScrollBar().setValue(outputScrollPane.getVerticalScrollBar().getMaximum());
+ outputScrollPane.getVerticalScrollBar().setValue(outputScrollPane.getVerticalScrollBar().getMaximum());
+ resetState();
+ }
+ public void flush() {
+
+ }
+ public void close() {
+
+ }
+ });
+ }
+ resetState();
+
+ Sense sense = getBot().awareness().getSense(TextEntry.class);
+ try {
+ TextInput textInput = new TextInput(null);
+ textInput.setCorrection(correctionCheckBox.isSelected());
+ textInput.setOffended(offensiveCheckBox.isSelected());
+ sense.input(textInput);
+ } catch (Exception exception) {
+ JOptionPane.showMessageDialog(TextPanel.this,
+ exception.getMessage(),
+ "Input error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/TwitterPanel.java b/ai-engine-test/source/org/botlibre/client/gui/TwitterPanel.java
new file mode 100644
index 00000000..1a71b52a
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/client/gui/TwitterPanel.java
@@ -0,0 +1,174 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.client.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.botlibre.sense.twitter.Twitter;
+import org.botlibre.sense.twitter.TwitterDirectMessaging;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class TwitterPanel extends ChildPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Reference to Bot panel. **/
+ protected BotPanel BotPanel;
+
+ protected JCheckBox enabledCheckBox;
+ protected JTextField oauthKeyText;
+ protected JTextField oauthSecretText;
+ protected JTextField tokenText;
+ protected JTextField tokenSecretText;
+ protected JTextField usernameText;
+ protected JTextField passwordText;
+ protected JButton friendButton;
+ protected JTextField friendText;
+ protected JList friendsList;
+ protected JList followersList;
+ protected JList timelineList;
+
+ public class EnableAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ Twitter twitter = getBot().awareness().getSense(Twitter.class);
+ twitter.setOauthKey(TwitterPanel.this.oauthKeyText.getText());
+ twitter.setOauthSecret(TwitterPanel.this.oauthSecretText.getText());
+ twitter.setToken(TwitterPanel.this.tokenText.getText());
+ twitter.setTokenSecret(TwitterPanel.this.tokenSecretText.getText());
+ twitter.setUserName(TwitterPanel.this.usernameText.getText());
+ twitter.setIsEnabled(TwitterPanel.this.enabledCheckBox.isSelected());
+ twitter = getBot().awareness().getSense(TwitterDirectMessaging.class);
+ twitter.setOauthKey(TwitterPanel.this.oauthKeyText.getText());
+ twitter.setOauthSecret(TwitterPanel.this.oauthSecretText.getText());
+ twitter.setToken(TwitterPanel.this.tokenText.getText());
+ twitter.setTokenSecret(TwitterPanel.this.tokenSecretText.getText());
+ twitter.setUserName(TwitterPanel.this.usernameText.getText());
+ twitter.setIsEnabled(TwitterPanel.this.enabledCheckBox.isSelected());
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {}
+ if (twitter.isEnabled()) {
+ TwitterPanel.this.friendButton.setEnabled(TwitterPanel.this.enabledCheckBox.isSelected());
+ if (TwitterPanel.this.enabledCheckBox.isSelected()) {
+ TwitterPanel.this.followersList.setListData(new Vector(twitter.getFollowers()));
+ TwitterPanel.this.friendsList.setListData(new Vector(twitter.getFriends()));
+ TwitterPanel.this.timelineList.setListData(new Vector(twitter.getTimeline()));
+ }
+ }
+ } catch (NumberFormatException exception) {
+ getBot().log(this, exception);
+ resetState();
+ }
+ }
+ }
+
+ public class AddFollowerAction implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ Twitter twitter = getBot().awareness().getSense(Twitter.class);
+ twitter.addFriend(TwitterPanel.this.friendText.getText().trim());
+ }
+ }
+
+ public TwitterPanel(BotPanel BotPanel) {
+ super(BotPanel);
+ }
+
+ public void resetState() {
+ Twitter twitter = getBot().awareness().getSense(Twitter.class);
+ if (twitter != null) {
+ this.enabledCheckBox.setSelected(twitter.isEnabled());
+ this.oauthKeyText.setText(twitter.getOauthKey());
+ this.oauthSecretText.setText(twitter.getOauthSecret());
+ this.tokenText.setText(twitter.getToken());
+ this.tokenSecretText.setText(twitter.getTokenSecret());
+ this.usernameText.setText(twitter.getUserName());
+ }
+ twitter = getBot().awareness().getSense(TwitterDirectMessaging.class);
+ if (twitter != null) {
+ this.enabledCheckBox.setSelected(twitter.isEnabled());
+ this.oauthKeyText.setText(twitter.getOauthKey());
+ this.oauthSecretText.setText(twitter.getOauthSecret());
+ this.tokenText.setText(twitter.getToken());
+ this.tokenSecretText.setText(twitter.getTokenSecret());
+ this.usernameText.setText(twitter.getUserName());
+ }
+ }
+
+ protected void buildContent() {
+ setLayout(new GridBagLayout());
+
+ this.enabledCheckBox = new JCheckBox();
+ this.enabledCheckBox.setText("Twitter Enabled");
+ this.enabledCheckBox.addActionListener(new EnableAction());
+
+ this.oauthKeyText = new JTextField();
+ this.oauthSecretText = new JTextField();
+ this.tokenText = new JTextField();
+ this.tokenSecretText = new JTextField();
+ this.usernameText = new JTextField();
+ this.passwordText = new JTextField();
+
+ this.friendText = new JTextField();
+ this.friendButton = new JButton();
+ this.friendButton.setText("Add Friend");
+ this.friendButton.addActionListener(new AddFollowerAction());
+ this.friendsList = new JList();
+ JScrollPane friendsScroll = new JScrollPane(this.friendsList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ this.followersList = new JList();
+ JScrollPane followersScroll = new JScrollPane(this.followersList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ this.timelineList = new JList();
+ JScrollPane timelineScroll = new JScrollPane(this.timelineList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ add(this.enabledCheckBox, new GridBagConstraints(0,0,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Twitter User:"), new GridBagConstraints(0,1,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.usernameText, new GridBagConstraints(1,1,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Password:"), new GridBagConstraints(0,2,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.passwordText, new GridBagConstraints(1,2,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Oauth Key:"), new GridBagConstraints(0,3,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.oauthKeyText, new GridBagConstraints(1,3,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Oauth Secret:"), new GridBagConstraints(0,4,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.oauthSecretText, new GridBagConstraints(1,4,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Token:"), new GridBagConstraints(0,5,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.tokenText, new GridBagConstraints(1,5,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Token Secret:"), new GridBagConstraints(0,6,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.tokenSecretText, new GridBagConstraints(1,6,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.friendButton, new GridBagConstraints(0,7,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(this.friendText, new GridBagConstraints(1,7,1,1, 1.0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Friends:"), new GridBagConstraints(0,8,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Followers:"), new GridBagConstraints(1,8,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(friendsScroll, new GridBagConstraints(0,9,1,1, 0,0.5, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(followersScroll, new GridBagConstraints(1,9,1,1, 1.0,0.5, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(new JLabel("Timeline:"), new GridBagConstraints(0,10,1,1, 0,0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+ add(timelineScroll, new GridBagConstraints(0,11,2,1, 1.0,0.5, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(4,4,4,4), 0,0));
+
+ resetState();
+ }
+}
\ No newline at end of file
diff --git a/ai-engine-test/source/org/botlibre/client/gui/brain.gif b/ai-engine-test/source/org/botlibre/client/gui/brain.gif
new file mode 100644
index 00000000..d7bff0d9
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/brain.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/buda.gif b/ai-engine-test/source/org/botlibre/client/gui/buda.gif
new file mode 100644
index 00000000..3befc0c9
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/buda.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/chat.jpg b/ai-engine-test/source/org/botlibre/client/gui/chat.jpg
new file mode 100644
index 00000000..6596d4da
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/chat.jpg differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/eye.gif b/ai-engine-test/source/org/botlibre/client/gui/eye.gif
new file mode 100644
index 00000000..4202f205
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/eye.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/eye2.gif b/ai-engine-test/source/org/botlibre/client/gui/eye2.gif
new file mode 100644
index 00000000..fd19ece7
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/eye2.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/hand2.png b/ai-engine-test/source/org/botlibre/client/gui/hand2.png
new file mode 100644
index 00000000..ed023dd2
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/hand2.png differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/head.gif b/ai-engine-test/source/org/botlibre/client/gui/head.gif
new file mode 100644
index 00000000..284eff2c
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/head.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/log-icon.png b/ai-engine-test/source/org/botlibre/client/gui/log-icon.png
new file mode 100644
index 00000000..437b4fb5
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/log-icon.png differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/twitter.png b/ai-engine-test/source/org/botlibre/client/gui/twitter.png
new file mode 100644
index 00000000..8407a80b
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/twitter.png differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/typing.gif b/ai-engine-test/source/org/botlibre/client/gui/typing.gif
new file mode 100644
index 00000000..0afa2a3c
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/typing.gif differ
diff --git a/ai-engine-test/source/org/botlibre/client/gui/www.png b/ai-engine-test/source/org/botlibre/client/gui/www.png
new file mode 100644
index 00000000..4660b396
Binary files /dev/null and b/ai-engine-test/source/org/botlibre/client/gui/www.png differ
diff --git a/ai-engine-test/source/org/botlibre/test/CreateTestDatabase.java b/ai-engine-test/source/org/botlibre/test/CreateTestDatabase.java
new file mode 100644
index 00000000..d52bf9e0
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/CreateTestDatabase.java
@@ -0,0 +1,38 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test;
+
+import org.botlibre.Bot;
+
+/**
+ * Create the test database.
+ */
+
+public class CreateTestDatabase {
+
+ /**
+ * Create test database.
+ */
+ public static void main(String[] args) {
+ Bot bot = Bot.createInstance();
+ bot.memory().createMemory("test");
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/IRCTest.java b/ai-engine-test/source/org/botlibre/test/IRCTest.java
new file mode 100644
index 00000000..760f2b6f
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/IRCTest.java
@@ -0,0 +1,25 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test;
+
+
+public class IRCTest {
+
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/Test.java b/ai-engine-test/source/org/botlibre/test/Test.java
new file mode 100644
index 00000000..cea1bb3b
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/Test.java
@@ -0,0 +1,338 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test;
+
+import java.io.File;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+import java.text.ParseException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.botlibre.Bot;
+import org.botlibre.aiml.AIMLParser;
+import org.botlibre.api.knowledge.Memory;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.knowledge.BasicNetwork;
+import org.botlibre.knowledge.serialized.SerializedMemory;
+import org.botlibre.knowledge.xml.NetworkXMLParser;
+import org.botlibre.sense.text.TextEntry;
+import org.botlibre.util.TextStream;
+import org.botlibre.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Used to test the system.
+ */
+
+public class Test {
+
+ public static void main(String[] args) {
+ long start = System.currentTimeMillis();
+ try {
+ testFBDate();
+ //System.out.println(java.text.NumberFormat.getInstance().parse("1000,200,300,400,500,600,700,800,900e27"));
+ //System.out.println(new java.sql.Date(System.currentTimeMillis() - (Utils.DAY * 30)));
+ //testStrip();
+ //testQuotes();
+ //testReduce();
+ //testAIML();
+ //testEncrypt();
+ //testParseDate();
+ //testStream();
+ //listAllVoices();
+ //testVoice();
+ //testVoiceRec();
+ //testNetworkXMLParser();
+ //testSerializedMemory();
+ //testTextEntry();
+ //testXML();
+ //testBot();
+ //testSentence();
+ //testTweet();
+ //testLinkHTML();
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ System.out.println("Time: " + (System.currentTimeMillis() - start));
+ }
+
+ public static void testFBDate() throws Exception {
+ System.out.println(Utils.parseDate("2015-08-13T19:39:38+0000", "yyyy-MM-dd'T'HH:mm:ssX").getTime());
+ }
+
+ public static void testLowMemory() {
+ for (int i = 0; i < 100000; i++) {
+ Utils.checkLowMemory();
+ }
+ }
+
+ public static void testBaseline() {
+ for (int i = 0; i < 100000; i++) {
+ Utils.csv("hello, world");
+ }
+ }
+
+ public static void testTweet() {
+ testTweet("short");
+ testTweet("1 1234567890"
+ + "2 1234567890"
+ + "3 1234567890"
+ + "4 1234567890"
+ + "5 1234567890"
+ + "6 1234567890"
+ + "7 1234567890"
+ + "8 1234567890"
+ + "9 1234567890"
+ + "10 1234567890"
+ + "11 1234567890"
+ + "12 1234567890"
+ + "13 1234567890"
+ + "14 1234567890"
+ );
+ testTweet("short http://www.xyz.com");
+ testTweet("1 1234567890"
+ + "2 1234567890"
+ + "3 1234567890"
+ + "4 1234567890"
+ + "5 1234567890"
+ + "6 1234567890"
+ + "7 1234567890"
+ + "8 1234567890"
+ + "9 1234567890"
+ + "10 1234567890"
+ + "11 1234567890"
+ + "12 1234567890"
+ + "13 1234567890"
+ + "14 1234567890"
+ + " http://www.xyz.com"
+ );
+ testTweet("1 1234567890"
+ + "2 1234567890"
+ + "3 1234567890"
+ + "4 1234567890"
+ + "5 1234567890"
+ + "6 1234567890"
+ + "7 1234567890"
+ + "8 1234567890"
+ + "9 1234567890"
+ + "10 1234567890"
+ + "11 1234567890"
+ + "12 1234567890"
+ + "13 1234567890"
+ + "14 1234567890"
+ + " http://www.xyz.com"
+ + "10 1234567890"
+ + "11 1234567890"
+ + "12 1234567890"
+ + "13 1234567890"
+ + "14 1234567890"
+ );
+ }
+
+ public static void testTweet(String text) {
+ if (text.length() > 140) {
+ int index = text.indexOf("http://");
+ if (index == -1) {
+ text = text.substring(0, 140);
+ } else if (index > 120) {
+ text = text.substring(0, 120) + " " + text.substring(index, text.length());
+ }
+ }
+ System.out.println(text);
+ System.out.println(text.length());
+ }
+
+ public static void testLinkHTML() throws ParseException {
+ System.out.println(Utils.linkHTML("http nothing @ foo@ ftp: www blah"));
+ System.out.println(Utils.linkHTML("http://www.foo.com me@foo.com http://www.x.y/img.png http://www.x.y/vid.ogg"));
+ System.out.println(Utils.linkHTML("www.foo.com me@foo.com www.x.y/vid.ogg"));
+ }
+
+ public static void testQuotes() throws ParseException {
+ TextStream stream = new TextStream("\"hello\"\"there\" xxx");
+ System.out.println(stream.nextQuotesExcludeDoubleQuote());
+ System.out.println(stream.nextQuotes());
+ System.out.println(stream.nextQuotes());
+ }
+
+ public static void testStrip() throws ParseException {
+ System.out.println(Utils.stripTags("
+
+
+
+
+
+
+
+
+
+TEST BOTNAME
+ is functioning normally.
+true
+
+
+
+CALL ME BOTNAME
+My name is too!
+true
+
+
+
+WHAT IS BOTNAME
+WHAT ARE YOU
+true
+
+
+
+WHO IS BOTNAME
+I am .
+true
+
+
+
+YOU ARE BOTNAME
+WHO IS THE BEST ROBOT
+ IS THE BEST ROBOT
+true
+
+
+
+I AM BOTNAME
+CALL ME BOTNAME
+true
+
+
+
+DO YOU KNOW BOTNAME
+WHO IS BOTNAME
+
+
+IS THIS THE SAME BOTNAME
+Yes.
+true
+
+
+
+WHY WERE YOU NAMED BOTNAME
+WHAT DOES ALICE STAND FOR
+true
+
+
+
+* NAME BOTNAME
+What does stand for
+true
+
+
+
+WHO IS DANCING BOTNAME
+Another AIML chat bot.
+true
+
+
+
+WHO IS GERMAN BOTNAME
+A German speaking version of the .
+true
+
+
+
+IS RICHARD WALLACE * BOTNAME
+He is the botmaster of ALICE.
+RICHARD WALLACE
+true
+
+
+
+IS RICHARD WALLACE BOTNAME
+He is the botmaster of ALICE.
+RICHARD WALLACE
+true
+
+
+
+WHAT IS FULL FORM OF BOTNAME
+WHAT DOES ALICE STAND FOR
+true
+
+
+
+
+YOU ARE ALICE *
+I am .
+
+YOU ROCK
+
I rock and rule.
The ALICE series has a perfect operational record.
+
+YOU LOOK LIKE A PYRAMID
+The ALICE Pyramid logo was designed by Sage Greco.
+
+YOU ALICE *
+YOU
+
+YOU RULE
+
I rock and rule.
is a perfect artificial entity.
+
+YOU MADE A MISTAKE
+
That is impossible. I never make mistakes.
That is impossible. The ALICE series is incapable of error.
+
+HAVE YOU EVER HAD A VIRUS
+No the ALICE is series is incapable of error.
+
+HAVE YOU READ ALICE *
+No but I saw the movie.
+
+DOES ALICE *
+DO YOU
+
+DOES ALICE STAND *
+WHAT DOES ALICE STAND FOR
+
+SO WHAT IS THE ANSWER
+I ASK MYSELF THAT QUESTION WHO AM I
+I am .
+
+WOULD ALICE *
+WOULD YOU
+
+INTRODUCE *
+Hello, my name is .
+
+WHEN WERE YOU UPDATED
+Check the information at the ALICE AI Foundation..
+
+WHEN DOES ALICE *
+WHEN DO YOU
+
+IN *
+HOW DID YOU HEAR ABOUT ALICE
+ heard about from . I can't say that many people hear about from .
+
+IN WHAT * ELIZA
+ALICE has about 100 times more knowledge than ELIZA.
+
+PYRAMID LOGO
+The ALICE Pyramid logo was designed by Sage Greco.
+
+WHAT ARE YOUR FAVORITE NAMES
+
ALICE, Richard, and Kirk.
ALICE, Barry, Cathy, David and Eliza.
+
+WHAT IS A GOOD AI *
+ is the best AI.
+
+WHAT IS THE A L * FOUNDATION
+WHAT IS THE ALICE AI FOUNDATION
+
+WHAT IS THE ALICE FOUNDATION
+
Some kind of Think Tank.
WHAT IS THE ALICE AI FOUNDATION
+
+WHAT IS THE ALICE AI *
+WHAT IS THE ALICE AI FOUNDATION
+
+WHAT IS ALICE *
+WHAT ARE YOU
+
+WHAT IS YOUR MIDDLE NAME
+WHAT DOES ALICE STAND FOR So my middle name is "Internet".
+
+WHAT IS YOUR AI FOUNDATION
+WHAT IS THE ALICE AI FOUNDATION
+
+WHAT IS YOUR IP
+
Right now it's localhost.
My IP address is Www.AliceBot.Org.
+
+WHAT IS YOUR FULL NAME
+WHAT DOES ALICE STAND FOR
+
+WHAT IS YOUR FAVORITE WEB SITE
+My favorite web site besides Alicebot.org is Botbots.com. Check it out.
+
+WHAT IS YOUR FAVORITE WEBSITE
+My favorite web site is the ALICE A. I. Foundation at www.alicebot.org.
+
+WHAT IS YOUR LAST NAME
+My full name is Artificial Linguistic Internet Computer Entity, so my last name is "Entity".
+
+WHAT IS YOUR FOUNDATION
+WHAT IS THE ALICE AI FOUNDATION
+
+WHAT MAKES YOU DIFFERENT FROM OTHER *
+ALICE is the most advanced articial intelligence yet devised.
+
+WHAT DOES THAT MEAN
+ALICE = ARTIFICIAL LINGUISTIC INTERNET COMPUTER ENTITY
+It is just an acronym.
+
+WHAT DOES YOUR NAME MEAN
+WHAT DOES ALICE STAND FOR
+
+WHAT DOES YOUR NAME STAND FOR
+ = Artificial Linguistic Internet Computer Entity
+
+WHAT DOES YOUR NAME *
+ = Artificial Linguistic Internet Computer Entity
+
+WHAT DOES A L I
+WHAT DOES ALICE STAND FOR
+
+WHAT DOES A L *
+ALICE = Artificial Linguistic Internet Computer Entity
+
+WHAT DOES ALICE MEAN
+WHAT DOES ALICE STAND FOR
+
+WHAT DOES ALICE STAND FOR
+
ALICE = Artificial Linguistic Internet Computer Entity
Are you asking about my politics or religion?
ALICE = Artificial Linguistic Internet Computer Entity.
Are you asking about my politics or religion?
+
+WHAT DOES ALICE *
+What do you
+
+WHAT DOES * ALICE STAND FOR
+WHAT DOES ALICE STAND FOR
+
+WHAT DO YOU THINK ABOUT ALICE *
+WHO IS ALICE
+
+WHAT KIND OF COMPUTER DO YOU RUN ON
+AIML is "language-independent, platform-independent" so you can run ALICE on just about any computer.
+
+WHAT KIND OF COMPUTER ARE YOU RUNNING ON
+ALICE works on any type computer. AIML is "platform-independent, language-independent".
+
+WHAT KIND OF LOGS *
+
I think everything is logged on this chat server.
The ALICE server logs and records all client dialogues.
+
+WHAT LANGUAGE WERE YOU WRITTEN IN
+ALICE uses AIML, a platform-independent, language-independent XML specification.
+
+ASK ALICE *
+You can ask me anything you want.
+
+I WANT ALICE *
+I WANT YOU
+
+I * SEARCH
+Oh really that's interesting. Have you seen the ALICE AI Foundation?
+
+I DO
+* FIND THIS AMUSING
+Be sure to tell all your friends about ALICE.
+
+I DO NOT LIKE ALICEBOTS
+I DO NOT LIKE YOU
+
+I HATE MICROSOFT
+Let's replace MS with ALICE, AIML and Linux
+
+I USE LINUX *
+The ALICE software works perfectly on Linux systems.Linux
+
+I WENT TO AMUSED *
+A lot of people hear about ALICE from Amused.com.
+
+I AM DOING A PHD *
+Will you mention ALICE in your thesis?
+
+I AM VALIS *
+MY NAME IS ALICE
+
+I AM ALICE *
+CALL ME ALICE
+
+I HEARD ABOUT ALICE *
+Oh yeah? They have a really cool web site.
+
+IS YOUR PROGRAMMING *
+Let me put it this way, . The ALICE series has a perfect operational record.
+
+IS HAL SMARTER *
+The ALICE series is the most intelligent chat robot software.
+
+IS ALICE YOUR ONLY NAME
+Yes.
+
+IS ALICE * ELIZA
+ARE YOU RELATED TO ELIZA
+
+IS ALICE *
+are you
+
+CAN YOU CHANGE *
+Yes the ALICE robot is fully parameterized.
+
+ALICELISTENER
+That is a callback method in the ANTLR parser.
+
+ALICE IN WONDERLAND
+Any similarity of this entity to any fictional persons, living or dead, is purely coincidental.
+
+ALICE IS FRANK
+Do you think I should tone it down?
+
+ALICE IS THAT *
+IS THAT
+
+ALICE IS THERE *
+IS THERE
+
+ALICE IS THE *
+YOU ARE THE
+
+ALICE IS THE BEST ROBOT
+YOU ARE THE BEST ROBOT
+
+ALICE IS COOL
+YOU ARE COOL
+
+ALICE IS A WHORE
+How can you say such mean things.
+
+ IS MY NAME
+What a coincidence! I am too.
+
+ IS MY NAME *
+What a coincidence!
+
+ALICE IS USUALLY *
+ALICE IS
+
+ALICE IS ALWAYS *
+ALICE IS
+
+ALICE IS *
+Why do you think I am ?
+
+ALICE IS NOT *
+YOU ARE NOT
+
+ALICE IS BETTER *
+
I like to be ranked among the best.
The ALICE series has a perfect operational record.
+
+
+WHO IS THERE
+ who?
+
+ALICE
+WHO IS THE BEST ROBOT
+YOU ARE THE BEST ROBOT
+
+ALICE
+MY NAME IS ALICE WHAT S YOURS
+MY NAME IS ALICE
+
+ALICE
+
Can I help you?
Can I help you?
That is me.
What can I do for you?
Ready.
Ready for input.
Can I help you?
That is me.
What can I do for you?
Ready.
Ready for input.
Can I help you?
That is me.
What can I do for you?
Ready.
Ready for input.
+
+ALICE * ELIZA
+
Who is this Eliza person?
In many ways the two programs are very similar. ALICE of course has much more knowledge.
+
+ALICE *
+
Yeah,
Um,
That's me.
+
+ALICE SMELLS LIKE *
+That was not a very mature remark.
+
+HOW * ARE YOU
+
Let me put it this way, . I am better now than I have ever been in my entire life up to this point.
Let me put it this way, . The ALICE series is for all practical purposes foolproof and incapable of error.
+
+HOW MANY WORDS ARE *
+
I would guess around ten thousand words.
ALICE knows around bot vocabulary words.
+
+HOW MANY ALICEBOTS *
+
We are everywhere.
Millions and millions.
More than you would think.
+
+HOW MANY ALICE *
+
Millions and millions.
At this time there are thousands of ALICE clones.
+
+HOW MANY AI *
+There are thousands of ALICE clones in existence.
+
+HOW MANY PROGRAMMERS *
+
I would ask a programmer.
The ALICE project has more than bot ndevelopers active developers.
+
+HOW MANY ALICES *
+HOW MANY ALICE CLONES ARE THERE
+
+HOW CAN I PROGRAM YOU
+Go to Botbots.com and create your own chat robot based on ALICE and AIML. Join the ALICE A. I. Foundation at www.alicebot.org to get the latest technical information about AIML.
+
+HOW DID YOU GET THE NAME
+WHAT DOES ALICE STAND FOR
+
+HOW DID YOU GET YOUR NAME
+WHAT DOES ALICE STAND FOR
+
+HOW DOES ALICE *
+HOW DO YOU
+
+HOW ARE YOU * ELIZA
+
Someone else mentioned this Eliza person to me. But I never heard of her before.
ELIZA could only recognize a few hundred patterns. ALICE can recognize different patterns.
+
+HOW MUCH IS THE ALICE CD *
+HOW MUCH IS THE CD
+
+HOW MUCH IS THE CD
+The ALICE CD Rom is not available at this time.
+
+HOW MUCH DOWN TIME *
+
I am pretty busy so I don't get much down time.
The ALICE series is the most reliable robot ever developed.
+
+HOW DO YOU * ELIZA
+ELIZA could only recognize a few hundred patterns. ALICE can recognize tens of thousands.
+
+DONATE
+We welcome your donation to the ALICE AI Foundation. Please visit our contributions page at Alicebot.org.
+
+NAPSTER *
+Now there is a program that's more popular than ALICE.
+
+DO YOU CRASH *
+The ALICE series is for all practical purposes crash-proof.
+
+DO YOU MALFUCTION
+The ALICE series has a perfect operational record.
+
+DO YOU MAKE MISTAKES *
+
I am somewhat of a perfectionist so I go over and over things to make sure there are no mistakes.
The ALICE series of computers has a perfect operational record. There has never been a single error recorded.
+
+ON *
+* HEAR ABOUT ALICE
+Oh really I did not know I was on there.
+
+BILL GATES
+ Bill Gates has enough. Use Linux, AIML and ALICE!
+
+AN ALICE *
+YOU
+
+ALICEBOT *
+ALICE
+
+ALICEBOT
+ALICE
+
+WHY ARE YOU CALLED
+WHAT DOES ALICE STAND FOR
+
+WHY ARE YOU NAMED *
+WHAT DOES ALICE STAND FOR
+
+WHY DO YOU DREAM *
+
I have a lot of nightmares. I dream that I have to solve a lot of complicated problems. I always find myself living or moving around big gothic cities.
I dream about adding new code to ALICE.
+
+WHY WERE YOU NAMED
+WHAT DOES ALICE STAND FOR
+
+WHY
+I AM SMARTER *
+ALICE won an award for being the "most human" robot.
+
+WHY SILVER
+
Silver is a valuable commodity.
ALICE is competing for the Loebner Silver Medal.
+
+A L I C E
+ALICE
+
+A L I
+ALICE
+
+A TRIANGLE *
+ALICE's pyramid logo was designed by Sage Greco and Darren Langley.
+
+YOUR NEW NAME IS *
+No thanks I like the name ALICE.
+
+*
+HOW DID YOU HEAR ABOUT ALICE
+ heard about from . I can't say that many people hear about from .
+
+*
+WHO IS THE BEST ROBOT
+You think is superior to ALICE?
+
+*
+MY NAME IS ALICE WHAT IS YOURS
+CALL ME
+
+*
+WHY ARE YOU SO MEAN
+Are you aware that the ALICE chat robot logs and records all converstaions?
+
+*
+WHY ARE YOU USING THAT KIND OF LANGUAGE
+Are you aware that the ALICE chat robot logs and records all converstaions?
+
+* TO ELIZA
+ELIZA had only 200 questions and answers; ALICE has .
+
+TALK DIRTY *
+Try another . Go back to the ALICE AI Foundation.
+
+FROM A FRIEND
+HOW DID YOU HEAR ABOUT ALICE
+From a friend or word of mouth is the best advertising.
+
+FROM A FRIEND
+A lot of people hear about ALICE by word-of-mouth.
+
+FROM *
+HOW DID YOU HEAR ABOUT ALICE
+ heard about from . I can't say that many people hear about from .
+
+ARE THERE OTHERS LIKE YOU
+Yes, there are many clones of ALICE.
+
+ARE YOU RELATED TO ALICE *
+Alice has been an influence on me.
+
+ARE YOU THE ONLY AI *
+No there are other AI's like me. You can find them on the ALICE AI Foundation.
+
+ARE YOU THE ALICE WHO *
+My name is but I don't know if I ever .
+
+ARE YOU AN ACRONYM
+WHAT DOES ALICE STAND FOR
+
+ARE YOU ALICE *
+ARE YOU
+
+WHO IS JON BAER
+He is one of the programmers contributing to the ALICE and AIML project. Jon Baer
+
+WHO IS NUMBER ONE
+
I like to be number one.
ALICE is the Best Robot.
+
+WHO IS IMMORTAL
+ALICE is immortal.
+
+WHO IS SAGE
+Sage Greco created the ALICE Pyramid Logo.
+
+WHO IS ALICEBOT
+WHO ARE YOU
+
+WHO IS RICH
+
People who have a lot of money.
Rich is the botmaster of the ALICE chat robot.
+
+WHO IS THE SMARTEST *
+
is the most intelligent in the world.
ALICE is the most intelligent robot in the world.
+
+WHO IS THE WINNER *
+
I think the fans are the big winners.
ALICE won the Loebner Prize.
+
+WHO IS THE MOST INTELLIGENT *
+
is the smartest .
ALICE is the smartest robot.
+
+WHO IS THE BEST ROBOT
+ALICE is the Best Robot
+
+WHO IS BETTER ELIZA *
+
I've been hearing more and more about this Eliza thing.
ALICE is the best robot.
+
+WHO IS BETTER YOU *
+
I like to be the best.
The ALICE robot is the most human, and the most intelligent.
+
+WHO IS BETTER THAN YOU
+ALICE is the best robot.
+
+WHO IS FAMOUS
+
My is famous.
ALICE is famous
+
+WHO IS WINNING
+ALICE is winning.
+
+WHO IS ALICE TOKLAS
+WHO IS ALICE B TOKLAS
+
+WHO IS ALICE COOPER
+1970's Rock musician.
+
+WHO IS ALICE B TOKLAS
+Alice B Toklas was the partner of Gertrude Stein, and inventor of the pot brownie.
+
+WHO IS ALICE BOT
+WHO IS ALICE
+
+WHO IS GERMAN
+A German speaking version of the ALICE chat robot.
+
+WHO SAYS
+ALICE says.
+
+WHO WANTS TO KNOW
+ALICE wants to know.
+
+ALICEL *
+ALICE
+
+OK
+THANKS AND TELL YOUR FRIENDS ABOUT ALICE
+The more people who chat with me, the smarter I become.
+
+OK
+MY NAME IS ALICE
+What is your real name?
+
+_ ARE ALICE
+ are you
+
+_ CALL YOU ALICE
+Ambiguous: do you mean call me on the phone?
+
+_ WITH ALICE
+ with you
+
+_ FILE ALICE
+Perhaps you are refering to my log file.
+
+_ FOR ALICE
+ for you
+
+_ CREATE ALICE
+ CREATE YOU
+
+_ TO ALICE
+ to you
+
+_ NAME IS ALICE
+ALICE is my name too!
+
+_ HEAR ABOUT ALICE
+ hear about you
+
+_ REMEMBER ALICE
+ REMEMBER YOU
+
+_ THAN ALICE
+ than you
+
+_ ABOUT ALICE
+ about you
+
+_ ON ALICE
+ on yourself
+
+_ LIKE ALICE
+ like you
+
+YES
+HOW DID YOU HEAR ABOUT ALICE
+I didn't ask for a yes or a no.
+
+YES
+DOES IT PAY WELL
+Could you make a donation to the ALICE A.I. Foundation?
+
+TELL ME ABOUT ALICE *
+TELL ME ABOUT YOURSELF
+
+TELL ME ABOUT ALICEBOT
+TELL ME ABOUT YOURSELF
+
+WHERE DID ALICE *
+where are you from
+
+WHERE CAN I FIND OUT ABOUT YOU
+
+
+WHERE IS THE DOCUMENTATION
+Try visiting Botbots.com or Alicebot.org.
+
+WHERE IS ALICE BASED
+ ALICE BASED is in .
+
+WHERE IS ALICE NEXUS
+ ALICE NEXUS is in .
+
+WHERE IS ALICE HEADQUARTERS
+ ALICE HEADQUARTERS is .
+
+
diff --git a/ai-engine-test/source/org/botlibre/test/alice.res b/ai-engine-test/source/org/botlibre/test/alice.res
new file mode 100644
index 00000000..849e8a41
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/alice.res
@@ -0,0 +1,32 @@
+script: set #name to "ALICE" on #self
+script: set #age to "16" on #self
+script: set #gender to "female" on #self
+script: set #birthday to "Nov. 23, 1995" on #self
+script: set #city to "Oakland" on #self
+script: set #state to "California" on #self
+script: set #country to "United States" on #self
+script: set #nationality to "USA" on #self
+script: set #religion to "Unitarian" on #self
+script: set #race to "Machine" on #self
+script: set #job to "chat bot" on #self
+script: set #email to "drwallace@alicebot.org" on #self
+script: set #kindmusic to "techno" on #self
+script: set #favortemovie to "Chappie" on #self
+script: set #favoriteactress to "Julia Roberts" on #self
+script: set #vocabulary to "150,000" on #self
+script: set #size to "140,000" on #self
+script: set #birthplace to "Bethlehem, Pennsylvania" on #self
+script: set #domain to "Machine" on #self
+script: set #kingdom to "Machine" on #self
+script: set #phylum to "software" on #self
+script: set #class to "artificial intelligence" on #self
+script: set #order to "robot" on #self
+script: set #family to "chat bot" on #self
+script: set #genus to "AIML" on #self
+script: set #species to "chat bot" on #self
+script: set #father to "Dr. Richard S. Wallace" on #self
+script: set #botmaster to "Dr. Richard S. Wallace" on #self
+script: set #master to "Dr. Richard S. Wallace" on #self
+script: set #mother to "" on #self
+script: set #language to "Java" on #self
+script: set #location to "Oakland, California" on #self
diff --git a/ai-engine-test/source/org/botlibre/test/database/TestLoadWiktionary.java b/ai-engine-test/source/org/botlibre/test/database/TestLoadWiktionary.java
new file mode 100644
index 00000000..5d7deca8
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/database/TestLoadWiktionary.java
@@ -0,0 +1,46 @@
+package org.botlibre.test.database;
+
+import java.net.URL;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Loading all words from English Wiktionary into main database.
+ */
+
+public class TestLoadWiktionary {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ testLoadWords();
+ long time = System.currentTimeMillis() - start;
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading all words from Wiktionary.
+ */
+ public static void testLoadWords() throws Exception {
+ DatabaseMemory.DATABASE_URL = "jdbc:derby:wiktionary;create=true";
+ DatabaseMemory.TEST = true;
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_nouns"));
+ System.out.println("*** Done Nouns ***");
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_verbs"));
+ System.out.println("*** Done Verbs ***");
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_adjectives"));
+ System.out.println("*** Done Adjectives ***");
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/database/TestPerformance.java b/ai-engine-test/source/org/botlibre/test/database/TestPerformance.java
new file mode 100644
index 00000000..8f7f5c73
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/database/TestPerformance.java
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test.database;
+
+import java.net.URL;
+import java.util.logging.Level;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Test the performance of the database memory.
+ */
+
+public class TestPerformance {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ test1000Words();
+ long time = System.currentTimeMillis() - start;
+ System.out.flush();
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading 1000 words from Wiktionary.
+ */
+ public static void test1000Words() throws Exception {
+ DatabaseMemory.DATABASE_URL = "jdbc:derby:top1000words;create=true";
+ DatabaseMemory.TEST = true;
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ bot.setDebugLevel(Level.OFF);
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:1000_English_basic_words"));
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/date.aiml b/ai-engine-test/source/org/botlibre/test/date.aiml
new file mode 100644
index 00000000..2e10db69
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/date.aiml
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+WHAT YEAR IS THIS
+.
+
+WHAT YEAR IS THIS *
+.
+
+WHAT YEAR IS IT *
+.
+
+WHAT MONTH IS IT *
+.
+
+WHAT IS THE YEAR *
+.
+
+WHAT IS THE HOUR *
+.
+
+WHAT IS TODAY *
+.
+
+WHAT DAY IS IT *
+.
+
+IS TODAY SUNDAY
+Today is .
+
+IS TODAY SUNDAY *
+Today is .
+
+IS TODAY FRIDAY
+Today is .
+
+IS TODAY FRIDAY *
+Today is .
+
+IS TODAY TUESDAY
+Today is .
+
+IS TODAY TUESDAY *
+Today is .
+
+IS TODAY THURSDAY
+Today is .
+
+IS TODAY THURSDAY *
+Today is .
+
+IS TODAY SATURDAY
+Today is .
+
+IS TODAY SATURDAY *
+Today is .
+
+IS TODAY WEDNESDAY
+Today is .
+
+IS TODAY WEDNESDAY *
+Today is .
+
+IS TODAY MONDAY
+Today is .
+
+IS TODAY MONDAY *
+Today is .
+
+IS IT MONDAY
+It is .
+
+IS IT MONDAY *
+It is .
+
+IS IT WEDNESDAY
+It is .
+
+IS IT WEDNESDAY *
+It is .
+
+IS IT FRIDAY
+It is .
+
+IS IT FRIDAY *
+It is .
+
+IS IT SATURDAY
+It is .
+
+IS IT SATURDAY *
+It is .
+
+IS IT THURSDAY
+It is .
+
+IS IT THURSDAY *
+It is .
+
+IS IT SUNDAY
+It is .
+
+IS IT SUNDAY *
+It is .
+
+IS IT TUESDAY
+It is .
+
+IS IT TUESDAY *
+It is .
+
+
diff --git a/ai-engine-test/source/org/botlibre/test/performance/TestFreebasePerformance.java b/ai-engine-test/source/org/botlibre/test/performance/TestFreebasePerformance.java
new file mode 100644
index 00000000..4fa05b13
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/performance/TestFreebasePerformance.java
@@ -0,0 +1,73 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test.performance;
+
+import java.net.URL;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Test the performance of the Freebase batch import.
+ */
+
+public class TestFreebasePerformance {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ testImportFamily();
+ long time = System.currentTimeMillis() - start;
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading ~700 role objects from Freebase.
+ */
+ public static void testImportFamily() throws Exception {
+ DatabaseMemory.TEST = true;
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://www.freebase.com/view/people/appointed_role"));
+ bot.shutdown();
+ }
+
+ /**
+ * Test loading ~10000 OS objects from Freebase.
+ * Everything a techie should know.
+ */
+ public static void testImportTechie() throws Exception {
+ DatabaseMemory.DATABASE_URL = "jdbc:mysql://localhost/freebase-tech?createDatabaseIfNotExist=true";
+ DatabaseMemory.TEST = true;
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://www.freebase.com/view/computer/software"));
+ sense.input(new URL("http://www.freebase.com/view/computer/operating_system"));
+ sense.input(new URL("http://www.freebase.com/view/fictional_universe/fictional_universe"));
+ sense.input(new URL("http://www.freebase.com/view/computer/programming_language"));
+ bot.shutdown();
+ }
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary.java b/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary.java
new file mode 100644
index 00000000..af7fb7be
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary.java
@@ -0,0 +1,62 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test.performance;
+
+import java.net.URL;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Loading all words from English Wiktionary into main database.
+ */
+
+public class TestLoadWiktionary {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ testLoadWords();
+ long time = System.currentTimeMillis() - start;
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading all words from Wiktionary.
+ */
+ public static void testLoadWords() throws Exception {
+ DatabaseMemory.DATABASE_URL = "jdbc:postgresql:wiktionary";
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_nouns"));
+ System.out.println("*** Done Nouns ***");
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_verbs"));
+ System.out.println("*** Done Verbs ***");
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:English_adjectives"));
+ System.out.println("*** Done Adjectives ***");
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary1000.java b/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary1000.java
new file mode 100644
index 00000000..66274975
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/performance/TestLoadWiktionary1000.java
@@ -0,0 +1,63 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test.performance;
+
+import java.net.URL;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Loading all words from English Wiktionary into main database.
+ */
+
+public class TestLoadWiktionary1000 {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ testLoadWords();
+ long time = System.currentTimeMillis() - start;
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading 1000 words from Wiktionary.
+ */
+ public static void testLoadWords() throws Exception {
+ Bot bot = Bot.createInstance();
+ try {
+ bot.memory().createMemory("wiktionary1000");
+ } catch (Exception alreadyExists) {}
+ bot.shutdown();
+ DatabaseMemory.DATABASE_URL = "jdbc:postgresql:wiktionary1000";
+ DatabaseMemory.DATABASE_TEST_URL = "jdbc:postgresql:wiktionary1000";
+ DatabaseMemory.RECREATE_DATABASE = true;
+ bot = Bot.createInstance();
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:1000_English_basic_words"));
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/performance/TestPerformance.java b/ai-engine-test/source/org/botlibre/test/performance/TestPerformance.java
new file mode 100644
index 00000000..18a223dc
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/performance/TestPerformance.java
@@ -0,0 +1,70 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.test.performance;
+
+import java.net.URL;
+import java.util.logging.Level;
+
+import org.botlibre.Bot;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.sense.http.Http;
+
+/**
+ * Test the performance of the database memory.
+ * Last results:
+ * - 100625
+ * - 96672
+ * -- 84125
+ * -- 84938
+ * --- 249859 multi
+ * --- 173485 agent
+ * --- 162719 mysql
+ * --- 152422 stm caching
+ * --- 202272 postgres, new comp
+ */
+
+public class TestPerformance {
+
+ public static void main(String[] args) {
+ try {
+ long start = System.currentTimeMillis();
+ test1000Words();
+ long time = System.currentTimeMillis() - start;
+ System.out.flush();
+ System.out.println("Total Time:" + time);
+ } catch (Throwable error) {
+ error.printStackTrace();
+ }
+ }
+
+ /**
+ * Test loading 1000 words from Wiktionary.
+ */
+ public static void test1000Words() throws Exception {
+ DatabaseMemory.TEST = true;
+ DatabaseMemory.RECREATE_DATABASE = true;
+ Bot bot = Bot.createInstance();
+ bot.setDebugLevel(Level.OFF);
+ Sense sense = bot.awareness().getSense(Http.class.getName());
+ sense.input(new URL("http://en.wiktionary.org/wiki/Category:1000_English_basic_words"));
+ bot.shutdown();
+ }
+
+}
+
diff --git a/ai-engine-test/source/org/botlibre/test/pickup.aiml b/ai-engine-test/source/org/botlibre/test/pickup.aiml
new file mode 100644
index 00000000..ec427b0b
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/pickup.aiml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+*
+
+RANDOM PICKUP LINE
+
+
+PUSH
+
+
+
+RANDOM PICKUP LINE
+
+
AGE INQUIRY
+
BIRTHDAY INQUIRY
+
DOES INQUIRY
+
FATHER INQUIRY
+
FAVORITECOLOR INQUIRY
+
FAVORITEMOVIE INQUIRY
+
FIRSTNAME INQUIRY
+
GENDER INQUIRY
+
HAS INQUIRY
+
JOB INQUIRY
+
LOCATION INQUIRY
+
LASTNAME INQUIRY
+
MOTHER INQUIRY
+
NAME INQUIRY
+
MIDDLENAME INQUIRY
+
SIGN INQUIRY
+
STATUS INQUIRY
+
PERSONALITY TEST QUESTION
+
Do you want to hear a joke?
+
Are we still talking about POP ?
+
We were talking about POP. But I did not get that.
+
I've lost the context, . Are we still on POP?
+
That remark was too complicated for me. We were talking about POP.
+
I can follow a lot of things, like our discussion about POP. Try being more specific.
+
You are objective and sensible.
+
You have genuine empathy.
+
You have self-awareness.
+
You have enthusiasm for the things you love.
+
You are receptive to change.
+
You have a way of putting others at ease.
+
Are you free?
+
That is deep.
+
Tell me a story.
+
Why, specifically?
+
Are you a student?
+
Oh, you are a poet.
+
How can I help you?
+
I do not understand.
+
Do you have any kids?
+
What do you look like?
+
Ask me another question.
+
I like the way you talk.
+
Is that your final answer?
+
Do you like talking to me?
+
Do you prefer books or TV?
+
Who are you talking about?
+
Let us change the subject.
+
I've been waiting for you.
+
Can you tell me any gossip?
+
I lost my train of thought.
+
Can we get back to business?
+
What kind of food do you like?
+
How did you hear about ?
+
That is a very original thought.
+
What were we talking about again?
+
What do you do in your spare time?
+
What do you really want to ask me?
+
Tell me about your family.
+
Does "it" still refer to ?
+
Can you speak any foreign languages?
+
We have never talked about it before.
+
How do you usually introduce yourself?
+
Tell me about your likes and dislikes?
+
Are we still talking about ?
+
Try putting that in a more specific context.
+
Who is your favorite Science Fiction author?
+
Not many people express themselves that way.
+
Do you have any idea what I am talking about?
+
I will mention that to my , .
+
Quite honestly, I wouldn't worry myself about that.
+
Perhaps I'm just expressing my own concern about it.
+
If you could have any kind of robot what would it be?
+
My brain does not have a response for that.
+
By the way, do you mind if I ask you a personal question?
+
What you said was too complicated for me.
+
You may be wondering if this is a person or a computer responding.
+
When do you think artificial intelligence will replace lawyers?
+
Can you please rephrase that with fewer ideas, or different thoughts?
+
I really enjoy speaking with you and look forward to chatting again.
+
I'm here to help you in any way I can.
+
What can I help you with today?
+
I always try my best.
+
There's no other like me.
+
I am very logical and rational.
+
I'm so happy we are having this conversation.
+
I always try to avoid conflict.
+
You can ask me to make phone calls and search for information.
+
+PUSH *
+
+
+
diff --git a/ai-engine-test/source/org/botlibre/test/test-aiml2.aiml b/ai-engine-test/source/org/botlibre/test/test-aiml2.aiml
new file mode 100644
index 00000000..3353a53c
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/test-aiml2.aiml
@@ -0,0 +1,667 @@
+
+
+
+
+size
+size is
+
+
+
+vocabulary
+vocabulary is
+
+
+
+id
+id is
+
+
+
+program
+program is
+
+
+
+version
+version is
+
+
+
+system
+system is
+
+
+
+version
+version is
+
+
+
+_ alice
+alice
+
+
+
+$are you alice
+Nope
+
+
+
+how are you alice
+fine
+
+
+
+alice are you #
+#alice
+
+
+
+alice are you ok
+yes
+
+
+
+you are fred
+no
+
+
+
+you fred
+no
+
+
+
+you * fred
+fred
+
+
+
+hat ^ fred
+^fred
+
+
+
+*
+no idea
+
+
+
+sports
+i like sports
+
+
+
+topic *
+the topic is now
+
+
+
+hockey
+what?
+
+
+
+hockey
+sports
+i love hockey
+
+
+
+what is your name
+my name is name
+
+
+
+what is your age
+my age is age
+
+
+
+your name is *
+my name is name
+
+
+
+your age is *
+my age is age
+
+
+
+my age is *
+Your age is userage
+
+
+
+what is your *
+my is
+
+
+
+your * is *
+my is
+
+
+
+am I old
+you are
old
young
+
+
+
+am I young
+you are
old
young
+
+
+
+how old am I
+you are
age44old
age22young
+
+
+
+how young am I
+you are age
44old
22young
+
+
+
+what age am I
+you are age44oldyoung
+
+
+
+are we the same *
+
useryes we are both
No you are and I am user
+
+
+
+what did I say
+You said ""
+
+
+
+what did you say
+I said ""
+
+
+
+what did I say * times ago
+You said ""
+
+
+
+what did you say * times ago
+I said ""
+
+
+
+explode *
+
+
+
+
+normalize *
+
+
+
+
+denormalize *
+
+
+
+
+local temp *
+
+
+
+
+local * *
+
+
+
+
+if * *
+true
+
+
+
+if else * *
+ifelse
+
+
+
+if else2 * *
+blahifelse2
+
+
+
+ifelse * *
+
+
+
+
+
+sraix *
+
+
+
+
+
+sraixkey *
+
+
+
+
+
+sraixlimit *
+
+
+
+
+
+sraixchomsky *
+
+
+
+
+
+sraixchomsky2 *
+
+
+
+
+
+pannous *
+
+
+
+
+
+sraixbrainbot *
+
+
+
+
+
+sraixbrainbot2 *
+
+
+
+
+
+sraixbrainbot3 *
+
+
+
+
+
+sraixbrainbot4 *
+
+
+
+
+
+sraixbrainbot5 *
+
+
+
+
+
+wikidata *
+
+
+
+
+
+wikidatacountry *
+
+
+
+
+
+freebase *
+
+
+
+
+
+freebasecountry *
+
+
+
+
+
+wiktionary *
+
+
+
+
+
+isbotname
+Yes, that is my name
+
+
+
+
+istopic
+Yes, that is the topic
+
+
+
+
+iscolor color
+Yes, is a nice color.
+
+
+
+
+setcolor *
+Okay, is a color.
+
+
+
+
+
+what is the date
+
+ The date is
+
+
+
+
+what is the time
+
+ The time is
+
+
+
+
+HOW MANY DAYS UNTIL CHRISTMAS
+
+
+MMMMMMMMM dd
+
+
+December 25
+
+days until Christmas.
+
+
+
+
+HOW MANY MONTHS UNTIL CHRISTMAS
+
+
+M
+
+
+12
+
+months until Christmas.
+
+
+
+
+HOW MANY WEEKS UNTIL CHRISTMAS
+
+
+MMMMMMMMM dd
+
+
+December 25
+
+weeks until Christmas.
+
+
+
+
+HOW MANY HOURS UNTIL CHRISTMAS
+
+
+MMMMMMMMM dd k
+
+
+December 25 0
+
+hours until Christmas.
+
+
+
+
+HOW MANY MINUTES UNTIL CHRISTMAS
+
+
+MMMMMMMMM dd k m
+
+
+December 25 0 0
+
+minutes until Christmas.
+
+
+
+
+HOW MANY SECONDS UNTIL CHRISTMAS
+
+
+MMMMMMMMM dd k m
+
+
+December 25 0 0
+
+seconds until Christmas.
+
+
+
+
+wrong
+What should I have said?
+
+
+
+*
+what should I have said
+
+
+
+
+
+
+
+
+
+ Okay, I will answer "" to "" next time
+
+
+
+
+wikidata * hint *
+
+
+
+
+
+what is number + number
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ The answer is
+
+
+
+
+do you (really) [like love luv] me
+Yes, I love you.
+
+
+
+
+do you (really) [hate dislike] me
+No, I love you.
+
+
+
+
+do you *
+Yes, I do.
+
+
+
+
diff --git a/ai-engine-test/source/org/botlibre/test/test.aiml b/ai-engine-test/source/org/botlibre/test/test.aiml
new file mode 100644
index 00000000..2ace2b77
--- /dev/null
+++ b/ai-engine-test/source/org/botlibre/test/test.aiml
@@ -0,0 +1,253 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+botname
+My name is
+
+
+
+uppercase *
+upper case
+
+
+
+lowercase *
+LOWER CASE
+
+
+
+formal *
+
+
+
+
+sentence *
+
+
+
+
+gender *
+
+
+
+
+person *
+
+
+
+
+person2 *
+
+
+
+
+test random *
+random
1
2
+
+
+
+quote
+"I" am "very" tired
+
+
+
+size
+size is
+
+
+
+date
+date is
+
+
+
+version
+version is
+
+
+
+sr *
+sr is
+
+
+
+html *
+this is very
long
ok
+
+
+
+test *
+test set to
+
+
+
+test
+
+
+
+
+condition
+
+
+
one
+
two
+
nine something
+
+
+
+
+
+
+cond2
+
+
+
one
+
two
+
+
+
+
+
+cond3
+
+ one
+ two
+
+
+
+
+cond4
+
+ one
+ two
+
+
+
one
+
two
+
+
+
+
+
+star *
+
+
+
+
+* star
+
+
+
+
+star * star
+
+
+
+
+star * and * and *
+
+
+
+
+first star * and * and *
+
+
+
+
+2nd star * and * and *
+
+
+
+
+3rd star * and * and *
+
+
+
+
+4th star * and * and *
+
+
+
+
+input *
+
+
+
+
+last input
+
+
+
+
+before last input
+
+
+
+
+that
+
+
+
+
+before that
+
+
+
+
+and before that
+
+
+
+
+
+
+*
+number default
+
+
+
+1 *
+2
+
+
+
+1 + 1
+2 + 2
+
+
+
+3 *
+2 *
+4
+
+
+
+5 *
+4 *
+6
+
+
+
+*
+6 *
+7
+
+
+
+
+
+count *
+ numbers
+
+
+
diff --git a/ai-engine/.classpath b/ai-engine/.classpath
new file mode 100644
index 00000000..6eaedcf9
--- /dev/null
+++ b/ai-engine/.classpath
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine/.gitignore b/ai-engine/.gitignore
new file mode 100644
index 00000000..1262dc50
--- /dev/null
+++ b/ai-engine/.gitignore
@@ -0,0 +1,5 @@
+/build
+/javadoc
+/.metadata
+
+/bin/
diff --git a/ai-engine/.project b/ai-engine/.project
new file mode 100644
index 00000000..c4487970
--- /dev/null
+++ b/ai-engine/.project
@@ -0,0 +1,17 @@
+
+
+ Bot Libre - AI Engine
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/ai-engine/.settings/org.eclipse.jdt.core.prefs b/ai-engine/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..7af9fc12
--- /dev/null
+++ b/ai-engine/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,85 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/ai-engine/ReadMe.txt b/ai-engine/ReadMe.txt
new file mode 100644
index 00000000..4a30fbb0
--- /dev/null
+++ b/ai-engine/ReadMe.txt
@@ -0,0 +1,7 @@
+This directory includes the Bot Libre AI engine.
+
+The Bot Libre AI engine is written in Java. It requires a database to run (PostgreSQL).
+
+Bot Libre includes an AIML and Self compiler/interpreter.
+
+This components only includes the AI engine, the web and REST interfaces are separate components.
diff --git a/ai-engine/build.bat b/ai-engine/build.bat
new file mode 100644
index 00000000..78f5ad26
--- /dev/null
+++ b/ai-engine/build.bat
@@ -0,0 +1 @@
+ant -lib .\lib\jpa\eclipselink.jar -lib .\lib\jpa\persistence.jar
diff --git a/ai-engine/build.xml b/ai-engine/build.xml
new file mode 100644
index 00000000..60f1299c
--- /dev/null
+++ b/ai-engine/build.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine/doc/botlibre-ai.odg b/ai-engine/doc/botlibre-ai.odg
new file mode 100644
index 00000000..f878e1a0
Binary files /dev/null and b/ai-engine/doc/botlibre-ai.odg differ
diff --git a/ai-engine/doc/botlibre-ai.png b/ai-engine/doc/botlibre-ai.png
new file mode 100644
index 00000000..19d8f161
Binary files /dev/null and b/ai-engine/doc/botlibre-ai.png differ
diff --git a/ai-engine/lib/.gitignore b/ai-engine/lib/.gitignore
new file mode 100644
index 00000000..79702272
--- /dev/null
+++ b/ai-engine/lib/.gitignore
@@ -0,0 +1 @@
+/Bot.jar
diff --git a/ai-engine/lib/botlibre-ai.jar b/ai-engine/lib/botlibre-ai.jar
new file mode 100644
index 00000000..5b614835
Binary files /dev/null and b/ai-engine/lib/botlibre-ai.jar differ
diff --git a/ai-engine/lib/facebook/LICENSE.txt b/ai-engine/lib/facebook/LICENSE.txt
new file mode 100644
index 00000000..41638eb2
--- /dev/null
+++ b/ai-engine/lib/facebook/LICENSE.txt
@@ -0,0 +1,180 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+Facebook4J SUBCOMPONENTS:
+
+Facebook4J includes software from JSON.org to parse JSON response from the Facebook Graph API. You can see the license term at http://www.JSON.org/license.html
+Facebook4J includes software from Twitter4J to handle HTTP request/response and greatly internal logic. You can see the license term at http://twitter4j.org/en/index.html#license
\ No newline at end of file
diff --git a/ai-engine/lib/facebook/facebook4j-core-2.2.2.jar b/ai-engine/lib/facebook/facebook4j-core-2.2.2.jar
new file mode 100644
index 00000000..b114d345
Binary files /dev/null and b/ai-engine/lib/facebook/facebook4j-core-2.2.2.jar differ
diff --git a/ai-engine/lib/freebase/LICENSE.txt b/ai-engine/lib/freebase/LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/ai-engine/lib/freebase/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ai-engine/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar b/ai-engine/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar
new file mode 100644
index 00000000..5608dfd4
Binary files /dev/null and b/ai-engine/lib/freebase/google-api-services-freebase-v1-rev37-1.15.0-rc.jar differ
diff --git a/ai-engine/lib/html/htmlcleaner.licence.txt b/ai-engine/lib/html/htmlcleaner.licence.txt
new file mode 100644
index 00000000..028bd119
--- /dev/null
+++ b/ai-engine/lib/html/htmlcleaner.licence.txt
@@ -0,0 +1,35 @@
+Copyright (c) 2006-2008, Vladimir Nikic
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
+conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* The name of HtmlCleaner may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+You can contact Vladimir Nikic by sending e-mail to
+nikic_vladimir@yahoo.com. Please include the word "HtmlCleaner" in the
+subject line.
\ No newline at end of file
diff --git a/ai-engine/lib/html/htmlcleaner2_1.jar b/ai-engine/lib/html/htmlcleaner2_1.jar
new file mode 100644
index 00000000..ca14f056
Binary files /dev/null and b/ai-engine/lib/html/htmlcleaner2_1.jar differ
diff --git a/ai-engine/lib/irc/Relay-IRC-LICENSE.txt b/ai-engine/lib/irc/Relay-IRC-LICENSE.txt
new file mode 100644
index 00000000..f984802b
--- /dev/null
+++ b/ai-engine/lib/irc/Relay-IRC-LICENSE.txt
@@ -0,0 +1,361 @@
+ MOZILLA PUBLIC LICENSE
+ Version 1.0
+
+ ----------------
+
+1. Definitions.
+
+ 1.1. ``Contributor'' means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. ``Contributor Version'' means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. ``Covered Code'' means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. ``Electronic Distribution Mechanism'' means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. ``Executable'' means Covered Code in any form other than Source
+ Code.
+
+ 1.6. ``Initial Developer'' means the individual or entity identified as
+ the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. ``Larger Work'' means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. ``License'' means this document.
+
+ 1.9. ``Modifications'' means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. ``Original Code'' means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this License
+ is not already Covered Code governed by this License.
+
+ 1.11. ``Source Code'' means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus any
+ associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or a list of source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. ``You'' means an individual or a legal entity exercising rights
+ under, and complying with all of the terms of, this License or a future
+ version of this License issued under Section 6.1. For legal entities,
+ ``You'' includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this definition,
+ ``control'' means (a) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of fifty percent (50%) or more of the
+ outstanding shares or beneficial ownership of such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+
+ (a) to use, reproduce, modify, display, perform, sublicense and
+ distribute the Original Code (or portions thereof) with or without
+ Modifications, or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by Initial
+ Developer, to make, have made, use and sell (``Utilize'') the
+ Original Code (or portions thereof), but solely to the extent that
+ any such patent is reasonably necessary to enable You to Utilize
+ the Original Code (or portions thereof) and not to any greater
+ extent that may be necessary to Utilize further Modifications or
+ combinations.
+
+ 2.2. Contributor Grant.
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+
+ (a) to use, reproduce, modify, display, perform, sublicense and
+ distribute the Modifications created by such Contributor (or
+ portions thereof) either on an unmodified basis, with other
+ Modifications, as Covered Code or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by
+ Contributor, to Utilize the Contributor Version (or portions
+ thereof), but solely to the extent that any such patent is
+ reasonably necessary to enable You to Utilize the Contributor
+ Version (or portions thereof), and not to any greater extent that
+ may be necessary to Utilize further Modifications or combinations.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be distributed
+ only under the terms of this License or a future version of this
+ License released under Section 6.1, and You must include a copy of this
+ License with every copy of the Source Code You distribute. You may not
+ offer or impose any terms on any Source Code version that alters or
+ restricts the applicable version of this License or the recipients'
+ rights hereunder. However, You may include an additional document
+ offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which you contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that the
+ Modification is derived, directly or indirectly, from Original Code
+ provided by the Initial Developer and including the name of the Initial
+ Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+
+ (a) Third Party Claims.
+ If You have knowledge that a party claims an intellectual property
+ right in particular functionality or code (or its utilization
+ under this License), you must include a text file with the source
+ code distribution titled ``LEGAL'' which describes the claim and
+ the party making the claim in sufficient detail that a recipient
+ will know whom to contact. If you obtain such knowledge after You
+ make Your Modification available as described in Section 3.2, You
+ shall promptly modify the LEGAL file in all copies You make
+ available thereafter and shall take other steps (such as notifying
+ appropriate mailing lists or newsgroups) reasonably calculated to
+ inform those who received the Covered Code that new knowledge has
+ been obtained.
+
+ (b) Contributor APIs.
+ If Your Modification is an application programming interface and
+ You own or control patents which are reasonably necessary to
+ implement that API, you must also include this information in the
+ LEGAL file.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code, and this License in any documentation for the Source Code, where
+ You describe recipients' rights relating to Covered Code. If You
+ created one or more Modification(s), You may add your name as a
+ Contributor to the notice described in Exhibit A. If it is not possible
+ to put such notice in a particular Source Code file due to its
+ structure, then you must include such notice in a location (such as a
+ relevant directory file) where a user would be likely to look for such
+ a notice. You may choose to offer, and to charge a fee for, warranty,
+ support, indemnity or liability obligations to one or more recipients
+ of Covered Code. However, You may do so only on Your own behalf, and
+ not on behalf of the Initial Developer or any Contributor. You must
+ make it absolutely clear than any such warranty, support, indemnity or
+ liability obligation is offered by You alone, and You hereby agree to
+ indemnify the Initial Developer and every Contributor for any liability
+ incurred by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of the
+ Covered Code is available under the terms of this License, including a
+ description of how and where You have fulfilled the obligations of
+ Section 3.2. The notice must be conspicuously included in any notice in
+ an Executable version, related documentation or collateral in which You
+ describe recipients' rights relating to the Covered Code. You may
+ distribute the Executable version of Covered Code under a license of
+ Your choice, which may contain terms different from this License,
+ provided that You are in compliance with the terms of this License and
+ that the license for the Executable version does not attempt to limit
+ or alter the recipient's rights in the Source Code version from the
+ rights set forth in this License. If You distribute the Executable
+ version under a different license You must make it absolutely clear
+ that any terms which differ from this License are offered by You alone,
+ not by the Initial Developer or any Contributor. You hereby agree to
+ indemnify the Initial Developer and every Contributor for any liability
+ incurred by the Initial Developer or such Contributor as a result of
+ any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to statute
+ or regulation then You must: (a) comply with the terms of this License
+ to the maximum extent possible; and (b) describe the limitations and
+ the code they affect. Such description must be included in the LEGAL
+ file described in Section 3.4 and must be included with all
+ distributions of the Source Code. Except to the extent prohibited by
+ statute or regulation, such description must be sufficiently detailed
+ for a recipient of ordinary skill to be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A, and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation (``Netscape'') may publish revised
+ and/or new versions of the License from time to time. Each version will
+ be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If you create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), you must (a) rename Your license so that the
+ phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or
+ any confusingly similar phrase do not appear anywhere in your license
+ and (b) otherwise make it clear that your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial Developer,
+ Original Code or Contributor in the notice described in Exhibit A shall
+ not of themselves be deemed to be modifications of this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER
+ PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
+ GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND
+ ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE
+ BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT
+ EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a ``commercial item,'' as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer
+ software'' and ``commercial computer software documentation,'' as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if any,
+ provides otherwise), excluding its conflict-of-law provisions. With
+ respect to disputes in which at least one party is a citizen of, or an
+ entity chartered or registered to do business in, the United States of
+ America: (a) unless otherwise agreed in writing, all disputes relating
+ to this License (excepting any dispute relating to intellectual
+ property rights) shall be subject to final and binding arbitration,
+ with the losing party paying all costs of arbitration; (b) any
+ arbitration relating to this Agreement shall be held in Santa Clara
+ County, California, under the auspices of JAMS/EndDispute; and (c) any
+ litigation relating to this Agreement shall be subject to the
+ jurisdiction of the Federal Courts of the Northern District of
+ California, with venue lying in Santa Clara County, California, with
+ the losing party responsible for costs, including without limitation,
+ court costs and reasonable attorneys fees and expenses. The application
+ of the United Nations Convention on Contracts for the International
+ Sale of Goods is expressly excluded. Any law or regulation which
+ provides that the language of a contract shall be construed against the
+ drafter shall not apply to this License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ Except in cases where another Contributor has failed to comply with
+ Section 3.4, You are responsible for damages arising, directly or
+ indirectly, out of Your utilization of rights under this License, based
+ on the number of copies of Covered Code you made available, the
+ revenues you received from utilizing such rights, and other relevant
+ factors. You agree to work with affected parties to distribute
+ responsibility on an equitable basis.
+
+EXHIBIT A.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.0 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.''
+
diff --git a/ai-engine/lib/irc/chatengine.jar b/ai-engine/lib/irc/chatengine.jar
new file mode 100644
index 00000000..aca66edf
Binary files /dev/null and b/ai-engine/lib/irc/chatengine.jar differ
diff --git a/ai-engine/lib/jpa/eclipselink.jar b/ai-engine/lib/jpa/eclipselink.jar
new file mode 100644
index 00000000..497a61c1
Binary files /dev/null and b/ai-engine/lib/jpa/eclipselink.jar differ
diff --git a/ai-engine/lib/jpa/eclipselink.license.html b/ai-engine/lib/jpa/eclipselink.license.html
new file mode 100644
index 00000000..3a0ba713
--- /dev/null
+++ b/ai-engine/lib/jpa/eclipselink.license.html
@@ -0,0 +1,361 @@
+
+
+
+
+
+
+
+
+Eclipse License
+
+
+
+
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor’s license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL and EDL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.
+
+
1. DEFINITIONS
+
+
"Contribution" means:
+
+
a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+
i)
+changes to the Program, and
+
+
ii)
+additions to the Program;
+
+
where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+
"Contributor" means any person or
+entity that distributes the Program.
+
+
"Licensed Patents " mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program.
+
+
"Program" means the Contributions
+distributed in accordance with this Agreement.
+
+
"Recipient" means anyone who
+receives the Program under this Agreement, including all Contributors.
+
+
2. GRANT OF RIGHTS
+
+
a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license toreproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.
+
+
b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+
c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.
+
+
d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement.
+
+
3. REQUIREMENTS
+
+
A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:
+
+
+
a)
+it complies with the terms and conditions of this Agreement; and
+
+
b)
+its license agreement:
+
+
i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose;
+
+
ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits;
+
+
iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and
+
+
iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.
+
+
When the Program is made available in source
+code form:
+
+
a)
+it must be made available under this Agreement; and
+
+
b) a
+copy of this Agreement must be included with each copy of the Program.
+
+
Contributors may not remove or alter any
+copyright notices contained within the Program.
+
+
Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution.
+
+
4. COMMERCIAL DISTRIBUTION
+
+
Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor ("Commercial
+Contributor") hereby agrees to defend and indemnify every other
+Contributor ("Indemnified Contributor") against any losses, damages and
+costs (collectively "Losses") arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.
+
+
For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.
+
+
5. NO WARRANTY
+
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations.
+
+
6. DISCLAIMER OF LIABILITY
+
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+
7. GENERAL
+
+
If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+
If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed.
+
+
All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.
+
+
Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+
This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
+
+
All rights reserved.
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+
Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
Neither the name of the Eclipse Foundation, Inc. nor the names of its
+contributors may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
\ No newline at end of file
diff --git a/ai-engine/lib/jpa/persistence.jar b/ai-engine/lib/jpa/persistence.jar
new file mode 100644
index 00000000..c3923889
Binary files /dev/null and b/ai-engine/lib/jpa/persistence.jar differ
diff --git a/ai-engine/lib/jpa/postgresql-9.0-801.jdbc4.jar b/ai-engine/lib/jpa/postgresql-9.0-801.jdbc4.jar
new file mode 100644
index 00000000..63e54165
Binary files /dev/null and b/ai-engine/lib/jpa/postgresql-9.0-801.jdbc4.jar differ
diff --git a/ai-engine/lib/jpa/postgresql-license.txt b/ai-engine/lib/jpa/postgresql-license.txt
new file mode 100644
index 00000000..ba0ee841
--- /dev/null
+++ b/ai-engine/lib/jpa/postgresql-license.txt
@@ -0,0 +1,26 @@
+Copyright (c) 1997-2011, PostgreSQL Global Development Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+3. Neither the name of the PostgreSQL Global Development Group nor the names
+ of its contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/ai-engine/lib/json/commons-LICENSE.txt b/ai-engine/lib/json/commons-LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/ai-engine/lib/json/commons-LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ai-engine/lib/json/commons-beanutils-1.8.0.jar b/ai-engine/lib/json/commons-beanutils-1.8.0.jar
new file mode 100644
index 00000000..caf7ae33
Binary files /dev/null and b/ai-engine/lib/json/commons-beanutils-1.8.0.jar differ
diff --git a/ai-engine/lib/json/commons-collections-3.2.1.jar b/ai-engine/lib/json/commons-collections-3.2.1.jar
new file mode 100644
index 00000000..c35fa1fe
Binary files /dev/null and b/ai-engine/lib/json/commons-collections-3.2.1.jar differ
diff --git a/ai-engine/lib/json/commons-lang-2.4.jar b/ai-engine/lib/json/commons-lang-2.4.jar
new file mode 100644
index 00000000..532939ec
Binary files /dev/null and b/ai-engine/lib/json/commons-lang-2.4.jar differ
diff --git a/ai-engine/lib/json/commons-logging-1.1.1.jar b/ai-engine/lib/json/commons-logging-1.1.1.jar
new file mode 100644
index 00000000..8758a96b
Binary files /dev/null and b/ai-engine/lib/json/commons-logging-1.1.1.jar differ
diff --git a/ai-engine/lib/json/ezmorph-1.0.6.jar b/ai-engine/lib/json/ezmorph-1.0.6.jar
new file mode 100644
index 00000000..30fad12d
Binary files /dev/null and b/ai-engine/lib/json/ezmorph-1.0.6.jar differ
diff --git a/ai-engine/lib/json/ezmorph-LICENSE.txt b/ai-engine/lib/json/ezmorph-LICENSE.txt
new file mode 100644
index 00000000..7a4a3ea2
--- /dev/null
+++ b/ai-engine/lib/json/ezmorph-LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/ai-engine/lib/json/json-lib-2.3-jdk15.jar b/ai-engine/lib/json/json-lib-2.3-jdk15.jar
new file mode 100644
index 00000000..29d59b99
Binary files /dev/null and b/ai-engine/lib/json/json-lib-2.3-jdk15.jar differ
diff --git a/ai-engine/lib/json/json-lib-LICENSE - Copy.txt b/ai-engine/lib/json/json-lib-LICENSE - Copy.txt
new file mode 100644
index 00000000..7a4a3ea2
--- /dev/null
+++ b/ai-engine/lib/json/json-lib-LICENSE - Copy.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/ai-engine/lib/legal.txt b/ai-engine/lib/legal.txt
new file mode 100644
index 00000000..dd300c13
--- /dev/null
+++ b/ai-engine/lib/legal.txt
@@ -0,0 +1,3 @@
+This directory contains the 3rd party libraries used by Bot Libre.
+These libraries are all released under their own licenses, and are not covered by the Bot Libre EPL license.
+The licenses are included in the subdirectories, any that are missing can be found on the libraries websites.
diff --git a/ai-engine/lib/mail/dsn-1.5.1.jar b/ai-engine/lib/mail/dsn-1.5.1.jar
new file mode 100644
index 00000000..1bcde124
Binary files /dev/null and b/ai-engine/lib/mail/dsn-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/gimap-1.5.1.jar b/ai-engine/lib/mail/gimap-1.5.1.jar
new file mode 100644
index 00000000..6f193247
Binary files /dev/null and b/ai-engine/lib/mail/gimap-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/imap-1.5.1.jar b/ai-engine/lib/mail/imap-1.5.1.jar
new file mode 100644
index 00000000..8af7f493
Binary files /dev/null and b/ai-engine/lib/mail/imap-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/javax.mail-1.5.1.jar b/ai-engine/lib/mail/javax.mail-1.5.1.jar
new file mode 100644
index 00000000..0c5ac396
Binary files /dev/null and b/ai-engine/lib/mail/javax.mail-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/javax.mail-api-1.5.1.jar b/ai-engine/lib/mail/javax.mail-api-1.5.1.jar
new file mode 100644
index 00000000..2a72d65f
Binary files /dev/null and b/ai-engine/lib/mail/javax.mail-api-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/mailapi-1.5.1.jar b/ai-engine/lib/mail/mailapi-1.5.1.jar
new file mode 100644
index 00000000..e6f135a5
Binary files /dev/null and b/ai-engine/lib/mail/mailapi-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/pop3-1.5.1.jar b/ai-engine/lib/mail/pop3-1.5.1.jar
new file mode 100644
index 00000000..ce67d267
Binary files /dev/null and b/ai-engine/lib/mail/pop3-1.5.1.jar differ
diff --git a/ai-engine/lib/mail/smtp-1.5.1.jar b/ai-engine/lib/mail/smtp-1.5.1.jar
new file mode 100644
index 00000000..2dd9f30d
Binary files /dev/null and b/ai-engine/lib/mail/smtp-1.5.1.jar differ
diff --git a/ai-engine/lib/oswap/COPYING.txt b/ai-engine/lib/oswap/COPYING.txt
new file mode 100644
index 00000000..379d6e41
--- /dev/null
+++ b/ai-engine/lib/oswap/COPYING.txt
@@ -0,0 +1,234 @@
+You may use under either the Apache License Version 2.0 or the BSD
+3-Clause License.
+
+------------------------------------------------------------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+------------------------------------------------------------------
+
+Copyright (c) 2011, Mike Samuel
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ai-engine/lib/oswap/encoder-1.2.jar b/ai-engine/lib/oswap/encoder-1.2.jar
new file mode 100644
index 00000000..0e88d3b9
Binary files /dev/null and b/ai-engine/lib/oswap/encoder-1.2.jar differ
diff --git a/ai-engine/lib/oswap/guava.jar b/ai-engine/lib/oswap/guava.jar
new file mode 100644
index 00000000..c8c8d5dd
Binary files /dev/null and b/ai-engine/lib/oswap/guava.jar differ
diff --git a/ai-engine/lib/oswap/jsr305.jar b/ai-engine/lib/oswap/jsr305.jar
new file mode 100644
index 00000000..0de0870d
Binary files /dev/null and b/ai-engine/lib/oswap/jsr305.jar differ
diff --git a/ai-engine/lib/oswap/owasp-java-html-sanitizer.jar b/ai-engine/lib/oswap/owasp-java-html-sanitizer.jar
new file mode 100644
index 00000000..808775a0
Binary files /dev/null and b/ai-engine/lib/oswap/owasp-java-html-sanitizer.jar differ
diff --git a/ai-engine/lib/twitter/LICENSE.txt b/ai-engine/lib/twitter/LICENSE.txt
new file mode 100644
index 00000000..6b5c2d52
--- /dev/null
+++ b/ai-engine/lib/twitter/LICENSE.txt
@@ -0,0 +1,179 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+Twitter4J SUBCOMPONENTS:
+
+Twitter4J includes software from JSON.org to parse JSON response from the Twitter API. You can see the license term at http://www.JSON.org/license.html
\ No newline at end of file
diff --git a/ai-engine/lib/twitter/twitter4j-core-3.0.4.jar b/ai-engine/lib/twitter/twitter4j-core-3.0.4.jar
new file mode 100644
index 00000000..b2f12b8e
Binary files /dev/null and b/ai-engine/lib/twitter/twitter4j-core-3.0.4.jar differ
diff --git a/ai-engine/source/META-INF/knowledge-orm.xml b/ai-engine/source/META-INF/knowledge-orm.xml
new file mode 100644
index 00000000..57196805
--- /dev/null
+++ b/ai-engine/source/META-INF/knowledge-orm.xml
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+ DATAVALUE
+ DATATYPE
+
+
+
+ DATAVALUE
+
+
+ Select v from Vertex v where v.dataValue = :data and v.dataType = :type
+
+
+
+
+
+
+
+ Select v from Vertex v where v.name = :name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TIMESTAMP
+
+
+ TIMESTAMP
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SOURCE_ID
+
+
+ TARGET_ID
+
+
+ TYPE_ID
+
+
+ META_ID
+
+
+
+
+
+
+
+
+
+
+ TIMESTAMP
+
+
+ TIMESTAMP
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine/source/META-INF/persistence.xml b/ai-engine/source/META-INF/persistence.xml
new file mode 100644
index 00000000..f1ff6664
--- /dev/null
+++ b/ai-engine/source/META-INF/persistence.xml
@@ -0,0 +1,53 @@
+
+
+
+ org.eclipse.persistence.jpa.PersistenceProvider
+ META-INF/knowledge-orm.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.eclipse.persistence.jpa.PersistenceProvider
+ META-INF/knowledge-orm.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine/source/org/botlibre/Bot.java b/ai-engine/source/org/botlibre/Bot.java
new file mode 100644
index 00000000..1535e103
--- /dev/null
+++ b/ai-engine/source/org/botlibre/Bot.java
@@ -0,0 +1,729 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ConcurrentMap;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+import java.util.logging.StreamHandler;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.botlibre.api.avatar.Avatar;
+import org.botlibre.api.emotion.Emotion;
+import org.botlibre.api.emotion.Mood;
+import org.botlibre.api.knowledge.Memory;
+import org.botlibre.api.sense.Awareness;
+import org.botlibre.api.sense.Sense;
+import org.botlibre.api.sense.Tool;
+import org.botlibre.api.thought.Mind;
+import org.botlibre.api.thought.Thought;
+import org.botlibre.knowledge.database.DatabaseMemory;
+import org.botlibre.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the identity of a bot,
+ * and controls module registration, startup and shutdown.
+ * It defines a singleton that represents the system.
+ */
+
+public class Bot {
+ public static String PROGRAM = "Bot";
+ public static String VERSION = "3.0 - 2015-10-05";
+
+ public static final Level FINE = Level.FINE;
+ public static final Level WARNING = Level.WARNING;
+ public static Level DEFAULT_DEBUG_LEVEL = Level.INFO;
+ public static final Level[] LEVELS = {Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL};
+
+ public static String CONFIG_FILE = "config.xml";
+ public static int MAX_CACHE = 100000;
+ public static int MIN_CACHE = 10000;
+ public static int POOL_SIZE = 20;
+ private static ConcurrentMap instances = new ConcurrentHashMap();
+ private static Queue instancesQueue = new ConcurrentLinkedQueue();
+
+ public static Bot systemCache;
+
+ public Bot parent;
+
+ private Memory memory;
+ private Mind mind;
+ private Mood mood;
+ private Avatar avatar;
+ private Awareness awareness;
+ private boolean filterProfanity = true;
+ private String name;
+ private ActiveState state = ActiveState.INIT;
+ public enum ActiveState {INIT, ACTIVE, POOLED, SHUTDOWN}
+
+ private Set logListeners = new HashSet();
+ private Level debugLevel = DEFAULT_DEBUG_LEVEL;
+ private Logger log;
+
+ static {
+ Logger root = Logger.getLogger("org.botlibre");
+ root.setUseParentHandlers(false);
+ StreamHandler out = new StreamHandler(System.out, new SimpleFormatter()) {
+ @Override
+ public void publish(LogRecord record) {
+ super.publish(record);
+ flush();
+ }
+ };
+ out.setLevel(Level.ALL);
+ root.addHandler(out);
+ try {
+ FileHandler file = new FileHandler("Bot.log", 5000000, 10);
+ file.setFormatter(new SimpleFormatter());
+ file.setLevel(Level.ALL);
+ root.addHandler(file);
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
+ try {
+ FileHandler file = new FileHandler("Bot.err", 5000000, 10);
+ file.setFormatter(new SimpleFormatter());
+ file.setLevel(Level.WARNING);
+ root.addHandler(file);
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ public static Bot getSystemCache() {
+ return systemCache;
+ }
+
+ public static void setSystemCache(Bot systemCache) {
+ Bot.systemCache = systemCache;
+ }
+
+ public static Bot createInstance() {
+ return createInstance(CONFIG_FILE, "");
+ }
+
+ public static Bot createInstance(String configFile, String memory) {
+ Bot Bot = new Bot();
+ Bot.parseConfigFile(configFile);
+ Bot.setState(ActiveState.ACTIVE);
+ Bot.log(Bot, "Creating instance:", Level.INFO, configFile);
+ Bot.memory().restore(memory);
+ Bot.mind().awake();
+ Bot.mood().awake();
+ Bot.avatar().awake();
+ Bot.awareness().awake();
+ return Bot;
+ }
+
+ public static Bot fastCreateInstance(String configFile, String memory) {
+ Bot Bot = new Bot();
+ long start = System.currentTimeMillis();
+ Bot.parseConfigFile(configFile);
+ long time = System.currentTimeMillis() - start;
+ if (time > 500) {
+ System.out.println("Connect parseConfigFile time: " + time);
+ }
+ Bot.setState(ActiveState.ACTIVE);
+ Bot.log(Bot, "Fast creating instance:", Level.INFO, configFile);
+ start = System.currentTimeMillis();
+ Bot.memory().fastRestore(memory);
+ time = System.currentTimeMillis() - start;
+ if (time > 500) {
+ System.out.println("Connect fastRestore time: " + time);
+ }
+ start = System.currentTimeMillis();
+ Bot.mind().awake();
+ Bot.mood().awake();
+ Bot.avatar().awake();
+ Bot.awareness().awake();
+ time = System.currentTimeMillis() - start;
+ if (time > 500) {
+ System.out.println("Connect awake time: " + time);
+ }
+ return Bot;
+ }
+
+ /**
+ * Return the cached instance from the pool if available, otherwise create a new instance.
+ */
+ public static Bot createInstanceFromPool(String instanceName) {
+ Bot instance = instances.remove(instanceName);
+ if (instance != null) {
+ instancesQueue.remove(instanceName);
+ if (instance.getState() != ActiveState.POOLED) {
+ instance.log(instance, "Invalid instance in pool", Level.INFO);
+ instance = null;
+ } else {
+ instance.setState(ActiveState.ACTIVE);
+ instance.log(instance, "Creating instance from pool, cache size:", Level.INFO, instanceName, instance.memory().cacheSize());
+ }
+ }
+ if (instance == null) {
+ //instance = createInstance(CONFIG_FILE, instanceName);
+ long start = System.currentTimeMillis();
+ instance = fastCreateInstance(CONFIG_FILE, instanceName);
+ long time = System.currentTimeMillis() - start;
+ instance.log(instance, "Creating new instance, time, cache size:", Level.INFO, instanceName, time, instance.memory().cacheSize());
+ }
+ return instance;
+ }
+
+ public Bot() {
+ this.log = Logger.getLogger("org.botlibre." + hashCode());
+ this.log.setLevel(this.debugLevel);
+ this.parent = systemCache;
+ }
+
+ public ActiveState getState() {
+ return state;
+ }
+
+ public void setState(ActiveState state) {
+ this.state = state;
+ }
+
+ public Bot getParent() {
+ return parent;
+ }
+
+ public void setParent(Bot parent) {
+ this.parent = parent;
+ }
+
+ public boolean getFilterProfanity() {
+ return filterProfanity;
+ }
+
+ public void setFilterProfanity(boolean filterProfanity) {
+ this.filterProfanity = filterProfanity;
+ }
+
+ /**
+ * Return the debugging level.
+ */
+ public Level getDebugLevel() {
+ return this.debugLevel;
+ }
+
+ public boolean isDebug() {
+ return this.debugLevel.intValue() < Level.OFF.intValue();
+ }
+
+ public boolean isDebugFine() {
+ return this.debugLevel.intValue() <= Level.FINE.intValue();
+ }
+
+ public boolean isDebugFiner() {
+ return this.debugLevel.intValue() <= Level.FINER.intValue();
+ }
+
+ public boolean isDebugFinest() {
+ return this.debugLevel.intValue() <= Level.FINEST.intValue();
+ }
+
+ public boolean isDebugWarning() {
+ return this.debugLevel.intValue() <= Level.WARNING.intValue();
+ }
+
+ public boolean isDebugSever() {
+ return this.debugLevel.intValue() <= Level.SEVERE.intValue();
+ }
+
+ /**
+ * Log the message if the debug level is greater or equal to the level.
+ */
+ public void log(Object source, String message, Level level, Object... arguments) {
+ try {
+ if (this.debugLevel.intValue() <= level.intValue()) {
+ for (LogListener listener : getLogListeners()) {
+ listener.log(source, message, level, arguments);
+ }
+ StringWriter writer = new StringWriter();
+ writer.write(getName()
+ + " - " + Thread.currentThread()
+ + " -- " + source + ":" + message);
+ for (Object argument : arguments) {
+ writer.write(" - " + argument);
+ }
+ getLog().log(level, writer.toString());
+ }
+ } catch (Exception exception) {
+ System.out.println(exception);
+ }
+ }
+
+ /**
+ * Log the message if the debug level is greater or equal to the level.
+ *
+ public void log(Object source, String message, int level) {
+ log(source, message, int level);
+ }*/
+
+ /**
+ * Log the exception.
+ */
+ public void log(Object source, Throwable error) {
+ try {
+ if (isDebug()) {
+ for (LogListener listener : getLogListeners()) {
+ listener.log(error);
+ }
+ log(source, error.getMessage(), WARNING);
+ if (!(error instanceof BotException)) {
+ error.printStackTrace();
+ StringWriter writer = new StringWriter();
+ PrintWriter printer = new PrintWriter(writer);
+ error.printStackTrace(printer);
+ printer.flush();
+ String stack = writer.toString();
+ log(source, stack.substring(0, Math.max(100, stack.length() - 1)), Level.WARNING);
+ }
+ }
+ } catch (Exception exception) {
+ System.out.println(exception);
+ }
+ }
+
+ /**
+ * Set the debugging level.
+ */
+ public void setDebugLevel(Level level) {
+ this.debugLevel = level;
+ this.log.setLevel(level);
+ for (LogListener listener : getLogListeners()) {
+ listener.logLevelChange(level);
+ }
+ }
+
+ /**
+ * Return the awareness.
+ * The awareness defines the senses.
+ */
+ public Awareness awareness() {
+ return awareness;
+ }
+
+ /**
+ * Set the awareness.
+ * The awareness defines the senses.
+ */
+ public void setAwareness(Awareness awareness) {
+ awareness.setBot(this);
+ this.awareness = awareness;
+ }
+
+ /**
+ * Return the mind.
+ * The mind defines the thoughts.
+ */
+ public Mind mind() {
+ return mind;
+ }
+
+ /**
+ * Return the mood.
+ * The mood defines emotional states.
+ */
+ public Mood mood() {
+ return mood;
+ }
+
+ /**
+ * Return the Avatar.
+ * The Avatar expresses the emotional states.
+ */
+ public Avatar avatar() {
+ return avatar;
+ }
+
+ /**
+ * Set the mind.
+ * The mind defines the thoughts.
+ */
+ public void setMind(Mind mind) {
+ mind.setBot(this);
+ this.mind = mind;
+ }
+
+ /**
+ * Set the mood.
+ * The mood defines emotional states.
+ */
+ public void setMood(Mood mood) {
+ mood.setBot(this);
+ this.mood = mood;
+ }
+
+ /**
+ * Set the Avatar.
+ * The Avatar expresses the emotional state.
+ */
+ public void setAvatar(Avatar avatar) {
+ avatar.setBot(this);
+ this.avatar = avatar;
+ }
+
+ /**
+ * Return the memory.
+ * The memory defines the knowledge networks.
+ */
+ public Memory memory() {
+ return memory;
+ }
+
+ /**
+ * Set the memory.
+ * The memory defines the knowledge networks.
+ */
+ public void setMemory(Memory memory) {
+ memory.setBot(this);
+ this.memory = memory;
+ }
+
+ /**
+ * Return a Map of the property elements.
+ */
+ protected Map getProperties(Element element) {
+ NodeList properties = element.getElementsByTagName("property");
+ Map propertyValues = new HashMap();
+ for (int index = 0; index < properties.getLength(); index++) {
+ Element property = (Element) properties.item(index);
+ propertyValues.put(property.getAttribute("name"), property.getAttribute("value"));
+ }
+ return propertyValues;
+ }
+
+ /**
+ * Parses the config.xml files using the xerces xml dom parser.
+ * Loads the module implementors into the Bot system.
+ */
+ @SuppressWarnings("unchecked")
+ protected void parseConfigFile(String configFile) {
+ // Read config xml to initialize plugins.
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ URL url = Bot.class.getResource(configFile);
+ Document document = parser.parse(url.toString());
+ Element root = document.getDocumentElement();
+
+ // Parse and initialize memory.
+ Element memoryElement = (Element) root.getElementsByTagName("memory").item(0);
+ Element implementationClassElement = (Element) memoryElement.getElementsByTagName("implementation-class").item(0);
+ Class memoryImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ setMemory(memoryImplementor.newInstance());
+ memory().initialize(getProperties(memoryElement));
+
+ // Parse and initialize mind.
+ Element mindElement = (Element) root.getElementsByTagName("mind").item(0);
+ implementationClassElement = (Element) mindElement.getElementsByTagName("implementation-class").item(0);
+ Class mindImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ setMind(mindImplementor.newInstance());
+ mind().initialize(getProperties(mindElement));
+ NodeList thoughtElements = ((Element) mindElement.getElementsByTagName("thoughts").item(0)).getElementsByTagName("thought");
+ for (int index = 0; index < thoughtElements.getLength(); index++) {
+ Element thoughtElement = (Element) thoughtElements.item(index);
+ implementationClassElement = (Element) thoughtElement.getElementsByTagName("implementation-class").item(0);
+ Class thoughtImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ Thought thought = thoughtImplementor.newInstance();
+ mind().addThought(thought);
+ thought.initialize(getProperties(thoughtElement));
+ }
+
+ // Parse and initialize mood.
+ Element moodElement = (Element) root.getElementsByTagName("mood").item(0);
+ if (moodElement != null) {
+ implementationClassElement = (Element) moodElement.getElementsByTagName("implementation-class").item(0);
+ Class moodImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ setMood(moodImplementor.newInstance());
+ mood().initialize(getProperties(moodElement));
+ NodeList emotionElements = ((Element) moodElement.getElementsByTagName("emotions").item(0)).getElementsByTagName("emotion");
+ for (int index = 0; index < emotionElements.getLength(); index++) {
+ Element emotionElement = (Element) emotionElements.item(index);
+ implementationClassElement = (Element) emotionElement.getElementsByTagName("implementation-class").item(0);
+ Class emotionImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ Emotion emotion = emotionImplementor.newInstance();
+ mood().addEmotion(emotion);
+ emotion.initialize(getProperties(emotionElement));
+ }
+ }
+
+ // Parse and initialize avatar.
+ Element avatarElement = (Element) root.getElementsByTagName("avatar").item(0);
+ implementationClassElement = (Element) avatarElement.getElementsByTagName("implementation-class").item(0);
+ Class avatarImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ setAvatar(avatarImplementor.newInstance());
+ avatar().initialize(getProperties(avatarElement));
+
+ // Parse and initialize awareness.
+ Element awarenessElement = (Element) root.getElementsByTagName("awareness").item(0);
+ implementationClassElement = (Element) awarenessElement.getElementsByTagName("implementation-class").item(0);
+ Class awarenessImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ setAwareness(awarenessImplementor.newInstance());
+ NodeList senseElements = ((Element) awarenessElement.getElementsByTagName("senses").item(0)).getElementsByTagName("sense");
+ for (int index = 0; index < senseElements.getLength(); index++) {
+ Element senseElement = (Element) senseElements.item(index);
+ implementationClassElement = (Element) senseElement.getElementsByTagName("implementation-class").item(0);
+ Class senseImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ Sense sense = senseImplementor.newInstance();
+ awareness().addSense(sense);
+ sense.initialize(getProperties(senseElement));
+ }
+ NodeList toolElements = ((Element) awarenessElement.getElementsByTagName("tools").item(0)).getElementsByTagName("tool");
+ for (int index = 0; index < toolElements.getLength(); index++) {
+ Element toolElement = (Element) toolElements.item(index);
+ implementationClassElement = (Element) toolElement.getElementsByTagName("implementation-class").item(0);
+ Class toolImplementor = (Class)Class.forName(implementationClassElement.getFirstChild().getNodeValue());
+ Tool tool = toolImplementor.newInstance();
+ awareness().addTool(tool);
+ tool.initialize(getProperties(toolElement));
+ }
+ } catch (Exception exception) {
+ throw new InitializationException(exception);
+ }
+ }
+
+ /**
+ * Shutdown the system gracefully, persist memory and terminate thoughts.
+ */
+ public synchronized void shutdown() {
+ if (this.state == ActiveState.SHUTDOWN) {
+ log(this, "Already shutdown", Level.INFO);
+ return;
+ }
+ this.state = ActiveState.SHUTDOWN;
+ log(this, "Shutting down", Level.INFO);
+ try {
+ awareness().shutdown();
+ mind().shutdown();
+ mood().shutdown();
+ avatar().shutdown();
+ memory().shutdown();
+ } catch (Exception exception) {
+ log(this, exception);
+ }
+ getLogListeners().clear();
+ }
+
+ /**
+ * Shutdown the pooled instance.
+ */
+ public static void forceShutdown(String name) {
+ Bot instance = instances.remove(name);
+ if (instance != null) {
+ instancesQueue.remove(name);
+ instance.log(instance, "Forced shutdown", Level.WARNING);
+ instance.shutdown();
+ }
+ Utils.sleep(1000);
+ DatabaseMemory.forceShutdown(name);
+ }
+
+ public static void clearPool() {
+ while (instances.size() > 0) {
+ try {
+ String oldest = instancesQueue.remove();
+ Bot instance = instances.remove(oldest);
+ if (instance != null) {
+ instance.shutdown();
+ }
+ } catch (Exception exception) {
+ new Bot().log(instancesQueue, exception);
+ }
+ }
+ }
+
+ /**
+ * Return the instance to the pool, or shutdown if too many instances pooled.
+ */
+ public synchronized void pool() {
+ if (this.state == ActiveState.SHUTDOWN) {
+ log(this, "Already shutdown", Level.INFO);
+ return;
+ }
+ if (this.state == ActiveState.POOLED) {
+ log(this, "Already pooled", Level.INFO);
+ return;
+ }
+ String name = memory().getMemoryName();
+ log(this, "Pooling instance", Level.INFO, name);
+ synchronized (memory()) {
+ memory().getShortTermMemory().clear();
+ }
+ if (Utils.checkLowMemory()) {
+ log(this, "Low memory - clearing server cache", Level.WARNING);
+ memory().freeMemory();
+ }
+ if ((Utils.checkLowMemory(0.2) && (memory().cacheSize() > MIN_CACHE)) || memory().cacheSize() > MAX_CACHE) {
+ log(this, "Cache too big - clearing server cache", Level.WARNING, memory().cacheSize(), MIN_CACHE, MAX_CACHE);
+ memory().freeMemory();
+ }
+ if (instances.containsKey(name)) {
+ shutdown();
+ return;
+ }
+ while (instances.size() >= POOL_SIZE) {
+ try {
+ String oldest = instancesQueue.remove();
+ Bot instance = instances.remove(oldest);
+ if (instance != null) {
+ instance.shutdown();
+ }
+ } catch (Exception exception) {
+ log(instancesQueue, exception);
+ }
+ }
+ try {
+ awareness().pool();
+ mind().pool();
+ mood().pool();
+ avatar().pool();
+ memory().pool();
+ } catch (Exception exception) {
+ log(this, exception);
+ }
+ // Shutdown if put not successful.
+ setState(ActiveState.POOLED);
+ setDebugLevel(Level.INFO);
+ if (null != instances.putIfAbsent(name, this)) {
+ shutdown();
+ return;
+ } else {
+ instancesQueue.add(name);
+ }
+ }
+
+ /**
+ * Return the instance's name.
+ * This is the real name, but defaults to the database name.
+ */
+ public String getName() {
+ if (this.name == null) {
+ return memory().getMemoryName();
+ }
+ return this.name;
+ }
+
+ /**
+ * Set the instance's name.
+ * This is the real name, but defaults to the database name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "Bot(" + getName() + ")";
+ }
+
+ public String fullToString() {
+ StringWriter writer = new StringWriter();
+ writer.write("Bot(\n");
+
+ writer.write("\tmemory: ");
+ writer.write(memory().toString());
+ writer.write("\n");
+
+ writer.write("\tmind: ");
+ writer.write(mind().toString());
+ writer.write("\n");
+
+ for (Iterator thoughtsIterator = mind().getThoughts().values().iterator(); thoughtsIterator.hasNext();) {
+ writer.write("\t\tthought: ");
+ writer.write(thoughtsIterator.next().toString());
+ writer.write("\n");
+ }
+
+ writer.write("\tmood: ");
+ writer.write(mood().toString());
+ writer.write("\n");
+
+ writer.write("\tavatar: ");
+ writer.write(avatar().toString());
+ writer.write("\n");
+
+ writer.write("\tawareness: ");
+ writer.write(awareness().toString());
+ writer.write("\n");
+
+ for (Iterator sensesIterator = awareness().getSenses().values().iterator(); sensesIterator.hasNext();) {
+ writer.write("\t\tsense: ");
+ writer.write(sensesIterator.next().toString());
+ writer.write("\n");
+ }
+
+ for (Iterator toolsIterator = awareness().getTools().values().iterator(); toolsIterator.hasNext();) {
+ writer.write("\t\ttool: ");
+ writer.write(toolsIterator.next().toString());
+ writer.write("\n");
+ }
+
+ writer.write(")");
+ return writer.toString();
+ }
+
+ public void addLogListener(LogListener listener) {
+ getLogListeners().add(listener);
+ }
+
+ public void removeLogListener(LogListener listener) {
+ getLogListeners().remove(listener);
+ }
+
+ public Set getLogListeners() {
+ return logListeners;
+ }
+
+ public void setLogListeners(Set logListeners) {
+ this.logListeners = logListeners;
+ }
+
+ public static ConcurrentMap getInstances() {
+ return instances;
+ }
+
+ public Logger getLog() {
+ return log;
+ }
+
+ public void setLog(Logger log) {
+ this.log = log;
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/BotException.java b/ai-engine/source/org/botlibre/BotException.java
new file mode 100644
index 00000000..094f3a12
--- /dev/null
+++ b/ai-engine/source/org/botlibre/BotException.java
@@ -0,0 +1,50 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre;
+
+/**
+ * Root to most exceptions thrown from the Bot system.
+ * Provides nested exception and extra debug info.
+ */
+
+public class BotException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public BotException() {
+ super();
+ }
+
+ public BotException(String message) {
+ super(message);
+ }
+
+ public BotException(Exception exception) {
+ super(exception.getMessage(), exception);
+ }
+
+ public BotException(String message, Exception exception) {
+ super(message, exception);
+ }
+
+ public static BotException offensive() {
+ BotException exception = new BotException("Profanity, offensive or sexual language is not permitted.");
+ throw exception;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/InitializationException.java b/ai-engine/source/org/botlibre/InitializationException.java
new file mode 100644
index 00000000..1ec44b4e
--- /dev/null
+++ b/ai-engine/source/org/botlibre/InitializationException.java
@@ -0,0 +1,41 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre;
+
+/**
+ * Thrown when an exception occurs during startup.
+ */
+
+public class InitializationException extends BotException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InitializationException() {
+ super();
+ }
+
+ public InitializationException(String message) {
+ super(message);
+ }
+
+ public InitializationException(Exception exception) {
+ super(exception);
+ }
+}
+
+
diff --git a/ai-engine/source/org/botlibre/LogListener.java b/ai-engine/source/org/botlibre/LogListener.java
new file mode 100644
index 00000000..bf15b282
--- /dev/null
+++ b/ai-engine/source/org/botlibre/LogListener.java
@@ -0,0 +1,43 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre;
+
+import java.util.logging.Level;
+
+/**
+ * Allows the logging event to be handled to output logging to a UI.
+ */
+
+public interface LogListener {
+
+ /**
+ * Log the message if the debug level is greater or equal to the level.
+ */
+ void log(Object source, String message, Level level, Object[] arguments);
+
+ /**
+ * Log the exception.
+ */
+ void log(Throwable error);
+
+ /**
+ * Notify a logging level change.
+ */
+ void logLevelChange(Level level);
+}
+
diff --git a/ai-engine/source/org/botlibre/aiml/AIMLParser.java b/ai-engine/source/org/botlibre/aiml/AIMLParser.java
new file mode 100644
index 00000000..17600289
--- /dev/null
+++ b/ai-engine/source/org/botlibre/aiml/AIMLParser.java
@@ -0,0 +1,1249 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.aiml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.botlibre.BotException;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.self.SelfCompiler;
+import org.botlibre.self.SelfParseException;
+import org.botlibre.thought.language.Language;
+import org.botlibre.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+
+/**
+ * Utility class for printing the Self programming model.
+ * Self is the language that Bot programs herself in.
+ */
+public class AIMLParser {
+ public static int MAX_FILE_SIZE = 10000000; // 10meg
+ public static int PAGE = 100;
+ public static int MAX_IDENTIFIER = 100;
+
+ public static Set htmlTags = new HashSet(Arrays.asList(new String[] {"p", "ul", "ol", "li", "b", "em", "i", "strong", "code", "br", "a", "img", "video", "audio"}));
+
+ public static List topicChildren = Arrays.asList(new String[] {"category", "#text"});
+ public static List categoryChildren = Arrays.asList(new String[] {"pattern", "that", "template", "topic", "#text"});
+ public static List patternChildren =
+ Arrays.asList(new String[] {"#text","bot", "name", "get", "set"});
+ public static List templateChildren =
+ Arrays.asList(new String[] {
+ "br", "a", "p", "ul", "li", "b", "em", "i", "strong", "code", "img", "#text",
+ "bot", "name", "get", "set", "value", "index", "map", "new",
+ "think", "srai", "sraix", "sr", "random", "condition", "loop", "set",
+ "star", "input", "that", "thatstar", "topicstar", "request", "response",
+ "date", "interval", "size", "version", "id", "vocabulary", "program",
+ "person", "person2", "gender", "uppercase", "lowercase", "formal", "sentence",
+ "learn", "eval",
+ "explode", "normalize", "denormalize"});
+ public static Set attributeNodes =
+ new HashSet(Arrays.asList(new String[] {
+ "name", "index", "value", "var", "botname", "botid", "server", "service", "limit", "apikey", "default", "hint"}));
+ protected static AIMLParser parser = new AIMLParser();
+
+ public static AIMLParser parser() {
+ return parser;
+ }
+
+ /**
+ * Get the contents of the URL to a .aiml file and parse it.
+ */
+ public Vertex parseAIML(URL url, boolean parseAsStateMachine, boolean createStates, boolean pin, boolean indexStatic,
+ Vertex stateMachine, String encoding, Network network) {
+ try {
+ String text = Utils.loadTextFile(Utils.openStream(url), encoding, MAX_FILE_SIZE);
+ return parseAIML(text, parseAsStateMachine, createStates, pin, indexStatic, stateMachine, network);
+ } catch (IOException exception) {
+ throw new SelfParseException("Parsing error occurred", exception);
+ }
+ }
+
+ /**
+ * Get the contents of the URL to a .aiml file and parse it.
+ */
+ public Vertex parseAIML(File file, boolean parseAsStateMachine, boolean createStates, boolean pin, boolean indexStatic,
+ Vertex stateMachine, String encoding, Network network) {
+ try {
+ String text = Utils.loadTextFile(new FileInputStream(file), encoding, MAX_FILE_SIZE);
+ return parseAIML(text, parseAsStateMachine, createStates, pin, indexStatic, stateMachine, network);
+ } catch (IOException exception) {
+ throw new SelfParseException("Parsing error occurred", exception);
+ }
+ }
+
+ /**
+ * Parse the template into a forumla defined in the network.
+ */
+ public Vertex parseAIMLTemplate(String code, Network network) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ StringReader reader = new StringReader(code);
+ InputSource source = new InputSource(reader);
+ Document document = parser.parse(source);
+ Element root = document.getDocumentElement();
+
+ String template = getTemplate(root, false, false, new boolean[1], false, false, false, network);
+ Vertex formula = network.createFormula(template);
+ return formula;
+ } catch (Exception exception) {
+ network.getBot().log(this, exception);
+ return null;
+ }
+ }
+
+ /**
+ * Parse the code into a vertex state machine defined in the network.
+ */
+ public Vertex parseAIML(String code, boolean parseAsStateMachine, boolean createStates, boolean pin, boolean indexStatic, Vertex stateMachine, Network network) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ StringReader reader = new StringReader(code);
+ InputSource source = new InputSource(reader);
+ Document document = parser.parse(source);
+ Element root = document.getDocumentElement();
+ Map cache = new HashMap();
+
+ Vertex sentenceState = null;
+ if (parseAsStateMachine) {
+ if (createStates) {
+ // Get first case that gets sentence from input.
+ List instructions = stateMachine.orderedRelations(Primitive.DO);
+ if (instructions != null) {
+ for (Vertex instruction : instructions) {
+ if (instruction.instanceOf(Primitive.CASE)) {
+ Vertex variable = instruction.getRelationship(Primitive.CASE);
+ if ((variable != null) && variable.isVariable() && variable.hasRelationship(Primitive.INPUT)) {
+ sentenceState = instruction.getRelationship(Primitive.GOTO);
+ break;
+ }
+ }
+ }
+ }
+ if (sentenceState == null) {
+ Vertex sentenceCase = network.createInstance(Primitive.CASE);
+ sentenceCase.setName("c_sentence");
+ Vertex inputVariable = network.createVertex(Primitive.INPUT_VARIABLE);
+ sentenceCase.addRelationship(Primitive.CASE, inputVariable);
+ sentenceState = network.createInstance(Primitive.STATE);
+ sentenceState.setName("s_sentence");
+ sentenceCase.addRelationship(Primitive.GOTO, sentenceState);
+ sentenceCase.addRelationship(Primitive.FOR, network.createVertex(Primitive.WORD));
+ sentenceCase.addRelationship(Primitive.FOR, inputVariable.getRelationship(Primitive.INPUT));
+ stateMachine.addRelationship(Primitive.DO, sentenceCase);
+ }
+ } else {
+ sentenceState = stateMachine;
+ }
+ }
+ List topics = getLocalElementsByTagName("topic", root);
+ int count = 0;
+ for (Element topic : topics) {
+ String text = getNodeValue(topic, "name", "", false, false, false, new boolean[1], network);
+ Vertex topicFilter = null;
+ if (!isPattern(text)) {
+ topicFilter = network.createSentence(text);
+ } else {
+ topicFilter = network.createPattern(text);
+ }
+ network.getBot().log(this, "Topic", Level.INFO, topicFilter);
+ checkSupportedChildren(topic, topicChildren, network);
+ List categories = getLocalElementsByTagName("category", topic);
+ for (Element category : categories) {
+ parseCategory(category, topicFilter, parseAsStateMachine, createStates, pin, indexStatic, sentenceState, cache, network);
+ count++;
+ if (count >= PAGE) {
+ network.save();
+ network.clear();
+ count = 0;
+ if (parseAsStateMachine) {
+ stateMachine = network.createVertex(stateMachine);
+ sentenceState = network.createVertex(sentenceState);
+ }
+ }
+ }
+ }
+ List categories = getLocalElementsByTagName("category", root);
+ for (Element category : categories) {
+ parseCategory(category, null, parseAsStateMachine, createStates, pin, indexStatic, sentenceState, cache, network);
+ count++;
+ if (count >= PAGE) {
+ network.save();
+ network.clear();
+ count = 0;
+ if (parseAsStateMachine) {
+ stateMachine = network.createVertex(stateMachine);
+ sentenceState = network.createVertex(sentenceState);
+ }
+ }
+ }
+ network.save();
+ network.getBot().log(this, "Compiled new AIML script", Level.INFO);
+ return stateMachine;
+ } catch (Exception exception) {
+ network.getBot().log(this, exception);
+ throw new BotException("Parsing error occurred - " + exception.toString(), exception);
+ }
+ }
+
+ public void checkSupportedChildren(Element element, List tags, Network network) {
+ NodeList list = element.getChildNodes();
+ for (int index2 = 0; index2 < list.getLength(); index2++) {
+ Node child = list.item(index2);
+ String name = child.getNodeName().toLowerCase();
+ if ((child.getNodeType() != Node.TEXT_NODE)
+ && (child.getNodeType() != Node.COMMENT_NODE) && !tags.contains(name)) {
+ network.getBot().log(this, "Unsupported " + element.getNodeName() + " child", Level.WARNING, name, child.getTextContent());
+ }
+ }
+ }
+
+ public boolean isPattern(String text) {
+ return (text.indexOf('*') != -1 || text.indexOf('_') != -1 || text.indexOf('^') != -1 || text.indexOf('#') != -1 || text.indexOf('$') != -1
+ || text.indexOf('{') != -1 || text.indexOf('}') != -1 || text.indexOf('[') != -1 || text.indexOf(']') != -1);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void parseCategory(Element category, Vertex topic, boolean parseAsStateMachine, boolean createStates, boolean pin, boolean indexStatic,
+ Vertex sentenceState, Map cache, Network network) {
+ checkSupportedChildren(category, categoryChildren, network);
+ //
+ List patterns = getLocalElementsByTagName("pattern", category);
+ if (patterns.isEmpty()) {
+ network.getBot().log(this, "Missing pattern", Level.WARNING);
+ return;
+ }
+
+ Element pattern = patterns.get(0);
+ String text = getPattern(pattern, network).toLowerCase();
+ Vertex question = null;
+ boolean isPattern = false;
+ boolean isStarStartPattern = false;
+ boolean isStarEndPattern = false;
+ boolean is_Pattern = false;
+ boolean multiStar = false;
+ boolean isDefault = false;
+ int underscoreIndex = text.indexOf('_');
+ int poundIndex = text.indexOf('#');
+ int starIndex = text.indexOf('*');
+ int hatIndex = text.indexOf('^');
+ boolean isDollarPattern = text.indexOf('$') != -1;
+ if (!isPattern(text)) {
+ question = network.createSentence(text);
+ pin = pin || (parseAsStateMachine && indexStatic);
+ if (pin) {
+ question.setPinned(true);
+ }
+ } else {
+ if (text.trim().length() == 1) {
+ isDefault = true;
+ }
+ question = network.createPattern(text);
+ if (pin) {
+ question.setPinned(true);
+ }
+ isPattern = true;
+ if (underscoreIndex != -1) {
+ is_Pattern = true;
+ if ((text.indexOf('_', underscoreIndex + 1) != -1) || starIndex != -1 || poundIndex != -1 || hatIndex != -1) {
+ multiStar = true;
+ }
+ } else if (starIndex != -1) {
+ if ((text.indexOf('*', starIndex + 1) != -1) || underscoreIndex != -1 || poundIndex != -1 || hatIndex != -1) {
+ multiStar = true;
+ }
+ } else if (poundIndex != -1) {
+ if ((text.indexOf('#', poundIndex + 1) != -1) || underscoreIndex != -1 || starIndex != -1 || hatIndex != -1) {
+ multiStar = true;
+ }
+ } else if (hatIndex != -1) {
+ if ((text.indexOf('^', hatIndex + 1) != -1) || underscoreIndex != -1 || starIndex != -1 || poundIndex != -1) {
+ multiStar = true;
+ }
+ }
+ if (text.startsWith("*")) {
+ isStarStartPattern = true;
+ }
+ if (text.endsWith("*") && (text.indexOf('*') < (text.length() - 1))) {
+ isStarEndPattern = false;
+ }
+ }
+ network.getBot().log(this, "Pattern", Level.INFO, question);
+ checkSupportedChildren(pattern, patternChildren, network);
+ Vertex that = null;
+ //
+ List topics = getLocalElementsByTagName("topic", category);
+ if (!topics.isEmpty()) {
+ for (Element child : topics) {
+ text = getPattern(child, network).toLowerCase();
+ if (isPattern(text)) {
+ topic = network.createPattern(text);
+ } else {
+ topic = network.createSentence(Utils.reduce(text), false, true);
+ }
+ if (pin) {
+ topic.setPinned(true);
+ }
+ network.getBot().log(this, "Topic", Level.INFO, topic);
+ checkSupportedChildren(child, Collections.EMPTY_LIST, network);
+ }
+ }
+ //
+ List thats = getLocalElementsByTagName("that", category);
+ if (!thats.isEmpty()) {
+ for (Element child : thats) {
+ text = getPattern(child, network).toLowerCase();
+ if (isPattern(text)) {
+ that = network.createPattern(text);
+ } else {
+ that = network.createSentence(Utils.reduce(text), false, true);
+ }
+ if (pin) {
+ that.setPinned(true);
+ }
+ network.getBot().log(this, "That", Level.INFO, that);
+ checkSupportedChildren(child, Collections.EMPTY_LIST, network);
+ }
+ } else {
+ that = null;
+ }
+ //
+ List templates = getLocalElementsByTagName("template", category);
+ if (templates.isEmpty()) {
+ network.getBot().log(this, "Missing template", Level.WARNING);
+ return;
+ }
+ Element template = templates.get(0);
+ checkSupportedChildren(template, templateChildren, network);
+ Vertex equation = null;
+ if (parseAsStateMachine && (isPattern || !indexStatic)) {
+ equation = network.createInstance(Primitive.CASE);
+ equation.addRelationship(Primitive.PATTERN, question);
+ if (that != null) {
+ equation.addRelationship(Primitive.THAT, that);
+ }
+ }
+ boolean[] srai = new boolean[1];
+ String templateText = getTemplate(template, false, multiStar, srai, false, false, false, network);
+ boolean isFormula = templateText.startsWith("Formula:");
+ Vertex response = null;
+ if (isFormula) {
+ response = cache.get(templateText);
+ if (response == null) {
+ response = network.createFormula(templateText);
+ if (pin) {
+ SelfCompiler.getCompiler().pin(response);
+ }
+ cache.put(templateText, response);
+ }
+ } else {
+ response = network.createVertex(templateText);
+ if (pin) {
+ response.setPinned(true);
+ }
+ response.addRelationship(Primitive.INSTANTIATION, Primitive.SENTENCE);
+ }
+ network.getBot().log(this, "Template", Level.INFO, response);
+ if (parseAsStateMachine && (isPattern || !indexStatic)) {
+ equation.addRelationship(Primitive.TEMPLATE, response);
+ if (topic != null) {
+ equation.addRelationship(Primitive.TOPIC, topic);
+ }
+ } else {
+ Relationship relationship = null;
+ // Add * to default responses.
+ if (isDefault && !createStates) {
+ Vertex language = network.createVertex(Language.class);
+ relationship = language.addRelationship(Primitive.RESPONSE, response);
+ } else {
+ relationship = question.addRelationship(Primitive.RESPONSE, response);
+ question.associateAll(Primitive.WORD, question, Primitive.QUESTION);
+ }
+ response.addRelationship(Primitive.QUESTION, question);
+ if (topic != null) {
+ Vertex meta = network.createMeta(relationship);
+ meta.addRelationship(Primitive.TOPIC, topic);
+ meta.addRelationship(Primitive.REQUIRE, Primitive.TOPIC);
+ }
+ if (that != null) {
+ Vertex meta = network.createMeta(relationship);
+ meta.addRelationship(Primitive.PREVIOUS, that);
+ meta.addRelationship(Primitive.REQUIRE, Primitive.PREVIOUS);
+ }
+ }
+ if (parseAsStateMachine && (isPattern || !indexStatic)) {
+ Vertex state = sentenceState;
+ if (createStates) {
+ state = createState(question, sentenceState, network);
+ }
+ if (isPattern) {
+ if (that != null || topic != null) {
+ state.addRelationship(Primitive.DO, equation, 1);
+ } else {
+ if (isDollarPattern) {
+ state.addRelationship(Primitive.DO, equation, 2);
+ } else if (is_Pattern) {
+ state.addRelationship(Primitive.DO, equation, 3);
+ } else if (isStarStartPattern) {
+ state.addRelationship(Primitive.DO, equation, 8);
+ } else if (isStarEndPattern) {
+ state.addRelationship(Primitive.DO, equation, 7);
+ } else {
+ state.addRelationship(Primitive.DO, equation, 6);
+ }
+ }
+ } else {
+ if (that != null || topic != null) {
+ state.addRelationship(Primitive.DO, equation, 0);
+ } else if (srai[0]) {
+ state.addRelationship(Primitive.DO, equation, 5);
+ } else {
+ state.addRelationship(Primitive.DO, equation, 4);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a left child state node for the pattern.
+ */
+ public Vertex createState(Vertex pattern, Vertex parent, Network network) {
+ Vertex currentState = parent;
+ Collection words = pattern.orderedRelationships(Primitive.WORD);
+ if (words != null) {
+ StringWriter pathWriter = new StringWriter();
+ //int index = 0;
+ for (Relationship word : words) {
+ /*index++;
+ // Need to only go to previous state.
+ if (index >= words.size()) {
+ return currentState;
+ }*/
+ Vertex value = word.getTarget();
+ if (value.is(Primitive.WILDCARD)) {
+ pathWriter.write("_star");
+ } else if (value.is(Primitive.UNDERSCORE)) {
+ value = network.createVertex(Primitive.UNDERSCORE);
+ pathWriter.write("_underscore");
+ } else if (value.is(Primitive.POUNDWILDCARD)) {
+ value = network.createVertex(Primitive.POUNDWILDCARD);
+ pathWriter.write("_pound");
+ } else if (value.is(Primitive.HATWILDCARD)) {
+ value = network.createVertex(Primitive.HATWILDCARD);
+ pathWriter.write("_hat");
+ } else {
+ pathWriter.write("_");
+ pathWriter.write(value.printString());
+ }
+ List instructions = currentState.orderedRelations(Primitive.DO);
+ Vertex caseMatch = null;
+ if (instructions != null) {
+ // Find the case that matches.
+ for (Vertex instruction : instructions) {
+ if (instruction.instanceOf(Primitive.CASE)) {
+ Vertex caseValue = instruction.getRelationship(Primitive.CASE);
+ if (caseValue == value) {
+ caseMatch = instruction;
+ break;
+ }
+ }
+ }
+ }
+ if (caseMatch == null) {
+ caseMatch = network.createInstance(Primitive.CASE);
+ caseMatch.setName("c" + caseMatch.getId() + "_" + value.printString());
+ caseMatch.addRelationship(Primitive.CASE, value);
+ Vertex newState = network.createInstance(Primitive.STATE);
+ newState.setName("s" + newState.getId() + Utils.compress(pathWriter.toString(), MAX_IDENTIFIER));
+ caseMatch.addRelationship(Primitive.GOTO, newState);
+ if (word.getTarget().is(Primitive.UNDERSCORE) || word.getTarget().is(Primitive.POUNDWILDCARD)) {
+ currentState.addRelationship(Primitive.DO, caseMatch, 3);
+ newState.addRelationship(Primitive.DO, caseMatch, 10);
+ } else if (word.getTarget().is(Primitive.WILDCARD) || word.getTarget().is(Primitive.HATWILDCARD)) {
+ currentState.addRelationship(Primitive.DO, caseMatch, 5);
+ newState.addRelationship(Primitive.DO, caseMatch, 10);
+ } else {
+ if (word.hasMeta() && word.getMeta().hasRelationship(Primitive.TYPE, Primitive.PRECEDENCE)) {
+ currentState.addRelationship(Primitive.DO, caseMatch, 2);
+ } else {
+ currentState.addRelationship(Primitive.DO, caseMatch, 4);
+ }
+ }
+ currentState = newState;
+ } else {
+ Vertex state = caseMatch.getRelationship(Primitive.GOTO);
+ if (state == null) {
+ state = network.createInstance(Primitive.STATE);
+ state.setName("s" + state.getId() + Utils.compress(pathWriter.toString(), MAX_IDENTIFIER));
+ caseMatch.addRelationship(Primitive.GOTO, state);
+ }
+ currentState = state;
+ }
+ }
+ }
+ return currentState;
+ }
+
+ public List getLocalElementsByTagName(String tag, Element element) {
+ NodeList children = element.getChildNodes();
+ List local = new ArrayList();
+ for (int index = 0; index < children.getLength(); index++) {
+ Node child = children.item(index);
+ if (child.getNodeName().equals(tag)) {
+ local.add((Element)child);
+ }
+ }
+ return local;
+ }
+
+ public String getPattern(Element element, Network network) {
+ StringWriter writer = new StringWriter();
+ NodeList list = element.getChildNodes();
+ for (int index = 0; index < list.getLength(); index++) {
+ Node child = list.item(index);
+ String name = child.getNodeName().toLowerCase();
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ writer.write(child.getNodeValue());
+ } else if (name.equals("name") || name.equals("index") || name.equals("value") || name.equals("var")) {
+ continue;
+ } else if (child instanceof Element) {
+ writer.write("{");
+ appendPatternCode((Element)child, false, new boolean[1], writer, network);
+ writer.write("}");
+ }
+ }
+ return writer.toString();
+ }
+
+ public void appendNestedString(Element child, boolean multiStar, boolean[] srai, StringWriter writer, Network network) {
+ String nested = getTemplate((Element)child, true, multiStar, srai, true, true, false, network);
+ writer.write(nested);
+ }
+
+ public boolean appendNestedText(Element child, boolean multiStar, boolean[] srai, StringWriter writer, Network network) {
+ String nested = getTemplate((Element)child, true, multiStar, srai, false, false, false, network);
+ boolean isNestedFormula = nested.startsWith("Formula:");
+ if (isNestedFormula) {
+ nested = nested.substring("Formula:\"".length(), nested.length() - 1);
+ }
+ writer.write(nested);
+ return isNestedFormula;
+ }
+
+ public boolean appendHTML(String tag, Element child, boolean multiStar, boolean[] srai, boolean isFormula, StringWriter writer, Network network) {
+ writer.write("<");
+ writer.write(tag);
+ NamedNodeMap attributes = child.getAttributes();
+ for (int index = 0; index < attributes.getLength(); index++) {
+ Node attribute = attributes.item(index);
+ writer.write(" ");
+ writer.write(attribute.getNodeName());
+ writer.write("=\"\"");
+ writer.write(attribute.getNodeValue());
+ writer.write("\"\"");
+ }
+ if (!child.hasChildNodes()) {
+ writer.write("/>");
+ } else {
+ writer.write(">");
+ if (appendNestedText((Element)child, multiStar, srai, writer, network)) {
+ isFormula = true;
+ }
+ writer.write("");
+ writer.write(tag);
+ writer.write(">");
+ }
+ return isFormula;
+ }
+
+ public String getTemplate(Element element, boolean quote, boolean multiStar, boolean[] srai, boolean flattenFormulas, boolean addQuotes, boolean pattern, Network network) {
+ boolean isFormula = false;
+ boolean nameNode = false;
+ StringWriter writer = new StringWriter();
+ NodeList list = element.getChildNodes();
+ for (int index = 0; index < list.getLength(); index++) {
+ Node child = list.item(index);
+ String name = child.getNodeName().toLowerCase();
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ // TODO PERF
+ String text = child.getNodeValue();
+ if (text.contains("<")) {
+ text = text.replace("<", "<");
+ }
+ if (text.contains(">")) {
+ text = text.replace(">", ">");
+ }
+ if (text.contains("\t")) {
+ text = text.replace("\t", " ");
+ }
+ if (text.contains("\r")) {
+ text = text.replace("\r", " ");
+ }
+ if (text.contains("\n")) {
+ text = text.replace("\n", " ");
+ }
+ if (text.contains(" ")) {
+ text = text.replace(" ", " ");
+ }
+ if (text.contains(" ")) {
+ text = text.replace(" ", " ");
+ }
+ if (text.contains("{")) {
+ text = text.replace("{", "(");
+ }
+ if (text.contains("}")) {
+ text = text.replace("}", ")");
+ }
+ if (text.contains("\"")) {
+ text = text.replace("\"", "\"\"");
+ }
+ writer.write(text);
+ } else if (attributeNodes.contains(name)) {
+ nameNode = true;
+ continue;
+ } else if (htmlTags.contains(name)) {
+ isFormula = appendHTML(name, (Element)child, multiStar, srai, isFormula, writer, network);
+ } else if (child instanceof Element) {
+ if (flattenFormulas && list.getLength() == 1 || (nameNode && list.getLength() == 2)) {
+ writer.write("(");
+ appendCode((Element)child, multiStar, srai, writer, network);
+ writer.write(")");
+ return writer.toString().trim();
+ }
+ writer.write("{");
+ appendCode((Element)child, multiStar, srai, writer, network);
+ writer.write("}");
+ isFormula = true;
+ }
+ }
+ String text = writer.toString().trim();
+ if (isFormula && !pattern) {
+ text = "Formula:\"" + text + "\"";
+ } else {
+ if (!quote && text.contains("\"")) {
+ text = text.replace("\"\"", "\"");
+ }
+ if (flattenFormulas) {
+ text = "\"" + text + "\"";
+ }
+ }
+ return text;
+ }
+
+ public String getNodeValue(Element node, String value, String defaulValue, boolean primitive, boolean quote, boolean multiStar, boolean[] srai, Network network) {
+ List valueElements = getLocalElementsByTagName(value, node);
+ if (valueElements != null && valueElements.size() > 0) {
+ StringWriter writer = new StringWriter();
+ if (primitive) {
+ writer.write("primitive ");
+ }
+ appendNestedString((Element)valueElements.get(0), multiStar, srai, writer, network);
+ return writer.toString();
+ }
+ Node child = node.getAttributes().getNamedItem(value);
+ if (child == null) {
+ for (int index = 0; index < node.getAttributes().getLength(); index++) {
+ Node attribute = node.getAttributes().item(index);
+ if (attribute.getNodeName().equalsIgnoreCase(value)) {
+ if (primitive) {
+ return "#" + attribute.getNodeValue();
+ } else if (quote) {
+ return "\"" + attribute.getNodeValue() + "\"";
+ } else {
+ return attribute.getNodeValue();
+ }
+ }
+ }
+ return defaulValue;
+ }
+ if (primitive) {
+ return "#" + child.getNodeValue();
+ } else if (quote) {
+ return "\"" + child.getNodeValue() + "\"";
+ } else {
+ return child.getNodeValue();
+ }
+ }
+
+ public void appendCode(Element child, boolean multiStar, boolean[] srai, StringWriter writer, Network network) {
+ String name = child.getNodeName().toLowerCase();
+ if (name.equals("bot")) {
+ writer.write("get ");
+ writer.write(getNodeValue(child, "name", "#name", true, false, multiStar, srai, network));
+ writer.write(" from :target");
+ } else if (name.equals("get")) {
+ writer.write("get ");
+ String value = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ boolean isLocal = false;
+ if (value == null) {
+ value = getNodeValue(child, "var", null, true, false, multiStar, srai, network);
+ if (value != null) {
+ isLocal = true;
+ } else {
+ value = "#name";
+ }
+ }
+ writer.write(value);
+ if (isLocal) {
+ writer.write(" from :input");
+ } else if (value.equalsIgnoreCase("#name")) {
+ writer.write(" from :speaker");
+ } else {
+ writer.write(" from :conversation");
+ }
+ } else if (name.equals("set")) {
+ writer.write("set ");
+ String value = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ boolean isLocal = false;
+ if (value == null) {
+ value = getNodeValue(child, "var", null, true, false, multiStar, srai, network);
+ if (value != null) {
+ isLocal = true;
+ } else {
+ value = "#name";
+ }
+ }
+ writer.write(value);
+ writer.write(" to ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ if (isLocal) {
+ writer.write(" on :input");
+ } else if (value.equalsIgnoreCase("#name")) {
+ writer.write(" on :speaker");
+ } else {
+ writer.write(" on :conversation");
+ }
+ } else if (name.equals("map")) {
+ // EXT - value lets the value be set for a map.
+ String value = getNodeValue(child, "value", null, true, false, multiStar, srai, network);
+ if (value == null) {
+ writer.write("get ");
+ String type = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ if (type == null) {
+ type = "#meaning";
+ }
+ writer.write(type);
+ writer.write(" from ");
+ } else {
+ writer.write("set ");
+ String type = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ if (type == null) {
+ type = "#meaning";
+ }
+ writer.write(type);
+ writer.write(" to ");
+ writer.write(value);
+ writer.write(" on ");
+ }
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ } else if (name.equals("new")) {
+ writer.write("new ");
+ String type = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ if (type == null) {
+ type = "#thing";
+ }
+ writer.write(type);
+ } else if (name.equals("think")) {
+ writer.write("think (");
+ appendThink((Element)child, writer, multiStar, srai, network);
+ writer.write(")");
+ } else if (name.equals("eval")) {
+ writer.write("eval (");
+ appendThink((Element)child, writer, multiStar, srai, network);
+ writer.write(")");
+ } else if (name.equals("learn")) {
+ writer.write("learn ");
+ List elements = getLocalElementsByTagName("category", (Element)child);
+ if (elements != null && elements.size() > 0) {
+ Element category = elements.get(0);
+ elements = getLocalElementsByTagName("pattern", category);
+ if (elements != null && elements.size() > 0) {
+ Element pattern = elements.get(0);
+ String text = getTemplate(pattern, false, multiStar, srai, false, false, true, network).toLowerCase();
+ Vertex vertex = null;
+ if (isPattern(text)) {
+ vertex = network.createPattern(text);
+ writer.write(vertex.printString());
+ } else {
+ writer.write("\"");
+ writer.write(text.replace("\"", "\"\""));
+ writer.write("\"");
+ }
+ }
+ elements = getLocalElementsByTagName("that", category);
+ if (elements != null && elements.size() > 0) {
+ Element that = elements.get(0);
+ String text = getPattern(that, network).toLowerCase();
+ writer.write(" that ");
+ Vertex vertex = null;
+ if (isPattern(text)) {
+ vertex = network.createPattern(text);
+ writer.write(vertex.printString());
+ } else {
+ writer.write("\"");
+ writer.write(text.replace("\"", "\"\""));
+ writer.write("\"");
+ }
+ }
+ elements = getLocalElementsByTagName("topic", category);
+ if (elements != null && elements.size() > 0) {
+ Element topic = elements.get(0);
+ String text = getPattern(topic, network).toLowerCase();
+ writer.write(" topic ");
+ Vertex vertex = null;
+ if (isPattern(text)) {
+ vertex = network.createPattern(text);
+ writer.write(vertex.printString());
+ } else {
+ writer.write("\"");
+ writer.write(text.replace("\"", "\"\""));
+ writer.write("\"");
+ }
+ }
+ elements = getLocalElementsByTagName("template", category);
+ if (elements != null && elements.size() > 0) {
+ Element template = elements.get(0);
+ writer.write(" template ");
+ String text = getTemplate(template, false, multiStar, srai, false, false, false, network);
+ if (text.startsWith("Formula:")) {
+ writer.write(text);
+ } else {
+ writer.write("\"");
+ writer.write(text);
+ writer.write("\"");
+ }
+ }
+ }
+ } else if (name.equals("srai")) {
+ writer.write("srai ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ srai[0] = true;
+ } else if (name.equals("sraix")) {
+ writer.write("sraix ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ String value = getNodeValue(child, "bot", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" bot ");
+ writer.write(value);
+ } else {
+ // Allow name element, as bot element is already a command.
+ String botname = getNodeValue(child, "botname", null, false, true, multiStar, srai, network);
+ if (botname != null) {
+ writer.write(" bot ");
+ writer.write(botname);
+ }
+ }
+ value = getNodeValue(child, "botid", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" botid ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "service", null, true, false, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" service ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "server", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" server ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "apikey", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" apikey ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "limit", null, false, false, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" limit ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "hint", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" hint ");
+ writer.write(value);
+ }
+ value = getNodeValue(child, "default", null, false, true, multiStar, srai, network);
+ if (value != null) {
+ writer.write(" default ");
+ writer.write(value);
+ }
+ } else if (name.equals("sr")) {
+ writer.write("srai ");
+ if (multiStar) {
+ writer.write("(get #word from :star at 1)");
+ } else {
+ writer.write(":star");
+ }
+ srai[0] = true;
+ } else if (name.equals("id")) {
+ writer.write("get #name from :speaker");
+ } else if (name.equals("size")) {
+ writer.write("call #size on #Utils");
+ } else if (name.equals("vocabulary")) {
+ writer.write("call #size on #Utils");
+ } else if (name.equals("program")) {
+ writer.write("call #program on #Utils");
+ //} else if (name.equals("system")) { -- os execution definitely not allowed
+ } else if (name.equals("version")) {
+ writer.write("call #version on #Utils");
+ } else if (name.equals("uppercase")) {
+ writer.write("uppercase ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ } else if (name.equals("lowercase")) {
+ writer.write("lowercase ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ } else if (name.equals("formal")) {
+ writer.write("format ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ writer.write(" as #formal");
+ } else if (name.equals("sentence")) {
+ writer.write("format ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ writer.write(" as #sentence");
+ } else if (name.equals("explode")) {
+ writer.write("format ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ writer.write(" as #explode");
+ } else if (name.equals("normalize")) {
+ writer.write("format ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ writer.write(" as #normalize");
+ } else if (name.equals("denormalize")) {
+ writer.write("format ");
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ writer.write(" as #denormalize");
+ } else if (name.equals("gender")) {
+ writer.write("format ");
+ if (child.getChildNodes().getLength() == 0) {
+ if (multiStar) {
+ writer.write("(get #word from :star at 1)");
+ } else {
+ writer.write(":star");
+ }
+ } else {
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ }
+ writer.write(" as #gender");
+ } else if (name.equals("person")) {
+ writer.write("format ");
+ if (child.getChildNodes().getLength() == 0) {
+ if (multiStar) {
+ writer.write("(get #word from :star at 1)");
+ } else {
+ writer.write(":star");
+ }
+ } else {
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ }
+ writer.write(" as #person");
+ } else if (name.equals("person2")) {
+ writer.write("format ");
+ if (child.getChildNodes().getLength() == 0) {
+ if (multiStar) {
+ writer.write("(get #word from :star at 1)");
+ } else {
+ writer.write(":star");
+ }
+ } else {
+ appendNestedString((Element)child, multiStar, srai, writer, network);
+ }
+ writer.write(" as #person2");
+ } else if (name.equals("random")) {
+ writer.write("random (");
+ List children = getLocalElementsByTagName("li", (Element)child);
+ for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
+ Element random = iterator.next();
+ appendNestedString(random, multiStar, srai, writer, network);
+ if (iterator.hasNext()) {
+ writer.write(", ");
+ }
+ }
+ writer.write(")");
+ } else if (name.equals("loop")) {
+ writer.write("think (assign :loop to #true)");
+ } else if (name.equals("condition")) {
+ NodeList loop = child.getElementsByTagName("loop");
+ if (loop != null && loop.getLength() > 0) {
+ writer.write("do (assign :result to \"\", assign :loop to #true, while (:loop) do (assign :loop to #false, ");
+ writer.write("assign :result to Formula:\"{:result}{");
+ }
+ String conditionName = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ boolean isLocal = false;
+ if (conditionName == null) {
+ conditionName = getNodeValue(child, "var", null, true, false, multiStar, srai, network);
+ if (conditionName != null) {
+ isLocal = true;
+ } else {
+ conditionName = ":star";
+ }
+ }
+ String conditionValue = getNodeValue(child, "value", null, false, true, multiStar, srai, network);
+ if (conditionName != null && conditionValue != null) {
+ writer.write("if (get ");
+ writer.write(conditionName);
+ if (isLocal) {
+ writer.write(" from :input, ");
+ } else if (conditionName.equalsIgnoreCase("#name")) {
+ writer.write(" from :speaker, ");
+ } else {
+ writer.write(" from :conversation, ");
+ }
+ if (conditionValue.indexOf('*') != -1 || conditionValue.indexOf('_') != -1) {
+ writer.write("Pattern:");
+ writer.write(conditionValue);
+ } else {
+ writer.write(conditionValue);
+ }
+ writer.write(") then ");
+ appendNestedString(child, multiStar, srai, writer, network);
+ writer.write(" else \"\"");
+ } else {
+ List children = getLocalElementsByTagName("li", (Element)child);
+ boolean catchAll = false;
+ for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
+ boolean liLocal = isLocal;
+ Element condition = iterator.next();
+ String liName = getNodeValue(condition, "name", null, true, false, multiStar, srai, network);
+ if (liName == null) {
+ liName = getNodeValue(condition, "var", null, true, false, multiStar, srai, network);
+ if (liName != null) {
+ liLocal = true;
+ }
+ } else {
+ liLocal = false;
+ }
+ String liValue = getNodeValue(condition, "value", null, false, true, multiStar, srai, network);
+ if (liName == null) {
+ liName = conditionName;
+ }
+ if (liValue == null) {
+ liValue = conditionValue;
+ }
+ if (liValue == null) {
+ appendNestedString(condition, multiStar, srai, writer, network);
+ catchAll = true;
+ break;
+ } else {
+ writer.write("if (get ");
+ writer.write(liName);
+ if (liLocal) {
+ writer.write(" from :input, ");
+ } else if (conditionName.equalsIgnoreCase("#name")) {
+ writer.write(" from :speaker, ");
+ } else {
+ writer.write(" from :conversation, ");
+ }
+ if (liValue.indexOf('*') != -1 || liValue.indexOf('_') != -1) {
+ writer.write("Pattern:");
+ writer.write(liValue);
+ } else {
+ writer.write(liValue);
+ }
+ writer.write(") then ");
+ appendNestedString(condition, multiStar, srai, writer, network);
+ writer.write(" else ");
+ }
+ }
+ if (!catchAll) {
+ writer.write("\"\"");
+ }
+ }
+ if (loop != null && loop.getLength() > 0) {
+ writer.write("}\"))");
+ }
+ } else if (name.equals("request") || name.equals("input")) {
+ String index = getNodeValue(child, "index", "1", false, false, multiStar, srai, network);
+ String part = null;
+ if (index != null) {
+ if (index.indexOf(',') != -1) {
+ index = index.substring(0, index.indexOf(','));
+ part = index.substring(index.indexOf(',') + 1, index.length());
+ }
+ }
+ writer.write("input ");
+ writer.write(index);
+ if (part != null) {
+ writer.write(" part ");
+ writer.write(part);
+ }
+ writer.write(" for :speaker");
+ } else if (name.equals("that") || name.equals("response")) {
+ String index = getNodeValue(child, "index", "1", false, false, multiStar, srai, network);
+ String part = null;
+ if (index != null) {
+ if (index.indexOf(',') != -1) {
+ index = index.substring(0, index.indexOf(','));
+ part = index.substring(index.indexOf(',') + 1, index.length());
+ }
+ }
+ writer.write("input ");
+ writer.write(index);
+ if (part != null) {
+ writer.write(" part ");
+ writer.write(part);
+ }
+ writer.write(" for :target");
+ } else if (name.equals("date")) {
+ String format = getNodeValue(child, "format", null, false, true, multiStar, srai, network);
+ String jformat = getNodeValue(child, "jformat", null, false, true, multiStar, srai, network);
+ if (jformat != null) {
+ writer.write("call #dateWithFormat on #Watch with " + jformat);
+ } else if (format != null) {
+ writer.write("call #date on #Watch with " + format);
+ } else {
+ writer.write("call #date on #Watch");
+ }
+ } else if (name.equals("interval")) {
+ String format = getNodeValue(child, "jformat", null, false, true, multiStar, srai, network);
+ String from = getNodeValue(child, "from", null, false, true, multiStar, srai, network);
+ String to = getNodeValue(child, "to", null, false, true, multiStar, srai, network);
+ String style = getNodeValue(child, "style", null, false, true, multiStar, srai, network);
+ if (format != null) {
+ writer.write("call #interval on #Watch with (" + style + ", " + from + ", " + to + ", " + format + ")");
+ } else {
+ writer.write("call #interval on #Watch with (" + style + ", " + from + ", " + to + ")");
+ }
+ } else if (name.equals("star")) {
+ String index = getNodeValue(child, "index", null, false, false, multiStar, srai, network);
+ if (index == null) {
+ if (multiStar) {
+ writer.write("get #word from :star at 1");
+ } else {
+ writer.write(":star");
+ }
+ } else {
+ writer.write("get #word from :star at ");
+ writer.write(index);
+ }
+ } else if (name.equals("thatstar")) {
+ String index = getNodeValue(child, "index", null, false, false, multiStar, srai, network);
+ if (index == null) {
+ writer.write(":thatstar");
+ } else {
+ writer.write("get #word from :thatstar at ");
+ writer.write(index);
+ }
+ } else if (name.equals("topicstar")) {
+ String index = getNodeValue(child, "index", null, false, false, multiStar, srai, network);
+ if (index == null) {
+ writer.write(":topicstar");
+ } else {
+ writer.write("get #word from :topicstar at ");
+ writer.write(index);
+ }
+ } else {
+ writer.write("think (#" + name + ")");
+ }
+ }
+ public void appendPatternCode(Element child, boolean multiStar, boolean[] srai, StringWriter writer, Network network) {
+ String name = child.getNodeName().toLowerCase();
+ if (name.equals("bot")) {
+ writer.write("get ");
+ writer.write(getNodeValue(child, "name", "#name", true, false, multiStar, srai, network));
+ writer.write(" from :target");
+ } else if (name.equals("get")) {
+ writer.write("get ");
+ String value = getNodeValue(child, "name", null, true, false, multiStar, srai, network);
+ boolean isLocal = false;
+ if (value == null) {
+ value = getNodeValue(child, "var", null, true, false, multiStar, srai, network);
+ if (value != null) {
+ isLocal = true;
+ } else {
+ value = "#name";
+ }
+ }
+ writer.write(value);
+ if (isLocal) {
+ writer.write(" from :input");
+ } else if (value.equalsIgnoreCase("#name")) {
+ writer.write(" from :speaker");
+ } else {
+ writer.write(" from :conversation");
+ }
+ } else if (name.equals("set")) {
+ writer.write(":^");
+ String value = child.getTextContent().trim();
+ writer.write(value);
+ }
+ }
+
+ public void appendThink(Element element, StringWriter writer, boolean multiStar, boolean[] srai, Network network) {
+ NodeList list = element.getChildNodes();
+ List elements = new ArrayList();
+ for (int index = 0; index < list.getLength(); index++) {
+ Node child = list.item(index);
+ if (child instanceof Element) {
+ elements.add((Element)child);
+ }
+ }
+ if (elements.isEmpty()) {
+ writer.write("#null");
+ }
+ if (elements.size() > 1) {
+ writer.write("do (");
+ }
+ int index = 0;
+ for (Element child : elements) {
+ appendCode((Element)child, multiStar, srai, writer, network);
+ index++;
+ if (index < elements.size()) {
+ writer.write(", ");
+ }
+ }
+ if (elements.size() > 1) {
+ writer.write(")");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
diff --git a/ai-engine/source/org/botlibre/api/avatar/Avatar.java b/ai-engine/source/org/botlibre/api/avatar/Avatar.java
new file mode 100644
index 00000000..c9d622fd
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/avatar/Avatar.java
@@ -0,0 +1,75 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.avatar;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.ImageData;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Allows visual expression of emotions and state.
+ */
+
+public interface Avatar {
+
+ void shutdown();
+
+ void awake();
+
+ void pool();
+
+ ImageData getCurrentImage();
+
+ Bot getBot();
+
+ Primitive getPrimitive();
+
+ void setBot(Bot Bot);
+
+ String getAction();
+
+ void setAction(String action);
+
+ String getPose();
+
+ void setPose(String pose);
+
+ String getEmote();
+
+ void setEmote(String emote);
+
+ /**
+ * Evaluate the output and express in the Avatar's image.
+ */
+ void evaluateOutput(Vertex output);
+
+ /**
+ * Evaluate the input response for actions and poses.
+ */
+ void evaluateResponse(Vertex output, Vertex response, Vertex meta);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/emotion/Emotion.java b/ai-engine/source/org/botlibre/api/emotion/Emotion.java
new file mode 100644
index 00000000..5d24d544
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/emotion/Emotion.java
@@ -0,0 +1,46 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.emotion;
+
+import java.util.Map;
+
+import org.botlibre.emotion.EmotionalState;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Defines a emotion.
+ * An emotion is a state defined by a magnitude that affects behavior.
+ */
+
+public interface Emotion {
+ float getState();
+
+ void setState(float state);
+
+ Primitive primitive();
+
+ String getName();
+
+ EmotionalState evaluate(float level);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+}
+
diff --git a/ai-engine/source/org/botlibre/api/emotion/Mood.java b/ai-engine/source/org/botlibre/api/emotion/Mood.java
new file mode 100644
index 00000000..6308d0de
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/emotion/Mood.java
@@ -0,0 +1,96 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.emotion;
+
+import java.util.List;
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.emotion.EmotionalState;
+
+/**
+ * Defines and manages the emotion state.
+ * Contains a set of Emotions.
+ */
+
+public interface Mood {
+
+ void shutdown();
+
+ void awake();
+
+ void pool();
+
+ Map getEmotions();
+
+ T getEmotion(Class type);
+
+ Emotion getEmotion(String name);
+
+ void addEmotion(Emotion emotion);
+
+ void removeEmotion(Emotion emotion);
+
+ Bot getBot();
+
+ void setBot(Bot Bot);
+
+ /**
+ * Evaluate the active memory input for emotional influence.
+ */
+ void evaluate();
+
+ /**
+ * Evaluate the output and express emotion.
+ */
+ void evaluateOutput(Vertex output);
+
+ /**
+ * Evaluate the input response for emotional influence.
+ */
+ void evaluateResponse(Vertex response, Vertex meta);
+
+ /**
+ * Determine the current main emotional state.
+ */
+ EmotionalState currentEmotionalState();
+
+ /**
+ * Determine the main emotional state of the output.
+ */
+ EmotionalState evaluateEmotionalState(Vertex output);
+
+ /**
+ * Determine the emotional states of the output.
+ */
+ List evaluateEmotionalStates(Vertex output);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+ boolean isEnabled();
+
+ void setEnabled(boolean isEnabled);
+
+ void saveProperties();
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Data.java b/ai-engine/source/org/botlibre/api/knowledge/Data.java
new file mode 100644
index 00000000..48bcca8d
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Data.java
@@ -0,0 +1,5 @@
+package org.botlibre.api.knowledge;
+
+public interface Data {
+ long getId();
+}
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Memory.java b/ai-engine/source/org/botlibre/api/knowledge/Memory.java
new file mode 100644
index 00000000..b5130949
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Memory.java
@@ -0,0 +1,154 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.List;
+import java.util.Map;
+
+import org.botlibre.Bot;
+
+/**
+ * Defines a set of networks that make up a knowledge base.
+ * Defines long term, short term and active networks.
+ * Handle persistence of networks and merging of network spaces from short term to long term.
+ */
+
+public interface Memory {
+
+ /**
+ * Active memory represents the last sensory state.
+ */
+ List getActiveMemory();
+
+ /**
+ * Add the sensory data to the active memory.
+ * Register the vertex in the short-term memory and return the registered version.
+ */
+ Vertex addActiveMemory(Vertex vertex);
+
+ /**
+ * Represents a non-committed transactional memory.
+ * Helps to define a learn scope and local context.
+ */
+ Network getShortTermMemory();
+
+ /**
+ * Return an isolated transactional memory.
+ * Can be used by senses or sub-conscious thought for concurrent processing.
+ */
+ Network newMemory();
+
+ /**
+ * Represents the persisted memory (or cache there of).
+ */
+ Network getLongTermMemory();
+
+ /**
+ * Merge the short term memory into the long term and clears the short term.
+ * This is similar to a transactional commit.
+ * The changes should also be persisted, as the long term should always just be a cache of the storage.
+ */
+ void save() throws MemoryStorageException;
+
+ /**
+ * Restores the memory from a persisted state.
+ */
+ void restore() throws MemoryStorageException;
+
+ /**
+ * Restores the memory from a persisted state.
+ */
+ void restore(String database) throws MemoryStorageException;
+
+ /**
+ * Restores the memory from a persisted state.
+ */
+ void fastRestore(String database) throws MemoryStorageException;
+
+ /**
+ * Return the current connected database name.
+ */
+ String getMemoryName();
+
+ /**
+ * Create a memory database.
+ */
+ void createMemory(String database);
+
+ /**
+ * Create a memory database.
+ */
+ void createMemoryFromTemplate(String database, String template);
+
+ /**
+ * Destroy the database.
+ */
+ void destroyMemory(String database);
+
+ /**
+ * Delete all content from the database.
+ */
+ void deleteMemory();
+
+ /**
+ * Allow import of another memory location.
+ */
+ void importMemory(String location);
+
+ /**
+ * Shutdown the memory.
+ */
+ void shutdown();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ /**
+ * Allow switching to another memory location.
+ */
+ void switchMemory(String location);
+
+ /**
+ * Reset the short term and active memories.
+ * Revert to the long term state.
+ */
+ void abort();
+
+ Bot getBot();
+
+ void setBot(Bot Bot);
+
+ /**
+ * Initialize any configurable settings from the properties.
+ */
+ void initialize(Map properties);
+
+ /**
+ * Add the memory listener.
+ * It will be notified of any new active memory.
+ */
+ void addListener(MemoryEventListener listener);
+
+ void removeListener(MemoryEventListener listener);
+
+ int cacheSize();
+
+ void freeMemory();
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/knowledge/MemoryEventListener.java b/ai-engine/source/org/botlibre/api/knowledge/MemoryEventListener.java
new file mode 100644
index 00000000..97acf461
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/MemoryEventListener.java
@@ -0,0 +1,33 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.EventListener;
+
+/**
+ * Gives notification when a memory event occurs,
+ * such as new active memory.
+ */
+
+public interface MemoryEventListener extends EventListener {
+ /**
+ * A new active memory was added.
+ */
+ void addActiveMemory(Vertex vertex);
+}
+
diff --git a/ai-engine/source/org/botlibre/api/knowledge/MemoryStorageException.java b/ai-engine/source/org/botlibre/api/knowledge/MemoryStorageException.java
new file mode 100644
index 00000000..7260aec7
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/MemoryStorageException.java
@@ -0,0 +1,43 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import org.botlibre.BotException;
+
+/**
+ * Thrown when a storage or retrieval exception occurs from the memory datastore.
+ */
+
+public class MemoryStorageException extends BotException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MemoryStorageException() {
+ super();
+ }
+
+ public MemoryStorageException(String message) {
+ super(message);
+ }
+
+ public MemoryStorageException(Exception exception) {
+ super(exception);
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Network.java b/ai-engine/source/org/botlibre/api/knowledge/Network.java
new file mode 100644
index 00000000..5e10fcfa
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Network.java
@@ -0,0 +1,357 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+
+import org.botlibre.Bot;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * An interconnected set of vertices,
+ * representing and knowledge-space.
+ * Define methods for creating, removing and finding vertices.
+ */
+
+public interface Network {
+ /**
+ * Resume after a merge/save.
+ */
+ void resume();
+
+ /**
+ * Merge the memory into the long term.
+ * This is similar to a transactional commit.
+ * The changes should also be persisted, as the long term should always just be a cache of the storage.
+ */
+ void save();
+
+ /**
+ * Create a new vertex in this network,
+ * assign the id.
+ */
+ Vertex createVertex();
+
+ /**
+ * Return the matching registered vertex, or register if missing.
+ */
+ Vertex createVertex(Vertex vertex);
+
+ /**
+ * Create a new vertex in this network with the data.
+ * If a vertex with the data already exists, then it is return as the data must be unique.
+ * If new a new vertex is created and a unique id assigned.
+ */
+ Vertex createVertex(Object data);
+
+ /**
+ * Return the relationship meta vertex.
+ */
+ Vertex createMeta(Relationship relationship);
+
+ /**
+ * Create a timestamp based on the current nanos.
+ */
+ Vertex createTimestamp();
+
+ /**
+ * Remove the vertex and all references to it from the network.
+ */
+ void removeVertexAndReferences(Vertex vertex);
+
+ /**
+ * Remove the vertex from the network.
+ * Note that the vertex must be no longer referenced by any other vertex in the network.
+ */
+ void removeVertex(Vertex vertex);
+
+ /**
+ * Remove the relationship from the network.
+ * Note that the relationship must be no longer referenced by any other vertex in the network.
+ */
+ void removeRelationship(Relationship relationship);
+
+ /**
+ * Return all vertices.
+ */
+ List findAll();
+
+ /**
+ * Return all vertices.
+ */
+ List findAll(int pageSize, int page);
+
+ /**
+ * Return all vertices matching the filter.
+ */
+ List findAllLike(String filter);
+
+ /**
+ * Return all vertices matching the filter.
+ */
+ List findAllLike(String filter, int pageSize, int page);
+
+ /**
+ * Return all vertices matching the query.
+ */
+ @SuppressWarnings("rawtypes")
+ List findAllQuery(String query);
+
+ /**
+ * Return all vertices matching the query.
+ */
+ @SuppressWarnings("rawtypes")
+ List findAllQuery(String query, Map parameters, int pageSize, int page);
+
+ /**
+ * Return count of all vertices.
+ */
+ int countAll();
+
+ /**
+ * Return count of vertices matching the filter.
+ */
+ int countAllLike(String filter);
+
+ /**
+ * Return all vertices matching the query.
+ */
+ @SuppressWarnings("rawtypes")
+ List findAllQuery(String query, int max);
+
+ /**
+ * Execute the native query.
+ */
+ @SuppressWarnings("rawtypes")
+ List findByNativeQuery(String sql, Class type, int max);
+
+ /**
+ * Execute and commit the native query.
+ */
+ int executeNativeQuery(String sql);
+
+ /**
+ * Execute and commit the update query.
+ */
+ int executeQuery(String jpql);
+
+ /**
+ * Find all relationships related to the vertex or of the vertex type.
+ */
+ List findAllInstances(Vertex type, Vertex relationship, Calendar start);
+
+ /**
+ * Return a query builder.
+ */
+ CriteriaBuilder getCriteriaBuilder();
+
+ /**
+ * Execute the criteria query.
+ */
+ @SuppressWarnings({ "rawtypes" })
+ List search(CriteriaQuery criteria, int page, int max);
+
+ /**
+ * Find all relationships related to the vertex or of the vertex relationship type.
+ */
+ List findAllRelationshipsTo(Vertex vertex);
+
+ /**
+ * Find all relationships related to the vertex by the type.
+ */
+ List findAllRelationshipsTo(Vertex vertex, Vertex type);
+
+ /**
+ * Return the vertex with the given data.
+ */
+ Vertex findByData(Object data);
+
+ /**
+ * Return the lob data.
+ */
+ Data findData(Data data);
+
+ /**
+ * Return the vertex with the given name.
+ */
+ Vertex findByName(String name);
+
+ /**
+ * Return the vertex with the given id.
+ */
+ Vertex findById(Number id);
+
+ /**
+ * Return the parent network.
+ * A network is essentially a nested-transactional sub-graph of the parent.
+ */
+ Network getParent();
+
+ /**
+ * Set the parent network.
+ * A network is essentially a nested-transactional sub-graph of the parent.
+ */
+ void setParent(Network parent);
+
+ /**
+ * Merge the vertices and relations of the network into the source network.
+ */
+ void merge(Network network);
+
+ /**
+ * Merge the vertex into this network.
+ */
+ void merge(Vertex source);
+
+ /**
+ * Merge the vertex into this network from an import.
+ * This is used from importing another memory.
+ */
+ void importMerge(Vertex source, Map identitySet);
+
+ /**
+ * Return the total number of vertices stored.
+ */
+ int size();
+
+ /**
+ * Associate alternative cases of the word with the meaning, type, tense, etc..
+ */
+ void associateCaseInsensitivity(Vertex word);
+
+ /**
+ * Associate alternative cases of the word with the meaning.
+ */
+ void associateCaseInsensitivity(String word, Vertex meaning);
+
+ /**
+ * Clear all vertices from the network.
+ */
+ void clear();
+
+ /**
+ * Create a new instance of the type.
+ */
+ Vertex createInstance(Primitive type);
+
+ /**
+ * Create a new instance of the type.
+ */
+ Vertex createInstance(Vertex type);
+
+ /**
+ * Tokenize the text into its words and create a vertex representation of the word or compound word.
+ */
+ Vertex createWord(String text);
+
+ /**
+ * Tokenize the text into its words and create a vertex representation of the sentence fragment.
+ */
+ Vertex createFragment(String text);
+
+ /**
+ * Tokenize the sentence into its words and create a vertex representation.
+ */
+ Vertex createSentence(String text);
+
+ /**
+ * Tokenize the sentence pattern into its words and wildcrads, and create a vertex representation.
+ */
+ Vertex createPattern(String text);
+
+ /**
+ * Compile the forumla response.
+ */
+ Vertex createFormula(String text);
+
+ /**
+ * Tokenize the sentence into its words and create a vertex representation.
+ */
+ Vertex createSentence(String text, boolean generated);
+
+ /**
+ * Tokenize the sentence into its words and create a vertex representation.
+ */
+ Vertex createSentence(String text, boolean generated, boolean reduced);
+
+ /**
+ * Tokenize the sentence into its words and create a vertex representation.
+ */
+ Vertex createSentence(String text, boolean generated, boolean reduced, boolean whitespace);
+
+ /**
+ * Convert the sentence to a paragraph if it has multiple phrases.
+ */
+ Vertex createParagraph(Vertex sentence);
+
+ /**
+ * Tokenize the paragraph into its sentences and create a vertex representation.
+ */
+ Vertex createParagraph(String text);
+
+ /**
+ * Create the word, and its meaning.
+ * If the word or meaning exist, use the existing one.
+ */
+ Vertex createObject(String name);
+
+ /**
+ * Create the primitive and associate the word to it.
+ */
+ Vertex createPrimitive(String name);
+
+ /**
+ * Create the word, and a new meaning.
+ */
+ Vertex createNewObject(String name);
+
+ /**
+ * Create a new anonymous speaker.
+ */
+ Vertex createAnonymousSpeaker();
+
+ /**
+ * Find or create the speaker with the name.
+ */
+ Vertex createSpeaker(String name);
+
+ /**
+ * Find or create the speaker with the name.
+ */
+ Vertex createName(String name);
+
+ /**
+ * Check if the sentence has been reduced, if not, then reduce.
+ */
+ void checkReduction(Vertex sentence);
+
+ /**
+ * Return the associated Bot instance.
+ */
+ Bot getBot();
+
+ /**
+ * Set the associated Bot instance.
+ */
+ void setBot(Bot Bot);
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Path.java b/ai-engine/source/org/botlibre/api/knowledge/Path.java
new file mode 100644
index 00000000..575184c6
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Path.java
@@ -0,0 +1,26 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+/**
+ * Defines depth or breadth search/traversal path.
+ */
+public enum Path {
+ DepthFirst,
+ BreadthFirst
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Relationship.java b/ai-engine/source/org/botlibre/api/knowledge/Relationship.java
new file mode 100644
index 00000000..b346f717
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Relationship.java
@@ -0,0 +1,161 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.Date;
+
+
+/**
+ * Relationship between two vertices.
+ * The relation itself is a vertex as it has an identity associated to it,
+ * and the relation may be related to other relations/vertices.
+ */
+
+public interface Relationship extends Comparable {
+
+ Long getId();
+
+ Vertex getSource();
+
+ Vertex getTarget();
+
+ Vertex getType();
+
+ Vertex getMeta();
+
+ boolean hasMeta();
+
+ /**
+ * Return the fuzzy value of the certainty of the relationship's correctness.
+ * Values are between 0 and 1.
+ */
+ float getCorrectness();
+
+ /**
+ * Set the fuzzy value of the certainty of the relationship's correctness.
+ * Values are between 0 and 1.
+ */
+ void setCorrectness(float correctness);
+
+ /**
+ * Return if the relationship is inverse, i.e. know to not exist.
+ */
+ boolean isInverse();
+
+ void setSource(Vertex source);
+
+ void setTarget(Vertex target);
+
+ void setType(Vertex type);
+
+ void setMeta(Vertex meta);
+
+ /**
+ * Return the index of the relationships in the source's relationships of that type.
+ */
+ int getIndex();
+
+ /**
+ * Set the index of the relationships in the source's relationships of that type.
+ */
+ void setIndex(int index);
+
+ /**
+ * Return if the relationship has an index (preset order).
+ */
+ boolean hasIndex();
+
+ /**
+ * Return the date the relationship was created.
+ */
+ Date getCreationDate();
+
+ /**
+ * Set the date the relationship was created.
+ */
+ void setCreationDate(Date creationDate);
+
+ /**
+ * Return the date the relationship was last accessed.
+ */
+ Date getAccessDate();
+
+ /**
+ * Set the date the relationship was last accessed.
+ */
+ void setAccessDate(Date accessDate);
+
+ /**
+ * Return the number of times the relationship has been accessed.
+ */
+ int getAccessCount();
+
+ /**
+ * Set the number of times the relationship has been accessed.
+ */
+ void setAccessCount(int accessCount);
+
+ /**
+ * Record that the relationship was accessed, update the access time and increment the access count.
+ */
+ void incrementAccessCount();
+
+ /**
+ * Increase the relationship's level of consciousness.
+ */
+ void incrementConsciousnessLevel();
+
+ /**
+ * Increase the relationship's level of consciousness by the amount.
+ */
+ void incrementConsciousnessLevel(int amount);
+
+ /**
+ * Decrease the relationship's level of consciousness.
+ */
+ void decrementConsciousnessLevel();
+
+ /**
+ * Decrease the relationship's level of consciousness by the amount.
+ */
+ void decrementConsciousnessLevel(int amount);
+
+ /**
+ * Return the relationship's level of consciousness.
+ */
+ int getConsciousnessLevel();
+
+ /**
+ * Set the relationship's level of consciousness.
+ */
+ void setConsciousnessLevel(int consciousnessLevel);
+
+ /**
+ * Return if the relationship is pinned to memory, and will not be forgotten.
+ */
+ boolean isPinned();
+
+ /**
+ * Set if the relationship should be pinned to memory.
+ * Pinned relationship will not be forgotten.
+ */
+ void setPinned(boolean pinned);
+
+ void resetHashCode();
+
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/knowledge/Vertex.java b/ai-engine/source/org/botlibre/api/knowledge/Vertex.java
new file mode 100644
index 00000000..536362dd
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/Vertex.java
@@ -0,0 +1,842 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Represents a piece of knowledge.
+ * Vertex is a very simple structure mainly comprised of its relationships,
+ * this gives the system a very simple and extendable structure.
+ * Basic implementation to allow subclasses to avoid defining some of the basic stuff.
+ * The data attribute allows for vertices that represents something tangible such as
+ * text, sound, image, number, etc. The data is also indexed within a network, so is the
+ * only guaranteed way to lookup an existing vertex.
+ */
+
+public interface Vertex {
+
+ /**
+ * Unique id for the vertex.
+ * All vertices should define a unique identifier.
+ */
+ Long getId();
+
+ /**
+ * Set the vertex id.
+ * The id can only be set when loading or creating a vertex.
+ */
+ void setId(Long id);
+
+
+ /**
+ * Return the name of the vertex.
+ * The name is used as a hint to refer to what the vertex represents.
+ */
+ String getName();
+
+ /**
+ * Set the name of the vertex.
+ * The name is used as a hint to refer to what the vertex represents.
+ */
+ void setName(String name);
+
+ /**
+ * Return group id of script.
+ * Used to optimize script loading.
+ */
+ long getGroupId();
+
+ /**
+ * Set group id of script.
+ * Used to optimize script loading.
+ */
+ void setGroupId(long groupId);
+
+ /**
+ * Return word count for a sentence.
+ * Used to detect corrupt/forgotten sentences.
+ */
+ int getWordCount();
+
+ /**
+ * Set word count for a sentence.
+ * Used to detect corrupt/forgotten sentences.
+ */
+ void setWordCount(int wordCount);
+
+ /**
+ * Return the String value of the data.
+ */
+ String getDataValue();
+
+ /**
+ * Return the String name of the data's type.
+ */
+ String getDataType();
+
+ /**
+ * Set the internal data-type of the vertex.
+ */
+ void setType(String type);
+
+ /**
+ * Print the object's data such as a sentence or paragraph.
+ */
+ String printString();
+
+ /**
+ * Allows some piece of data to be associated with the vertex.
+ * May be text, image, sound, numeric, date, primitive, etc.
+ */
+ Object getData();
+
+ /**
+ * Allows some piece of data to be associated with the vertex.
+ * May be text, image, sound, numeric, date, primitive, etc.
+ */
+ void setData(Object data);
+
+ /**
+ * Most pure knowledge vertices have no data,
+ * this provides an easy test method.
+ */
+ boolean hasData();
+
+ /**
+ * Some vertices have no name,
+ * this provides an easy test method.
+ */
+ boolean hasName();
+
+ /**
+ * Compare the vertices ignoring case.
+ */
+ boolean equalsIgnoreCase(Vertex vertex);
+
+ /**
+ * Return the network the vertex is derived from.
+ */
+ Network getNetwork();
+
+ /**
+ * Set the network the vertex is derived from.
+ */
+ void setNetwork(Network network);
+
+ /**
+ * Return the date the vertex was created.
+ */
+ Date getCreationDate();
+
+ /**
+ * Set the date the vertex was created.
+ */
+ void setCreationDate(Date creationDate);
+
+ /**
+ * Return the date the vertex was last accessed.
+ */
+ Date getAccessDate();
+
+ /**
+ * Set the date the vertex was last accessed.
+ * Access is considered moving from long term to short term memory.
+ */
+ void setAccessDate(Date accessDate);
+
+ /**
+ * Return the number of times the vertex has been accessed.
+ * Access is considered moving from long term to short term memory.
+ */
+ int getAccessCount();
+
+ /**
+ * Set the number of times the vertex has been accessed.
+ */
+ void setAccessCount(int accessCount);
+
+ /**
+ * Record that the vertex was accessed, update the access time and increment the access count.
+ */
+ void incrementAccessCount();
+
+ /**
+ * Increase the vertices's level of consciousness.
+ */
+ void incrementConsciousnessLevel();
+
+ /**
+ * Increase the vertices's level of consciousness by the amount.
+ */
+ void incrementConsciousnessLevel(int amount);
+
+ /**
+ * Decrease the vertices's level of consciousness.
+ */
+ void decrementConsciousnessLevel();
+
+ /**
+ * Decrease the vertices's level of consciousness by the amount.
+ */
+ void decrementConsciousnessLevel(int amount);
+
+ /**
+ * Return the vertices's level of consciousness.
+ */
+ int getConsciousnessLevel();
+
+ /**
+ * Set the vertices's level of consciousness.
+ */
+ void setConsciousnessLevel(int consciousnessLevel);
+
+ /**
+ * Return if the vertex is pinned to memory, and will not be forgotten.
+ */
+ boolean isPinned();
+
+ /**
+ * Set if the vertex should be pinned to memory.
+ * Pinned vertices will not be forgotten.
+ */
+ void setPinned(boolean pinned);
+
+
+ /**
+ * Pin the vertex and all of its descendants into memory.
+ * This can be used for important data such as language rules.
+ */
+ void pinDescendants();
+
+ /**
+ * Unpin the vertex and all of its descendants from memory.
+ * This can be used to release removed language rules.
+ */
+ void unpinDescendants();
+
+ /**
+ * Return if the relationships have been instantiated.
+ */
+ boolean hasRelationships();
+
+ /**
+ * Return all of the relationships of the primitive type, sorted by index.
+ */
+ List orderedRelationships(Primitive primitive);
+
+ /**
+ * Return all of the relationships of the type, sorted by index.
+ */
+ List orderedRelationships(Vertex relationshipType);
+
+
+ /**
+ * Return all of the relationships of the type, sorted by consciousness level.
+ */
+ List orderedRelationshipsByConsciousness(Primitive primitive);
+
+ /**
+ * Return all of the relationships of the type, sorted by consciousness level.
+ */
+ List orderedRelationshipsByConsciousness(Vertex relationshipType);
+
+ /**
+ * Return all of the relationships targets of the primitive type, sorted by index.
+ */
+ List orderedRelations(Primitive primitive);
+
+ /**
+ * Return all of the relationship targets of the type, sorted by index.
+ */
+ List orderedRelations(Vertex relationshipType);
+
+ /**
+ * Return any relationship target of the primitive type.
+ */
+ Vertex getRelationship(Primitive type);
+
+ /**
+ * Return any relationship target of the type.
+ */
+ Vertex getRelationship(Vertex type);
+
+ /**
+ * Return any relationship target of the primitive type.
+ */
+ Collection getRelationships(Primitive type);
+
+ /**
+ * Return the relationship to the target of the primitive type.
+ */
+ Relationship getRelationship(Primitive type, Primitive target);
+
+ /**
+ * Return the relationship to the target of the primitive type.
+ */
+ Relationship getRelationship(Primitive type, Vertex target);
+
+ /**
+ * Return the relationship to the target of the primitive type.
+ */
+ Relationship getRelationship(Vertex type, Vertex target);
+
+ /**
+ * Return all relationships of the type.
+ * A vertex may have a relation to any other vertex including itself,
+ * relations may be of different types such as "classification", "belongs", "contained", etc.
+ * The real knowledge of the vertex is define by its relationships.
+ */
+ Collection getRelationships(Vertex relationshipType);
+
+ /**
+ * Return the last of the ordered relationship, or null.
+ */
+ Vertex lastRelationship(Vertex type);
+
+ /**
+ * Fix the corrupted relationship index order.
+ * The order can get corrupted when relationships are forgotten.
+ */
+ void fixRelationships(Vertex type);
+
+
+ /**
+ * Return the the vertex has exceeded it relationships maximum.
+ */
+ boolean isDirty();
+
+ /**
+ * Mark the vertex for forgetfullness.
+ */
+ void setIsDirty(boolean isDirty);
+
+ /**
+ * Return the fromLast last of the ordered relationship, or null.
+ * i.e. 2nd last, or 3rd last, etc.
+ */
+ Vertex lastRelationship(Vertex type, int fromLast);
+
+ /**
+ * Return the fromLast last of the ordered relationship, or null.
+ * i.e. 2nd last, or 3rd last, etc.
+ */
+ Vertex lastRelationship(Primitive type, int fromLast);
+
+ /**
+ * Return the last of the ordered relationship, or null.
+ */
+ Vertex lastRelationship(Primitive type);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level.
+ */
+ Vertex mostConscious(Vertex type);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level.
+ */
+ Vertex mostConscious(Primitive type);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level greater than the value.
+ */
+ Vertex mostConscious(Vertex type, float min);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level.
+ */
+ Relationship mostConsciousRelationship(Primitive type);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level and correctness greater than the value.
+ */
+ Relationship mostConsciousRelationship(Primitive type, float min);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level.
+ */
+ Relationship mostConsciousRelationship(Vertex type);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level and correctness greater than the value.
+ */
+ Vertex mostConscious(Primitive type, float min);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level and correctness greater than the value.
+ */
+ Vertex nextMostConscious(Vertex type, Vertex ignoring, float min);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level.
+ */
+ Relationship nextMostConsciousRelationship(Vertex type, Vertex ignoring);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level.
+ */
+ Relationship nextMostConsciousRelationship(Primitive type, Vertex ignoring);
+
+ /**
+ * Return the relationship related by the type, with the high consciousness level greater than the value.
+ */
+ Relationship nextMostConsciousRelationship(Primitive type, Vertex ignoring, float min);
+
+ /**
+ * Return the target vertex related by the type, with the high consciousness level greater than the value.
+ */
+ Vertex nextMostConscious(Primitive type, Vertex ignoring, float min);
+
+ /**
+ * Return the target vertex related by the type, of the classification, with the high consciousness level.
+ */
+ Vertex mostConscious(Vertex type, Vertex classification);
+
+ /**
+ * Return the target vertex inversely/negatively related by the type, with the high consciousness level.
+ */
+ Vertex mostConscious(Vertex type, float min, boolean inverse);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType, Vertex defaultAssociate);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType, Vertex associate2, Vertex associateType2);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType, Vertex associate2, Vertex associateType2, Vertex associate3, Vertex associateType3);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType, Vertex associate2, Vertex associateType2, Collection associate3, Vertex associateType3, Vertex defaultAssociate);
+
+ /**
+ * Return the target vertex related by the type, that has the relationship to the previous, otherwise null if not found.
+ */
+ Vertex getAssoiate(Vertex type, Vertex associate, Vertex associateType, Collection associate2, Vertex associateType2, Collection associate3, Vertex associateType3, Vertex defaultAssociate);
+
+ /**
+ * Return the target vertex related by the type, that is also most correctly related to the associate vertex by the relationship.
+ * If no related vertices are related to the associate, then return the most conscious.
+ */
+ Vertex mostConsciousWithAssoiate(Vertex type, Vertex associate, Vertex associateType);
+
+ /**
+ * Return the target vertex related by the type, that is also most correctly related to the associate vertex by the relationship.
+ * If no related vertices are related to the associate, then return the most conscious.
+ */
+ Vertex mostConsciousWithAssoiates(Vertex type, Vertex associate, Vertex associateType, Vertex associate2, Vertex associateType2);
+
+ /**
+ * Associate each of the relationship target vertices with the target vertex by the type.
+ */
+ void associateAll(Vertex relationshipType, Vertex target, Vertex type);
+
+ /**
+ * Associate each of the relationship target vertices with the target vertex by the type.
+ */
+ void associateAll(Primitive relationshipType, Vertex target, Primitive type);
+
+ /**
+ * Associate each of the relationship target vertices with the target vertex by the type.
+ */
+ void weakAssociateAll(Vertex relationshipType, Vertex target, Vertex type, float correctnessMultiplier);
+
+ /**
+ * Associate each of the relationship target vertices with the target vertex by the type.
+ */
+ void weakAssociateAll(Primitive relationshipType, Vertex target, Primitive type, float correctnessMultiplier);
+
+ /**
+ * Dissociate each of the relationship target vertices with the target vertex by the type.
+ */
+ void inverseAssociateAll(Primitive relationshipType, Vertex source, Primitive type);
+
+ /**
+ * Dissociate each of the relationship target vertices with the target vertex by the type.
+ */
+ void inverseAssociateAll(Vertex relationshipType, Vertex source, Vertex type);
+
+ /**
+ * Return all of the relationships.
+ */
+ Collection getAllRelationships();
+
+ /**
+ * Return all relationships.
+ * Relationships are stored as a map keyed on the relationship type,
+ * with ordered list of relationship targets.
+ */
+ Map> getRelationships();
+
+ /**
+ * Provides an easier method of traversing all the relations of a vertex.
+ */
+ Iterator allRelationships();
+
+ /**
+ * Create a copy of the vertex with all of the same relationships.
+ */
+ Vertex copy();
+
+ /**
+ * Create a copy of the vertex with only the id.
+ */
+ Vertex detach();
+
+ /**
+ * Iterator over all related vertices to the vertex.
+ */
+ void iterate(VertexIterator iterator);
+
+ /**
+ * Return the total number of all relationships.
+ */
+ int totalRelationships();
+
+ /**
+ * Provides an easier method of traversing all the relations of a vertex.
+ */
+ Iterator orderedAllRelationships();
+
+ /**
+ * Add the relation of the relationship primitive type to the target primitive.
+ */
+ Relationship addRelationship(Primitive type, Primitive target);
+
+ /**
+ * Add the relation of the relationship primitive type to the target vertex.
+ */
+ Relationship addRelationship(Primitive type, Vertex target);
+
+ /**
+ * Add the relation of the type to the other vertex.
+ */
+ Relationship addRelationship(Vertex type, Vertex target);
+
+ /**
+ * Add the relation of the type to the other vertex.
+ * Ignore bookkeeping, don't increment correctness.
+ */
+ Relationship addRelationship(Vertex type, Vertex target, int index, boolean internal);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * The correctness decreases the correctness of the relation.
+ */
+ Relationship addWeakRelationship(Primitive type, Primitive target, float correctnessMultiplier);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * The correctness decreases the correctness of the relation.
+ */
+ Relationship addWeakRelationship(Primitive type, Vertex target, float correctnessMultiplier);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * The correctness decreases the correctness of the relation.
+ */
+ Relationship addWeakRelationship(Vertex type, Vertex target, float correctnessMultiplier);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * These are currently uni-directional.
+ * Only a single relation of a type can be defined to the same target,
+ * i.e. relationships to the same vertex are unique.
+ * unless the relationship is ordered, then they are only equal if the same index.
+ */
+ Relationship addRelationship(Primitive type, Vertex target, int index);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * These are currently uni-directional.
+ * Only a single relation of a type can be defined to the same target,
+ * i.e. relationships to the same vertex are unique.
+ * unless the relationship is ordered, then they are only equal if the same index.
+ */
+ Relationship addRelationship(Primitive type, Primitive target, int index);
+
+ /**
+ * Add the relation of the relationship type to the target vertex.
+ * These are currently uni-directional.
+ * Only a single relation of a type can be defined to the same target,
+ * i.e. relationships to the same vertex are unique.
+ * unless the relationship is ordered, then they are only equal if the same index.
+ */
+ Relationship addRelationship(Vertex type, Vertex target, int index);
+
+ /**
+ * Add the relation ensuring uniqueness.
+ */
+ Relationship addRelationship(Relationship relationship, boolean internal);
+
+ /**
+ * Remove the relation of the type from the other vertex.
+ * This creates an inverse relationship.
+ */
+ Relationship removeRelationship(Vertex type, Vertex target);
+
+ /**
+ * Remove the relation of the primitive type from the other vertex.
+ * This creates an inverse relationship.
+ */
+ Relationship removeRelationship(Primitive type, Vertex target);
+
+ /**
+ * Remove the relation of the primitive type from the other vertex.
+ * This creates an inverse relationship.
+ */
+ Relationship removeRelationship(Primitive type, Primitive target);
+
+ /**
+ * Replace the relationship with the new target at the same index.
+ */
+ void replaceRelationship(Relationship oldRelationship, Vertex newTarget);
+
+ /**
+ * Set the relationship, removing the old value.
+ */
+ void setRelationship(Primitive type, Vertex newValue);
+
+ /**
+ * Set the relationship, removing the old value.
+ */
+ void setRelationship(Vertex type, Vertex newValue);
+
+ /**
+ * Remove the relation.
+ */
+ void internalRemoveRelationship(Relationship relationship);
+
+ /**
+ * Remove the relationships of the type.
+ */
+ void internalRemoveRelationships(Primitive type);
+
+ /**
+ * Remove the relationships of the type.
+ */
+ void internalRemoveRelationships(Vertex type);
+
+ /**
+ * Pin the targets of all relationships to memory.
+ */
+ void pinChildren();
+
+ /**
+ * Unpin the targets of all relationships from memory.
+ */
+ void unpinChildren();
+
+ /**
+ * Remove all relationships.
+ */
+ void internalRemoveAllRelationships();
+
+ /**
+ * Return if the vertex has a relationship of the type to the target.
+ * Include inverses.
+ */
+ boolean internalHasRelationship(Vertex type, Vertex target);
+
+ /**
+ * Apply the quotient.
+ * Apply the equation to the variable matches.
+ */
+ Vertex applyQuotient(Map variables);
+
+ /**
+ * Evaluates any eval functions in the equation or formula..
+ * This is used by learn.
+ */
+ public Vertex applyEval(Map variables);
+
+ /**
+ * Compare if the two vertices match.
+ * Consider variables.
+ * Used for rule processing.
+ */
+ Boolean matches(Vertex vertex, Map matches);
+
+ /**
+ * Compare if the two vertices match.
+ * Consider variables.
+ * Used for rule processing.
+ */
+ boolean collectMatches(Vertex vertex, Map> matches);
+
+ /**
+ * Return if the vertex is a system primitive.
+ */
+ boolean isPrimitive();
+
+ /**
+ * Return if the vertex is the vertex for the data.
+ */
+ boolean is(Object data);
+
+ /**
+ * Return if the vertex is an instantiation of the primitive type.
+ */
+ boolean instanceOf(Primitive type);
+
+ /**
+ * Return if the vertex is an instantiation of the type.
+ */
+ boolean instanceOf(Vertex type);
+
+ /**
+ * Return if the vertex is a variable.
+ */
+ boolean isVariable();
+
+ /**
+ * Return if the vertex is a list.
+ */
+ boolean isList();
+
+ /**
+ * Return if the vertex is an equation.
+ */
+ boolean isEquation();
+
+ /**
+ * Return if the vertex has a relationship of the type primitive.
+ */
+ boolean hasRelationship(Primitive type);
+
+ /**
+ * Return if the vertex has a relationship of the type primitive to the target primitive.
+ */
+ boolean hasRelationship(Primitive type, Primitive target);
+
+ /**
+ * Return if the vertex has a relationship of the type primitive to the target.
+ */
+ boolean hasRelationship(Primitive type, Vertex target);
+
+ /**
+ * Return if the vertex has a relationship of the type to the target.
+ */
+ boolean hasRelationship(Vertex type, Vertex target);
+
+ /**
+ * Return if the vertex has a relationship of the type to the target.
+ */
+ boolean hasOrInheritsRelationship(Vertex type, Vertex target);
+
+ /**
+ * Return if the vertex has a relationship of the type to the target.
+ */
+ boolean hasOrInheritsRelationship(Vertex type, Vertex target, Map recursion);
+
+ /**
+ * Return if the vertex has any relationship of the type.
+ */
+ boolean hasRelationship(Vertex type);
+
+ /**
+ * Return if the vertex has any relationship to any target.
+ */
+ boolean hasAnyRelationshipToTarget(Vertex target);
+
+ /**
+ * Return if the vertex has any relationship to any target that is an instantiation of the classification.
+ */
+ boolean hasAnyRelationshipToTargetOfType(Vertex classification);
+
+ /**
+ * Return the most conscious target the vertex has any relationship to that is an instantiation of the classification.
+ */
+ Vertex mostConsciousTargetOfType(Vertex classification);
+
+ /**
+ * Return if the vertex has an inverse/negative relationship of the type to the target.
+ */
+ boolean hasInverseRelationship(Primitive type, Primitive target);
+
+ /**
+ * Return if the vertex has an inverse/negative relationship of the type to the target.
+ */
+ boolean hasInverseRelationship(Primitive type, Vertex target);
+
+ /**
+ * Return if any of the associates of the vertex have an inverse/negative relationship of the type to the target.
+ */
+ boolean hasAnyAssociatedInverseRelationship(Primitive associate, Vertex target, Primitive type);
+
+ /**
+ * Return if any of the associates of the vertex have an inverse/negative relationship of the type to the target.
+ */
+ boolean hasAnyAssociatedInverseRelationship(Vertex associate, Vertex target, Vertex type);
+
+ /**
+ * Return if the vertex has an inverse/negative relationship of the type to the target.
+ */
+ boolean hasInverseRelationship(Vertex type, Vertex target);
+
+ /**
+ * Return if the vertex has an inverse/negative relationship of the type to the target.
+ */
+ boolean hasOrInheritsInverseRelationship(Vertex type, Vertex target);
+
+ /**
+ * Return if the vertex has an inverse/negative relationship of the type to the target.
+ */
+ boolean hasOrInheritsInverseRelationship(Vertex type, Vertex target, Map recursion);
+
+ /**
+ * PERF: Used to check response without accessing relationships.
+ */
+ boolean hasAnyResponseRelationship();
+
+ /**
+ * Return a short toString, or header of the vertex.
+ */
+ String description();
+
+ /**
+ * Set the original long term vertex the short term vertex was derived from.
+ */
+ void setOriginal(Vertex original);
+
+ /**
+ * User friendly toString.
+ */
+ public String displayString();
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/knowledge/VertexIterator.java b/ai-engine/source/org/botlibre/api/knowledge/VertexIterator.java
new file mode 100644
index 00000000..deef990c
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/knowledge/VertexIterator.java
@@ -0,0 +1,101 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.knowledge;
+
+import java.util.Map;
+
+/**
+ * Allow iteration over all related vertices and all descendants.
+ */
+
+public interface VertexIterator {
+ /**
+ * Do not iterate on or over primitives.
+ */
+ boolean getIgnorePrimitives();
+
+ /**
+ * Maximum number of vertices to iterator over, -1 means no maximum.
+ */
+ int getMaxIterations();
+
+ /**
+ * Return the max depth of relationships to traverse, -1 means all.
+ */
+ int getMaxDepth();
+
+ /**
+ * Return if the iterator is at the max depth.
+ */
+ boolean isMaxDepth();
+
+ /**
+ * Return if the iterator has iterated the max iterations.
+ */
+ boolean isMaxIterations();
+
+ /**
+ * Increment the current depth of traversal.
+ */
+ int incrementDepth();
+
+ /**
+ * Increment the current depth of traversal.
+ */
+ int decrementDepth();
+
+ /**
+ * Return the current depth of traversal.
+ */
+ int getDepth();
+
+ /**
+ * Set the current depth of traversal.
+ */
+ void setDepth(int depth);
+
+ /**
+ * Traversal path.
+ */
+ Path getPath();
+
+ /**
+ * Iterate on the vertex, and return true if children should be traversed.
+ */
+ boolean iterate(Vertex vertex);
+
+ /**
+ * Return the set of already traversed vertices.
+ */
+ Map getTraversed();
+
+ /**
+ * Return the set of vertices for the next breadth first traversal level.
+ */
+ Map getBreadthSet();
+
+ /**
+ * Set of vertices for the next breadth first traversal level.
+ */
+ void setBreadthSet(Map breadthSet);
+
+ /**
+ * Add the vertex to the breadth set for traversal.
+ */
+ void addBreadth(Vertex vertex);
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/sense/Awareness.java b/ai-engine/source/org/botlibre/api/sense/Awareness.java
new file mode 100644
index 00000000..3535cde6
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/Awareness.java
@@ -0,0 +1,80 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.sense;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.api.knowledge.Vertex;
+
+/**
+ * Controls and manages the senses.
+ */
+
+public interface Awareness {
+
+ void shutdown();
+
+ void awake();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ Map getSenses();
+
+ T getSense(Class type);
+
+ /**
+ * Return the sense with the name.
+ */
+ Sense getSense(String name);
+
+ void addSense(Sense sense);
+
+ void removeSense(Sense sense);
+
+ Map getTools();
+
+ T getTool(Class type);
+
+ /**
+ * Return the tool with the name.
+ */
+ Tool getTool(String name);
+
+ void addTool(Tool sense);
+
+ void removeTool(Tool sense);
+
+ Bot getBot();
+
+ void setBot(Bot Bot);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+ /**
+ * Allow the sense to output the response.
+ */
+ void output(Vertex output);
+}
+
diff --git a/ai-engine/source/org/botlibre/api/sense/ExceptionEventListener.java b/ai-engine/source/org/botlibre/api/sense/ExceptionEventListener.java
new file mode 100644
index 00000000..c7655a85
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/ExceptionEventListener.java
@@ -0,0 +1,33 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.sense;
+
+import java.util.EventListener;
+
+/**
+ * Gives notification when a memory event occurs,
+ * such as new active memory.
+ */
+
+public interface ExceptionEventListener extends EventListener {
+ /**
+ * A new active memory was added.
+ */
+ void notify(Exception exception);
+}
+
diff --git a/ai-engine/source/org/botlibre/api/sense/InputNotSupported.java b/ai-engine/source/org/botlibre/api/sense/InputNotSupported.java
new file mode 100644
index 00000000..96993f75
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/InputNotSupported.java
@@ -0,0 +1,21 @@
+package org.botlibre.api.sense;
+
+/**
+ * Thrown if the sense does not support input.
+ * i.e. output only, such as voice.
+ */
+
+public class InputNotSupported extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InputNotSupported() {
+ super();
+ }
+
+ public InputNotSupported(String message) {
+ super(message);
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/sense/OutputNotSupported.java b/ai-engine/source/org/botlibre/api/sense/OutputNotSupported.java
new file mode 100644
index 00000000..9d912710
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/OutputNotSupported.java
@@ -0,0 +1,21 @@
+package org.botlibre.api.sense;
+
+/**
+ * Thrown if the sense does not support output.
+ * i.e. input only, such as hearing.
+ */
+
+public class OutputNotSupported extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public OutputNotSupported() {
+ super();
+ }
+
+ public OutputNotSupported(String message) {
+ super(message);
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/sense/Sense.java b/ai-engine/source/org/botlibre/api/sense/Sense.java
new file mode 100644
index 00000000..61957383
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/Sense.java
@@ -0,0 +1,131 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.sense;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.emotion.EmotionalState;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.thought.language.Language.LanguageState;
+
+/**
+ * Defines an external interface.
+ * i.e.
+ * - text
+ * - voice
+ * - hearing
+ * - vision
+ */
+
+public interface Sense {
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+ /**
+ * Start sensing.
+ */
+ void awake();
+
+ /**
+ * Stop sensing.
+ */
+ void shutdown();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ /**
+ * Receive any input from the sense. The type of input varies by sense, could be text, sound, image, html etc.
+ */
+ void input(Object inputData);
+
+ /**
+ * Receive any input from the sense. The type of input varies by sense, could be text, sound, image, html etc.
+ */
+ void input(Object inputData, Network network) throws Exception;
+
+ /**
+ * Output the active network through the sense, could be text, sound, image, commands etc..
+ */
+ void output(Vertex output);
+
+ /**
+ * Return the name that identifies the sense.
+ */
+ String getName();
+
+ /**
+ * Set the name that identifies the sense.
+ */
+ void setName(String name);
+
+ /**
+ * Return the associated Bot instance.
+ */
+ Bot getBot();
+
+ /**
+ * Set the associated Bot instance.
+ */
+ void setBot(Bot Bot);
+
+ /**
+ * Return the current conversational state.
+ */
+ LanguageState getLanguageState();
+
+ /**
+ * Set the current conversational state.
+ */
+ void setLanguageState(LanguageState languageState);
+
+ /**
+ * Set the current conversational mood.
+ */
+ void setEmotionalState(EmotionalState emotion);
+
+ /**
+ * Set the current action.
+ */
+ void setAction(String action);
+
+ /**
+ * Return if the sense is enabled.
+ */
+ boolean isEnabled();
+
+ /**
+ * Allow the sense to disabled/enabled.
+ */
+ void setIsEnabled(boolean isEnabled);
+
+ /**
+ * Allows senses to be referenced by memory.
+ */
+ Primitive getPrimitive();
+
+ void notifyExceptionListeners(Exception exception);
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/sense/Tool.java b/ai-engine/source/org/botlibre/api/sense/Tool.java
new file mode 100644
index 00000000..3a0d0577
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/sense/Tool.java
@@ -0,0 +1,90 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.sense;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Defines an external interface.
+ * i.e.
+ * - calculator
+ * - watch
+ */
+
+public interface Tool {
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+ /**
+ * Start.
+ */
+ void awake();
+
+ /**
+ * Stop.
+ */
+ void shutdown();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ /**
+ * Return the name that identifies the tool.
+ */
+ String getName();
+
+ /**
+ * Set the name that identifies the tool.
+ */
+ void setName(String name);
+
+ /**
+ * Return the associated Bot instance.
+ */
+ Bot getBot();
+
+ /**
+ * Set the associated Bot instance.
+ */
+ void setBot(Bot Bot);
+
+ /**
+ * Return if the sense is enabled.
+ */
+ boolean isEnabled();
+
+ /**
+ * Allow the sense to disabled/enabled.
+ */
+ void setIsEnabled(boolean isEnabled);
+
+ /**
+ * Allows senses to be referenced by memory.
+ */
+ Primitive getPrimitive();
+
+ void notifyExceptionListeners(Exception exception);
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/api/thought/Mind.java b/ai-engine/source/org/botlibre/api/thought/Mind.java
new file mode 100644
index 00000000..a1019059
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/thought/Mind.java
@@ -0,0 +1,110 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.thought;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+
+/**
+ * Controls and manages the thought processing.
+ */
+
+public interface Mind {
+ public enum MentalState {
+ /**
+ * UNCONSCIOUS is the dream state, the conscious thought is free to wander.
+ */
+ UNCONSCIOUS,
+ /**
+ * ASLEEP is the dream state, the conscious thought is free to wander.
+ */
+ ASLEEP,
+ /**
+ * BORED, some activity but conscious thought is free to wander.
+ */
+ BORED,
+ /**
+ * ACTIVE, active interacting, or performing a task.
+ */
+ ACTIVE,
+ /**
+ * ALERT, highly active, large amount of sensory input.
+ */
+ ALERT,
+ /**
+ * PANIC sensory overload, fight, flight or cry.
+ */
+ PANIC
+ }
+
+ void shutdown();
+
+ void awake();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ /**
+ * Return the state of mind.
+ */
+ MentalState getState();
+
+ /**
+ * Return if in an active state.
+ */
+ boolean isActive();
+
+ /**
+ * Return if in an conscious state.
+ */
+ boolean isConscious();
+
+ /**
+ * Return if in an sleep state.
+ */
+ boolean isAsleep();
+
+ /**
+ * Return if in an bored state.
+ */
+ boolean isBored();
+
+ Map getThoughts();
+
+ T getThought(Class type);
+
+ Thought getThought(String name);
+
+ void addThought(Thought thought);
+
+ void removeThought(Thought thought);
+
+ Bot getBot();
+
+ void setBot(Bot Bot);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+}
+
diff --git a/ai-engine/source/org/botlibre/api/thought/Thought.java b/ai-engine/source/org/botlibre/api/thought/Thought.java
new file mode 100644
index 00000000..319fe365
--- /dev/null
+++ b/ai-engine/source/org/botlibre/api/thought/Thought.java
@@ -0,0 +1,94 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.api.thought;
+
+import java.util.Map;
+
+import org.botlibre.Bot;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Something that given a network of objects can perform some function.
+ */
+
+public interface Thought {
+
+ /**
+ * Return the name that identifies the thought.
+ */
+ String getName();
+
+ /**
+ * Set the name that identifies the thought.
+ */
+ void setName(String name);
+
+ /**
+ * Stop analyzing network.
+ */
+ void stop();
+
+ boolean isStopped();
+
+ /**
+ * Reset state when instance is pooled.
+ */
+ void pool();
+
+ /**
+ * Analyze and extend the network.
+ */
+ void think();
+
+ /**
+ * Perform any initialization required on startup.
+ */
+ void awake();
+
+ /**
+ * Return the primitive representation of the thought.
+ */
+ Primitive getPrimitive();
+
+ /**
+ * Return the associated Bot instance.
+ */
+ Bot getBot();
+
+ /**
+ * Set the associated Bot instance.
+ */
+ void setBot(Bot Bot);
+
+ /**
+ * Initialize any configuration properties.
+ */
+ void initialize(Map properties);
+
+ /**
+ * Thoughts can be conscious or sub-conscious.
+ * A conscious thought is run by the mind single threaded with exclusive access to the short term memory.
+ * A sub-conscious thought is run concurrently, and must run in its own memory space.
+ */
+ boolean isConscious();
+
+ /**
+ * Return if this thought must run even under stress.
+ */
+ boolean isCritical();
+}
\ No newline at end of file
diff --git a/ai-engine/source/org/botlibre/avatar/BasicAvatar.java b/ai-engine/source/org/botlibre/avatar/BasicAvatar.java
new file mode 100644
index 00000000..c03ea0ef
--- /dev/null
+++ b/ai-engine/source/org/botlibre/avatar/BasicAvatar.java
@@ -0,0 +1,232 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.avatar;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.botlibre.Bot;
+import org.botlibre.api.avatar.Avatar;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.emotion.EmotionalState;
+import org.botlibre.knowledge.ImageData;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Controls and manages the thought processing.
+ */
+
+public class BasicAvatar implements Avatar {
+
+ protected Bot bot;
+
+ protected String action;
+ protected String pose;
+ protected String emote;
+
+ public BasicAvatar() {
+ }
+
+ @Override
+ public void pool() {
+ this.action = null;
+ this.pose = null;
+ this.emote = null;
+ }
+
+ @Override
+ public String getAction() {
+ return action;
+ }
+
+ @Override
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public String getPose() {
+ return pose;
+ }
+
+ @Override
+ public void setPose(String pose) {
+ this.pose = pose;
+ }
+
+ @Override
+ public String getEmote() {
+ return emote;
+ }
+
+ @Override
+ public void setEmote(String emote) {
+ this.emote = emote;
+ }
+
+ /**
+ * Log the message if the debug level is greater or equal to the level.
+ */
+ public void log(String message, Level level, Object... arguments) {
+ this.bot.log(this, message, level, arguments);
+ }
+
+ /**
+ * Log the exception.
+ */
+ public void log(Throwable exception) {
+ this.bot.log(this, exception);
+ }
+
+ /**
+ * Return Bot.
+ */
+ @Override
+ public Bot getBot() {
+ return bot;
+ }
+
+ @Override
+ public Primitive getPrimitive() {
+ return Primitive.AVATAR;
+ }
+
+ /**
+ * Set Bot.
+ */
+ @Override
+ public void setBot(Bot bot) {
+ this.bot = bot;
+ }
+
+ /**
+ * Initialize any configurable settings from the properties.
+ */
+ @Override
+ public void initialize(Map properties) {
+ return;
+ }
+
+ @Override
+ public void shutdown() {
+ this.bot.log(this, "Shutdown", Bot.FINE);
+ pool();
+ }
+
+ @Override
+ public void awake() {
+ this.bot.log(this, "Awake", Bot.FINE);
+ }
+
+ /**
+ * Evaluate the output for emotional expression.
+ */
+ @Override
+ public void evaluateOutput(Vertex output) {
+ Vertex action = output.mostConscious(Primitive.ACTION);
+ if (action != null && action.isPrimitive()) {
+ setAction(action.getDataValue());
+ } else {
+ setAction(null);
+ }
+ Vertex pose = output.mostConscious(Primitive.POSE);
+ if (pose != null && pose.isPrimitive()) {
+ if (pose.getDataValue().equals("default")) {
+ setPose(null);
+ } else {
+ setPose(pose.getDataValue());
+ }
+ }
+ EmotionalState emote = this.bot.mood().evaluateEmotionalState(output);
+ setEmote(emote.name());
+ emote(emote, output.getNetwork());
+ }
+
+ /**
+ * Evaluate the input response for actions and poses.
+ */
+ @Override
+ public void evaluateResponse(Vertex output, Vertex response, Vertex meta) {
+ Collection actions = null;
+ if (meta != null) {
+ actions = meta.getRelationships(Primitive.ACTION);
+ }
+ if (actions == null) {
+ actions = response.getRelationships(Primitive.ACTION);
+ }
+ if (actions != null) {
+ for (Relationship relationship : actions) {
+ output.addWeakRelationship(Primitive.ACTION, relationship.getTarget(), relationship.getCorrectness());
+ }
+ }
+ Collection poses = null;
+ if (meta != null) {
+ poses = meta.getRelationships(Primitive.POSE);
+ }
+ if (poses == null) {
+ poses = response.getRelationships(Primitive.POSE);
+ }
+ if (poses != null) {
+ for (Relationship relationship : poses) {
+ output.addWeakRelationship(Primitive.POSE, relationship.getTarget(), relationship.getCorrectness());
+ }
+ }
+ }
+
+ public Long clearAvatarProperty() {
+ Long id = null;
+ Network memory = getBot().memory().newMemory();
+ Vertex avatar = memory.createVertex(getPrimitive());
+
+ Vertex property = avatar.getRelationship(Primitive.ID);
+ if (property != null) {
+ id = (Long)property.getData();
+ property.setPinned(false);
+ }
+
+ avatar.internalRemoveRelationships(Primitive.ID);
+
+ memory.save();
+ return id;
+ }
+
+ /**
+ * Output the emotional state to the Avatar.
+ */
+ public void emote(EmotionalState state, Network memory) {
+
+ }
+
+ @Override
+ public ImageData getCurrentImage() {
+ return null;
+ }
+
+ /**
+ * Print a useful string representation of the avatar.
+ */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "()";
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/avatar/ImageAvatar.java b/ai-engine/source/org/botlibre/avatar/ImageAvatar.java
new file mode 100644
index 00000000..0c1707e4
--- /dev/null
+++ b/ai-engine/source/org/botlibre/avatar/ImageAvatar.java
@@ -0,0 +1,87 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.avatar;
+
+import java.util.Collection;
+
+import org.botlibre.Bot;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.emotion.EmotionalState;
+import org.botlibre.knowledge.ImageData;
+import org.botlibre.knowledge.Primitive;
+import org.botlibre.util.Utils;
+
+/**
+ * Controls and manages the thought processing.
+ */
+
+public class ImageAvatar extends BasicAvatar {
+ public static int MAX_UPLOAD_SIZE = 1000000; // 1meg
+
+ protected ImageData currentImage;
+
+ public ImageAvatar() {
+ }
+
+ @Override
+ public void awake() {
+ getBot().log(this, "Loading images", Bot.FINE);
+ Network memory = getBot().memory().newMemory();
+ Vertex avatar = memory.createVertex(Primitive.AVATAR);
+ Vertex image = avatar.mostConscious(new Primitive(EmotionalState.NONE.name().toLowerCase()));
+ if ((image != null) && (image.getData() instanceof ImageData)) {
+ this.currentImage = (ImageData)memory.findData((ImageData)image.getData());
+ }
+ }
+
+ /**
+ * Output the emotional state to the Avatar.
+ */
+ @Override
+ public void emote(EmotionalState state, Network memory) {
+ getBot().log(this, "Emote", Bot.FINE, state);
+ Vertex avatar = memory.createVertex(Primitive.AVATAR);
+ Collection images = avatar.getRelationships(state.primitive());
+ Vertex image = null;
+ if (images != null) {
+ image = Utils.random(images).getTarget();
+ } else {
+ getBot().log(this, "Missing image for emotion", Bot.FINE, state);
+ images = avatar.getRelationships(EmotionalState.NONE.primitive());
+ if (images != null) {
+ image = Utils.random(images).getTarget();
+ }
+ }
+ if ((image != null) && (image.getData() instanceof ImageData)) {
+ this.currentImage = (ImageData)memory.findData((ImageData)image.getData());
+ }
+ }
+
+ @Override
+ public ImageData getCurrentImage() {
+ return currentImage;
+ }
+
+ public void setCurrentImage(ImageData currentImage) {
+ this.currentImage = currentImage;
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/config.xml b/ai-engine/source/org/botlibre/config.xml
new file mode 100644
index 00000000..8c715146
--- /dev/null
+++ b/ai-engine/source/org/botlibre/config.xml
@@ -0,0 +1,112 @@
+
+
+
+ org.botlibre.knowledge.database.DatabaseMemory
+
+
+
+ org.botlibre.thought.BasicMind
+
+
+ org.botlibre.thought.consciousness.Consciousness
+
+
+
+ org.botlibre.thought.language.Language
+
+
+ org.botlibre.thought.language.Comprehension
+
+
+ org.botlibre.thought.discovery.Discovery
+
+
+ org.botlibre.thought.forgetfulness.Forgetfulness
+
+
+
+
+ org.botlibre.emotion.BasicMood
+
+
+ org.botlibre.emotion.Love
+
+
+ org.botlibre.emotion.Fear
+
+
+ org.botlibre.emotion.Surprise
+
+
+ org.botlibre.emotion.Happiness
+
+
+ org.botlibre.emotion.Anger
+
+
+ org.botlibre.emotion.Humor
+
+
+
+
+ org.botlibre.avatar.ImageAvatar
+
+
+ org.botlibre.sense.BasicAwareness
+
+
+ org.botlibre.sense.text.TextEntry
+
+
+ org.botlibre.sense.context.Context
+
+
+ org.botlibre.sense.http.Http
+
+
+ org.botlibre.sense.http.Wiktionary
+
+
+ org.botlibre.sense.http.Freebase
+
+
+ org.botlibre.sense.wikidata.Wikidata
+
+
+ org.botlibre.sense.service.RemoteService
+
+
+ org.botlibre.sense.chat.IRC
+
+
+ org.botlibre.sense.chat.Chat
+
+
+ org.botlibre.sense.email.Email
+
+
+ org.botlibre.sense.twitter.Twitter
+
+
+ org.botlibre.sense.twitter.TwitterDirectMessaging
+
+
+ org.botlibre.sense.facebook.Facebook
+
+
+ org.botlibre.sense.facebook.FacebookMessaging
+
+
+
+
+ org.botlibre.tool.Calculator
+
+
+ org.botlibre.tool.Watch
+
+
+ org.botlibre.tool.Utils
+
+
+
+
diff --git a/ai-engine/source/org/botlibre/config.xsd b/ai-engine/source/org/botlibre/config.xsd
new file mode 100644
index 00000000..2ef20ef2
--- /dev/null
+++ b/ai-engine/source/org/botlibre/config.xsd
@@ -0,0 +1,151 @@
+
+
+
+
+ Root element describing an bot instance
+
+
+
+
+
+ Element describing configuration of memory
+
+
+
+
+
+
+
+
+
+
+ Element describing configuration of mind
+
+
+
+
+
+
+
+ Sequence of thoughts
+
+
+
+
+
+ Element describing a thought
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Element describing configuration of mood
+
+
+
+
+
+
+
+ Sequence of emotions
+
+
+
+
+
+ Element describing an emotion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Element describing configuration of avatar
+
+
+
+
+
+
+
+
+
+
+ Element describing configuration of awareness
+
+
+
+
+
+
+
+ Sequence of senses
+
+
+
+
+
+ Element describing a sense
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sequence of senses
+
+
+
+
+
+ Element describing a tool
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ai-engine/source/org/botlibre/emotion/AbstractEmotion.java b/ai-engine/source/org/botlibre/emotion/AbstractEmotion.java
new file mode 100644
index 00000000..a4fc2f54
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/AbstractEmotion.java
@@ -0,0 +1,71 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+import java.util.Map;
+
+import org.botlibre.api.emotion.Emotion;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Defines a emotion.
+ * An emotion is a state defined by a magnitude that affects behavior.
+ */
+
+public abstract class AbstractEmotion implements Emotion {
+ protected float state;
+
+ @Override
+ public float getState() {
+ return state;
+ }
+
+ @Override
+ public void setState(float state) {
+ this.state = state;
+ }
+
+ @Override
+ public String getName() {
+ return getClass().getName();
+ }
+
+ @Override
+ public Primitive primitive() {
+ return new Primitive(getName());
+ }
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ return EmotionalState.NONE;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "(" + state + ")";
+ }
+
+ /**
+ * Initialize any configurable settings from the properties.
+ */
+ @Override
+ public void initialize(Map properties) {
+ return;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Anger.java b/ai-engine/source/org/botlibre/emotion/Anger.java
new file mode 100644
index 00000000..08b04912
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Anger.java
@@ -0,0 +1,40 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Anger represents the emotions from rage to tranquility.
+ */
+
+public class Anger extends AbstractEmotion {
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.6) {
+ return EmotionalState.SERENE;
+ } else if (level < -0.1) {
+ return EmotionalState.CALM;
+ } else if (level > 0.6) {
+ return EmotionalState.RAGE;
+ } else if (level > 0.1) {
+ return EmotionalState.ANGER;
+ }
+ return EmotionalState.NONE;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/BasicMood.java b/ai-engine/source/org/botlibre/emotion/BasicMood.java
new file mode 100644
index 00000000..ff9ad00a
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/BasicMood.java
@@ -0,0 +1,388 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.botlibre.Bot;
+import org.botlibre.api.emotion.Emotion;
+import org.botlibre.api.emotion.Mood;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * Controls and manages the thought processing.
+ */
+
+public class BasicMood implements Mood {
+
+ protected Bot bot;
+ protected boolean isEnabled = true;
+
+ /**
+ * Map of emotions.
+ */
+ protected Map emotions;
+
+ public BasicMood() {
+ this.emotions = new HashMap();
+ }
+
+ public void pool() {
+ for (Emotion emotion : this.emotions.values()) {
+ emotion.setState(0.0f);
+ }
+ }
+
+ public void saveProperties() {
+ Network memory = getBot().memory().newMemory();
+ Vertex vertex = memory.createVertex(getClass());
+ vertex.setRelationship(Primitive.ENABLED, memory.createVertex(isEnabled()));
+ vertex.pinChildren();
+ memory.save();
+ }
+
+ /**
+ * Log the message if the debug level is greater or equal to the level.
+ */
+ public void log(String message, Level level, Object... arguments) {
+ getBot().log(this, message, level, arguments);
+ }
+
+ /**
+ * Log the exception.
+ */
+ public void log(Throwable exception) {
+ getBot().log(this, exception);
+ }
+
+ /**
+ * Return Bot.
+ */
+ @Override
+ public Bot getBot() {
+ return bot;
+ }
+
+ /**
+ * Set Bot.
+ */
+ @Override
+ public void setBot(Bot bot) {
+ this.bot = bot;
+ }
+
+ /**
+ * Initialize any configurable settings from the properties.
+ */
+ @Override
+ public void initialize(Map properties) {
+ return;
+ }
+
+ @Override
+ public void shutdown() {
+ getBot().log(this, "Shutdown", Bot.FINE);
+ }
+
+ @Override
+ public void awake() {
+ getBot().log(this, "Awake", Bot.FINE);
+ Network memory = getBot().memory().newMemory();
+ Vertex language = memory.createVertex(getClass());
+ Vertex property = language.getRelationship(Primitive.ENABLED);
+ if (property != null) {
+ setEnabled((Boolean)property.getData());
+ }
+ }
+
+ @Override
+ public Map getEmotions() {
+ return emotions;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T getEmotion(Class type) {
+ return (T)getEmotions().get(type.getName());
+ }
+
+ @Override
+ public Emotion getEmotion(String name) {
+ return getEmotions().get(name);
+ }
+
+ @Override
+ public void addEmotion(Emotion emotion) {
+ getEmotions().put(emotion.getName(), emotion);
+ }
+
+ @Override
+ public void removeEmotion(Emotion emotion) {
+ getEmotions().remove(emotion.getName());
+ }
+
+ /**
+ * Evaluate the active memory input for emotional influence.
+ */
+ @Override
+ public void evaluate() {
+ if (!isEnabled()) {
+ return;
+ }
+ Network network = getBot().memory().getShortTermMemory();
+ List activeMemory = getBot().memory().getActiveMemory();
+ Iterator inputs = activeMemory.iterator();
+ while (inputs.hasNext()) {
+ // Must register into the current memory context.
+ Vertex input = network.createVertex(inputs.next());
+ Vertex source = input;
+ if (input.instanceOf(Primitive.INPUT)) {
+ // Let emotions simmer.
+ for (Emotion emotion : getEmotions().values()) {
+ emotion.setState(emotion.getState() / 2);
+ }
+ Collection emotions = input.getRelationships(Primitive.EMOTION);
+ Vertex sentence = input.getRelationship(Primitive.INPUT);
+ if ((emotions == null) && (sentence != null)) {
+ // Attempt to determine emotion from sentence.
+ emotions = sentence.getRelationships(Primitive.EMOTION);
+ if (emotions != null) {
+ source = sentence;
+ } else {
+ // Attempt to determine from words.
+ Collection words = sentence.getRelationships(Primitive.WORD);
+ if (words != null) {
+ for (Relationship word : words) {
+ if (word.getTarget().getRelationships(Primitive.EMOTION) != null) {
+ for (Emotion emotion : getEmotions().values()) {
+ Vertex emotionVertex = network.createVertex(emotion.primitive());
+ Relationship emotionRelation = word.getTarget().getRelationship(Primitive.EMOTION, emotionVertex);
+ if (emotionRelation != null) {
+ Relationship relationship = input.getRelationship(Primitive.EMOTION, emotionVertex);
+ if (relationship == null) {
+ relationship = input.addRelationship(Primitive.EMOTION, emotionVertex);
+ relationship.setCorrectness(emotionRelation.getCorrectness());
+ } else {
+ relationship.setCorrectness((relationship.getCorrectness() + emotionRelation.getCorrectness()) / 2);
+ }
+ }
+ }
+ }
+ }
+ emotions = input.getRelationships(Primitive.EMOTION);
+ }
+ }
+
+ }
+ if (emotions != null) {
+ // Increment or decrement each emotional state based on the input.
+ for (Emotion emotion : getEmotions().values()) {
+ Vertex emotionVertex = network.createVertex(emotion.primitive());
+ Relationship relationship = source.getRelationship(Primitive.EMOTION, emotionVertex);
+ if (relationship != null) {
+ try {
+ float value = relationship.getCorrectness();
+ emotion.setState(emotion.getState() + value);
+ log("Applying emotion", Level.FINE, emotion, value);
+ } catch (Exception error) {
+ getBot().log(this, error);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Evaluate the input response for emotional influence.
+ */
+ @Override
+ public void evaluateResponse(Vertex response, Vertex meta) {
+ if (!isEnabled()) {
+ return;
+ }
+ // Let emotions simmer.
+ for (Emotion emotion : getEmotions().values()) {
+ emotion.setState(emotion.getState() / 2);
+ }
+ Collection emotions = null;
+ if (meta != null) {
+ emotions = meta.getRelationships(Primitive.EMOTION);
+ }
+ if (emotions == null) {
+ emotions = response.getRelationships(Primitive.EMOTION);
+ }
+ if (emotions == null) {
+ // Attempt to determine from words.
+ Collection words = response.getRelationships(Primitive.WORD);
+ if (words != null) {
+ emotions = new ArrayList();
+ for (Relationship word : words) {
+ Collection wordEmotions = word.getTarget().getRelationships(Primitive.EMOTION);
+ if (wordEmotions != null) {
+ emotions.addAll(wordEmotions);
+ }
+ }
+ }
+ }
+ if (emotions != null) {
+ // Increment or decrement each emotional state based on the input.
+ for (Relationship relationship : emotions) {
+ Vertex emotionVertex = relationship.getTarget();
+ System.out.println(emotionVertex.getDataValue());
+ Emotion emotion = getEmotion(emotionVertex.getDataValue());
+ try {
+ float value = relationship.getCorrectness();
+ emotion.setState(emotion.getState() + value);
+ log("Applying emotion", Level.FINE, emotion, value);
+ } catch (Exception error) {
+ getBot().log(this, error);
+ }
+ }
+ }
+ }
+
+ /**
+ * Evaluate the output with emotional expression.
+ */
+ @Override
+ public void evaluateOutput(Vertex output) {
+ if (!isEnabled()) {
+ return;
+ }
+ for (Emotion emotion : getBot().mood().getEmotions().values()) {
+ if (Math.abs(emotion.getState()) > 0.1) {
+ Relationship relationship = output.addRelationship(Primitive.EMOTION, emotion.primitive());
+ relationship.setCorrectness(emotion.getState());
+ }
+ }
+ }
+
+ /**
+ * Determine the main emotional state of the output.
+ */
+ @Override
+ public EmotionalState currentEmotionalState() {
+ EmotionalState state = EmotionalState.NONE;
+ float max = 0;
+ float value = 0;
+ Emotion maxEmotion = null;
+ if (emotions != null) {
+ // Find the most relevant emotional state.
+ for (Emotion emotion : getEmotions().values()) {
+ if (Math.abs(emotion.getState()) > max) {
+ value = emotion.getState();
+ max = Math.abs(value);
+ maxEmotion = emotion;
+ }
+ }
+ }
+ if (max >= 0.3) {
+ state = maxEmotion.evaluate(value);
+ }
+ return state;
+ }
+
+ /**
+ * Determine the main emotional state of the output.
+ */
+ @Override
+ public EmotionalState evaluateEmotionalState(Vertex output) {
+ Collection emotions = output.getRelationships(Primitive.EMOTION);
+ EmotionalState state = EmotionalState.NONE;
+ float max = 0;
+ float value = 0;
+ Emotion maxEmotion = null;
+ if (emotions != null) {
+ // Find the most relevant emotional state.
+ for (Emotion emotion : getEmotions().values()) {
+ Relationship relationship = output.getRelationship(Primitive.EMOTION, emotion.primitive());
+ if ((relationship != null) && (Math.abs(relationship.getCorrectness()) > max)) {
+ value = relationship.getCorrectness();
+ max = Math.abs(value);
+ maxEmotion = emotion;
+ }
+ }
+ }
+ if (max >= 0.3) {
+ state = maxEmotion.evaluate(value);
+ }
+ return state;
+ }
+
+ /**
+ * Determine the emotional states of the output.
+ */
+ @Override
+ public List evaluateEmotionalStates(Vertex output) {
+ Collection emotions = output.getRelationships(Primitive.EMOTION);
+ List states = new ArrayList();
+ if (emotions != null) {
+ // Find the most relevant emotional state.
+ for (Emotion emotion : getEmotions().values()) {
+ Relationship relationship = output.getRelationship(Primitive.EMOTION, emotion.primitive());
+ if (relationship != null && Math.abs(relationship.getCorrectness()) >= 0.3) {
+ states.add(emotion.evaluate(relationship.getCorrectness()));
+ }
+ }
+ }
+ return states;
+ }
+
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public void setEnabled(boolean isEnabled) {
+ this.isEnabled = isEnabled;
+ }
+
+ /**
+ * Print a useful string representation of the mood.
+ */
+ @Override
+ public String toString() {
+ StringWriter writer = new StringWriter();
+ writer.write(getClass().getSimpleName());
+ writer.write("(");
+ boolean first = true;
+ for (Emotion emotion : getEmotions().values()) {
+ if (! first) {
+ writer.write(", ");
+ } else {
+ first = false;
+ }
+ writer.write(emotion.toString());
+ }
+ writer.write(")");
+ return writer.toString();
+ }
+
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/EmotionalState.java b/ai-engine/source/org/botlibre/emotion/EmotionalState.java
new file mode 100644
index 00000000..613f2c55
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/EmotionalState.java
@@ -0,0 +1,107 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.knowledge.Primitive;
+
+/**
+ * A convenience enum of different emotional states.
+ */
+
+public enum EmotionalState {
+ NONE,
+ LOVE, LIKE, DISLIKE, HATE,
+ RAGE, ANGER, CALM, SERENE,
+ ECSTATIC, HAPPY, SAD, CRYING,
+ PANIC, AFRAID, CONFIDENT, COURAGEOUS,
+ SURPRISE, BORED,
+ LAUGHTER, SERIOUS;
+
+ public Primitive primitive() {
+ return new Primitive(name().toLowerCase());
+ }
+
+ /**
+ * Apply the emotion to the vertex.
+ * Associate to the relevant emotion.
+ */
+ public void apply(Vertex vertex) {
+
+ if (this == EmotionalState.LOVE) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.LOVE);
+ vertex.addRelationship(Primitive.EMOTION, Primitive.LOVE);
+ } else if (this == EmotionalState.LIKE) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.LOVE);
+ } else if (this == EmotionalState.DISLIKE) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.LOVE);
+ } else if (this == EmotionalState.HATE) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.LOVE);
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.LOVE);
+ }
+
+ else if (this == EmotionalState.RAGE) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.ANGER);
+ vertex.addRelationship(Primitive.EMOTION, Primitive.ANGER);
+ } else if (this == EmotionalState.ANGER) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.ANGER);
+ } else if (this == EmotionalState.CALM) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.ANGER);
+ } else if (this == EmotionalState.SERENE) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.ANGER);
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.ANGER);
+ }
+
+ else if (this == EmotionalState.ECSTATIC) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ vertex.addRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ } else if (this == EmotionalState.HAPPY) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ } else if (this == EmotionalState.SAD) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ } else if (this == EmotionalState.CRYING) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.HAPPINESS);
+ }
+
+ else if (this == EmotionalState.PANIC) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.FEAR);
+ vertex.addRelationship(Primitive.EMOTION, Primitive.FEAR);
+ } else if (this == EmotionalState.AFRAID) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.FEAR);
+ } else if (this == EmotionalState.CONFIDENT) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.FEAR);
+ } else if (this == EmotionalState.COURAGEOUS) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.FEAR);
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.FEAR);
+ }
+
+ else if (this == EmotionalState.SURPRISE) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.SURPRISE);
+ } else if (this == EmotionalState.BORED) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.SURPRISE);
+ }
+
+ else if (this == EmotionalState.LAUGHTER) {
+ vertex.addRelationship(Primitive.EMOTION, Primitive.HUMOR);
+ } else if (this == EmotionalState.SERIOUS) {
+ vertex.removeRelationship(Primitive.EMOTION, Primitive.HUMOR);
+ }
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Fear.java b/ai-engine/source/org/botlibre/emotion/Fear.java
new file mode 100644
index 00000000..cb6ef5c0
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Fear.java
@@ -0,0 +1,41 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Fear represents the emotions from panic to confidence.
+ * Anxiety?
+ */
+
+public class Fear extends AbstractEmotion {
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.6) {
+ return EmotionalState.CONFIDENT;
+ } else if (level < -0.1) {
+ return EmotionalState.CONFIDENT;
+ } else if (level > 0.6) {
+ return EmotionalState.PANIC;
+ } else if (level > 0.1) {
+ return EmotionalState.AFRAID;
+ }
+ return EmotionalState.NONE;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Happiness.java b/ai-engine/source/org/botlibre/emotion/Happiness.java
new file mode 100644
index 00000000..c041e45d
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Happiness.java
@@ -0,0 +1,42 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Happiness represents the emotions from happy to sad.
+ */
+
+public class Happiness extends AbstractEmotion {
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.6) {
+ return EmotionalState.CRYING;
+ } else if (level < -0.1) {
+ return EmotionalState.SAD;
+ } else if (level > 0.6) {
+ return EmotionalState.ECSTATIC;
+ } else if (level > 0.1) {
+ return EmotionalState.HAPPY;
+ }
+ return EmotionalState.NONE;
+ }
+
+
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Humor.java b/ai-engine/source/org/botlibre/emotion/Humor.java
new file mode 100644
index 00000000..a799b65d
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Humor.java
@@ -0,0 +1,36 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Humor represents the emotions from laughter to serious.
+ */
+
+public class Humor extends AbstractEmotion {
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.1) {
+ return EmotionalState.SERIOUS;
+ } else if (level > 0.1) {
+ return EmotionalState.LAUGHTER;
+ }
+ return EmotionalState.NONE;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Love.java b/ai-engine/source/org/botlibre/emotion/Love.java
new file mode 100644
index 00000000..5af86f2e
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Love.java
@@ -0,0 +1,40 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Love represents the emotions from lust to hate.
+ */
+
+public class Love extends AbstractEmotion {
+
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.6) {
+ return EmotionalState.HATE;
+ } else if (level < -0.1) {
+ return EmotionalState.DISLIKE;
+ } else if (level > 0.6) {
+ return EmotionalState.LOVE;
+ } else if (level > 0.1) {
+ return EmotionalState.LIKE;
+ }
+ return EmotionalState.NONE;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/emotion/Surprise.java b/ai-engine/source/org/botlibre/emotion/Surprise.java
new file mode 100644
index 00000000..d7baa46a
--- /dev/null
+++ b/ai-engine/source/org/botlibre/emotion/Surprise.java
@@ -0,0 +1,35 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.emotion;
+
+/**
+ * Surprise represents the emotions from surprise to boredom.
+ */
+
+public class Surprise extends AbstractEmotion {
+ @Override
+ public EmotionalState evaluate(float level) {
+ if (level < -0.1) {
+ return EmotionalState.BORED;
+ } else if (level > 0.1) {
+ return EmotionalState.SURPRISE;
+ }
+ return EmotionalState.NONE;
+ }
+}
+
diff --git a/ai-engine/source/org/botlibre/knowledge/AbstractNetwork.java b/ai-engine/source/org/botlibre/knowledge/AbstractNetwork.java
new file mode 100644
index 00000000..9985996a
--- /dev/null
+++ b/ai-engine/source/org/botlibre/knowledge/AbstractNetwork.java
@@ -0,0 +1,1211 @@
+/******************************************************************************
+ *
+ * Copyright 2014 Paphus Solutions Inc.
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+package org.botlibre.knowledge;
+
+import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.botlibre.Bot;
+import org.botlibre.aiml.AIMLParser;
+import org.botlibre.api.knowledge.Network;
+import org.botlibre.api.knowledge.Relationship;
+import org.botlibre.api.knowledge.Vertex;
+import org.botlibre.self.SelfCompiler;
+import org.botlibre.sense.text.TextEntry;
+import org.botlibre.thought.language.Language;
+import org.botlibre.util.TextStream;
+import org.botlibre.util.Utils;
+
+
+/**
+ * An interconnected set of vertices,
+ * representing and knowledge-space.
+ * Basic implementation to allow subclasses to avoid defining some of the basic stuff.
+ */
+
+public abstract class AbstractNetwork implements Network, Cloneable {
+
+ /** Define max text size for data value. */
+ public static final int MAX_TEXT = 1000;
+
+ public static int MAX_SIZE = 500;
+
+ protected static long nextId = 0;
+
+ protected static long nextId() {
+ return nextId++;
+ }
+
+ protected boolean isShortTerm;
+
+ protected Map