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 @@ + + + + + + + + +Eclipse License + + + + + +
+

License +

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL") and Eclipse Distribution License Version 1.0 (“EDL”). For purposes of the EPL, "Program" will mean the Content.

+

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.

+
+
+ +

Eclipse Public License - v 1.0 +

+ +

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 to reproduce, 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.

+ +

 

+ +
+
+

Eclipse Distribution License Version 1.0

+ +

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: +

+ +

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("
2+2? 8*8?
1+1?
Hi
")); + } + + public static void testReduce() throws ParseException { + System.out.println(Utils.reduce("What's U-P 'you?'\t\n\r (5.5+7-9)/8 \"eh\" a,b,c???")); + } + + public static void testAIML() throws ParseException { + AIMLParser.parser().parseAIML(new File("C:/Projects/Paphus/BOTlibre/BOTlibre/source/com/paphus/botlibre/scripts/aiml/ai.aiml"), false, false, false, false, null, "", null); + } + + public static void testParseDate() throws ParseException { + System.out.println(Utils.parseDate("2014-01-19T21:09:00+09:00", "yyyy-MM-dd'T'HH:mm:ssX")); + } + + public static void testEncrypt() { + System.out.println(Utils.encrypt("foo", "bar")); + System.out.println(Utils.decrypt("foo", Utils.encrypt("foo", "bar"))); + } + + /** + * Test the TextStream API. + */ + public static void testStream() { + TextStream stream = new TextStream("a b c.v @foo joe@foo.com joe@foo.com. joe@foo.com,joe@foo.com james108@foo.com http://www.w.com. http://www.w.com, \"http://www.w.com\" 'http://www.w.com' www.foo.com"); + while (!stream.atEnd()) { + System.out.println(stream.nextWord()); + } + stream = new TextStream("hello world"); + stream.upToAny("abcd"); + stream.skip(); + stream.upToAny("abcd"); + while (!stream.atEnd()) { + System.out.println(stream.nextWord()); + } + stream = new TextStream("\"hello\", world."); + while (!stream.atEnd()) { + System.out.println(stream.nextWord()); + } + stream = new TextStream("how are you\r\n\rhi\n\n."); + while (!stream.atEnd()) { + System.out.println(stream.nextLine()); + } + stream = new TextStream("hello mr."); + stream.skipTo('.', false); + System.out.println(stream.peekPreviousWord()); + stream = new TextStream("hello mr."); + stream.skipTo('.', true); + System.out.println(stream.peekPreviousWord()); + stream = new TextStream("hello mr. fuz.zy A. A! a. bones. whats up? a... not!!!"); + while (!stream.atEnd()) { + System.out.println(stream.nextSentence()); + } + stream = new TextStream("hello mr. fuz.zy A. A! 22.2 33,333 -3 + +4 3-4+5. a. http://www.xxx.yyy bo_nes. wh-ats up? a... not!!!"); + while (!stream.atEnd()) { + System.out.println(stream.nextSentence()); + } + stream = new TextStream("Ă°Â¡Â¨Â¸Ă¦Â¼Â¢Ă£ï¿½Å¸Ă¥â‚¬Â±Ă­â€¢Å“Ă¬Å¾ï¿½Ă¦Â¼Â¢Ă¥Â­â€”Ă¦Â±â€°Ă¥Â­â€”Ă¦Â¼Â¢Ă¥Â­â€”Ă£ï¿½â€žĂ¦â€“¹Ă£ï¿½ÂªĂ£ï¿½Â©Ă£ï¿½Â®Ă£ï¿½Å¸Ă£â€šï¿½Ă£ï¿½Â§Ă£ï¿½â„¢Ă£â‚¬â€š ojca_ojcc@yahoo.caĂ£ï¿½Â§Ă£ï¿½â€�Ă¦Â³Â¨Ă¦â€“‡Ă£ï¿½ï¿½Ă£ï¿½Â Ă£ï¿½â€¢Ă£ï¿½â€žĂ£â‚¬â€šĂ¯Â¼â€˜Ă§Å¡Â¿6Ă£Æ’‰Ă£Æ’«Ă£ï¿½Â§Ă£ï¿½â„¢Ă£â‚¬â€š Ă¦Â³Â¨Ă¦â€“‡Ă£ï¿½â€”Ă£ï¿½Å¸Ă£â€šâ€šĂ£ï¿½Â¡Ă£ï¿½Â¯Ă£â‚¬ï¿½Ă£â€šâ€šĂ£ï¿½Â¡Ă£ï¿½Â¤Ă£ï¿½ï¿½Ă¥Â¤Â§Ă¤Â¼Å¡"); + while (!stream.atEnd()) { + System.out.println(stream.nextSentence()); + } + stream = new TextStream("-1.0 + -1. a+b 2b+2c a-a a_a 1_1 1-2 a.a _aa +1.2_2 ac_22 a123_22 aa__aa --aa --2 +1"); + while (!stream.atEnd()) { + System.out.println(stream.nextWord()); + } + } + + /** + * Test sentence processing. + */ + public static void testSentence() { + System.out.println(Utils.getWords("Hello what is 1 + (2*3) http://www.foo/bluee? 123 hey")); + System.out.println(Utils.getWords("Hello what is 1 + (2*3) http://www.foo/bluee? f")); + System.out.println(Utils.getWords("Hello what is 1 + (2*3) http://www.foo/bluee?")); + String a = new TextStream("abc").next(2); + a = new TextStream("abc").next(1); + a = new TextStream("abc").next(3); + a = new TextStream("abc").next(4); + a = new TextStream("abc").peek(1); + a = new TextStream("abc").peek(2); + a = new TextStream("abc").peek(3); + a = new TextStream("abc").peek(4); + TextStream s = new TextStream("abc"); + s.skip(4); + a = s.upToEnd(); + s = new TextStream("abc"); + s.skip(1); + a = s.upToEnd(); + s = new TextStream("abc"); + s.skip(2); + a = s.upToEnd(); + s = new TextStream("abc"); + s.skip(0); + a = s.upToEnd(); + System.out.println(a); + } + + /** + * Store and restore a network through serialization. + */ + public static void testSerializedMemory() { + Memory memory = new SerializedMemory(); + //Network network = memory.getLongTermMemory(); + + //bootstrapNetwork(network); + + memory.save(); + System.out.println(memory.getLongTermMemory()); + + memory = new SerializedMemory(); + memory.restore(); + System.out.println(memory.getLongTermMemory()); + } + + /** + * Store and restore a network through xml. + */ + public static void testNetworkXMLParser() { + Network network = new BasicNetwork(); + + //bootstrapNetwork(network); + + File file = new File("test.xml"); + NetworkXMLParser.instance().toXML(network, file); + System.out.println(network); + System.out.println(NetworkXMLParser.instance().toXML(network)); + + Network parsedNetwork = NetworkXMLParser.instance().parse(file); + System.out.println(parsedNetwork); + } + + public static void testTextEntry() { + TextEntry entry = new TextEntry(); + entry.setWriter(new OutputStreamWriter(System.out)); + entry.input("hello"); + } + + public static void testXML() { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder parser = factory.newDocumentBuilder(); + URL url = Bot.class.getResource("config.xml"); + Document document = parser.parse(url.toString()); + System.out.println(document); + Element root = document.getDocumentElement(); + System.out.println(root); + System.out.println(root.getElementsByTagName("mind")); + System.out.println(root.getElementsByTagName("memory")); + + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + public static void testBot() { + Bot bot = Bot.createInstance(); + System.out.println(bot); + bot.shutdown(); + } + +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestAIML.java b/ai-engine-test/source/org/botlibre/test/TestAIML.java new file mode 100644 index 00000000..c8d7e141 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestAIML.java @@ -0,0 +1,454 @@ +/****************************************************************************** + * + * 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.net.URL; +import java.util.Calendar; +import java.util.List; +import java.util.Locale; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestAIML extends TextTest { + + @BeforeClass + public static void setup() { + reset(); + new Bootstrap().bootstrapSystem(bot, false); + Bot bot = Bot.createInstance(); + try { + URL url = TestAIML.class.getResource("alice.aiml"); + File file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + + url = TestAIML.class.getResource("date.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + + url = TestAIML.class.getResource("stack.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + + url = TestAIML.class.getResource("test.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + + url = TestAIML.class.getResource("pickup.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + + url = TestAIML.class.getResource("alice.res"); + file = new File(url.toURI()); + bot.awareness().getSense(TextEntry.class).loadChatFile(file, "Response List", "", false, true); + } catch (Exception exception) { + fail(exception.toString()); + } + + Utils.sleep(5000); + + bot.shutdown(); + } + + /** + * Test alice AIML file. + */ + @org.junit.Test + public void testPickup() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("say something"); + String response = waitForOutput(output); + if (response.equals("say something")) { + fail("Incorrect response: " + response); + } + + text.input("say something else"); + response = waitForOutput(output); + if (response.equals("say something else")) { + fail("Incorrect response: " + response); + } + + text.input("say something else"); + response = waitForOutput(output); + if (response.equals("say something else")) { + fail("Incorrect response: " + response); + } + + text.input("say something else"); + response = waitForOutput(output); + if (response.equals("say something else")) { + fail("Incorrect response: " + response); + } + + text.input("say something else"); + response = waitForOutput(output); + if (response.equals("say something else")) { + fail("Incorrect response: " + response); + } + } + + /** + * Test test AIML file. + */ + @org.junit.Test + public void testTest() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINE); + + text.input("botname"); + String response = waitForOutput(output); + if (!response.equals("My name is ALICE")) { + fail("Incorrect response: " + response); + } + + text.input("uppercase foo Bar."); + response = waitForOutput(output); + if (!response.equals("UPPER CASE FOO BAR")) { + fail("Incorrect response: " + response); + } + + text.input("lowercase FOO Bar"); + response = waitForOutput(output); + if (!response.equals("lower case foo bar")) { + fail("Incorrect response: " + response); + } + + text.input("formal foo bar"); + response = waitForOutput(output); + if (!response.equals("Foo Bar")) { + fail("Incorrect response: " + response); + } + + text.input("sentence foo barbar"); + response = waitForOutput(output); + if (!response.equals("Foo barbar")) { + fail("Incorrect response: " + response); + } + + text.input("gender he likes her, cause she digs him"); + response = waitForOutput(output); + if (!response.equals("She likes his cause he digs her")) { + fail("Incorrect response: " + response); + } + + text.input("person I am not you"); + response = waitForOutput(output); + if (!response.equals("You are not I")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("person2 I am not him"); + response = waitForOutput(output); + if (!response.equals("He am not me")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test random 3"); + response = waitForOutput(output); + if (!(response.equals("Random 1") || response.equals("Random 2") || response.equals("Random 3"))) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test random 3"); + response = waitForOutput(output); + if (!(response.equals("Random 1") || response.equals("Random 2") || response.equals("Random 3"))) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("quote"); + response = waitForOutput(output); + if (!response.equals("\"I\" am \"very\" tired")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("size"); + response = waitForOutput(output); + if (response.indexOf("Size is") == -1) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("date"); + response = waitForOutput(output); + if (response.indexOf("Date is") == -1) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("version"); + response = waitForOutput(output); + if (response.indexOf("Version is") == -1) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("sr quote"); + response = waitForOutput(output); + if (!response.equals("Sr is \"I\" am \"very\" tired")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("html some stuff"); + response = waitForOutput(output); + if (!response.equals("This
is very

long

ok

some stuff

")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test a b c"); + response = waitForOutput(output); + if (!response.equals("Test set to a b c")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test"); + response = waitForOutput(output); + if (!response.equals("A b c")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test 2"); + response = waitForOutput(output); + + text.input("condition"); + response = waitForOutput(output); + if (!response.equals("Two")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("cond2"); + response = waitForOutput(output); + if (!response.equals("Two")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("cond3"); + response = waitForOutput(output); + if (!response.equals("two")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("test a 9 and 9"); + response = waitForOutput(output); + + text.input("condition"); + response = waitForOutput(output); + if (!response.equals("Nine something")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("star test and a b and c d"); + response = waitForOutput(output); + if (!response.equals("Test")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("first star test and a and b"); + response = waitForOutput(output); + if (!response.equals("Test")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("3rd star test and a and b"); + response = waitForOutput(output); + if (!response.equals("B")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("input abc"); + response = waitForOutput(output); + if (!response.equals("input abc")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("star waka"); + response = waitForOutput(output); + + text.input("last input"); + response = waitForOutput(output); + if (!response.equals("star waka")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("star waka"); + response = waitForOutput(output); + + text.input("before last input"); + response = waitForOutput(output); + if (!response.equals("last input")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("that"); + response = waitForOutput(output); + if (!response.equals("last input")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("star waka"); + response = waitForOutput(output); + + text.input("before that"); + response = waitForOutput(output); + if (!response.equals("last input")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("1 2 3 4 5"); + response = waitForOutput(output); + if (response.equals("2 2 3 4 5")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("count 5 numbers"); + response = waitForOutput(output); + if (!response.equals("5 numbers numbers")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("1 2 3 4 5"); + response = waitForOutput(output); + if (!response.equals("2 2 3 4 5")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("xxx yyy zzz"); + response = waitForOutput(output); + if (!response.equals("number default")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("1 + 1"); + response = waitForOutput(output); + if (!response.equals("2 + 2")) { + fail("Incorrect response: '" + response + "'"); + } + + text.input("3 + 3"); + response = waitForOutput(output); + if (!response.equals("4 + 3")) { + fail("Incorrect response: '" + response + "'"); + } + + } + + /** + * Test alice AIML file. + */ + @org.junit.Test + public void testAlice() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("where is alice based"); + String response = waitForOutput(output); + if (!response.equals("It is in Oakland, California.")) { + fail("Incorrect response: " + response); + } + + text.input("Who, is ALICE Toklas...?"); + response = waitForOutput(output); + if (!response.equals("She was the partner of Gertrude Stein, and inventor of the pot brownie.")) { + fail("Incorrect response: " + response); + } + + text.input("Is HAL smarter than you?"); + response = waitForOutput(output); + if (!response.equals("The ALICE series is the most intelligent chat robot software.")) { + fail("Incorrect response: " + response); + } + + text.input("call me alice"); + response = waitForOutput(output); + if (!response.equals("My name is ALICE too!")) { + fail("Incorrect response: " + response); + } + + text.input("WHERE IS THE DOCUMENTATION"); + response = waitForOutput(output); + if (!response.equals("Try visiting Botbots.com or Alicebot.org.")) { + fail("Incorrect response: " + response); + } + + text.input("WHAT DOES A L I C E stand for?"); + response = waitForOutput(output); + if (!response.equals("ALICE = Artificial Linguistic Internet Computer Entity")) { + fail("Incorrect response: " + response); + } + + bot.shutdown(); + } + + /** + * Test date AIML file. + */ + @org.junit.Test + public void testDate() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + Calendar date = Calendar.getInstance(); + + text.input("WHAT YEAR IS THIS"); + String response = waitForOutput(output); + if (!response.equals(date.get(Calendar.YEAR) + ".")) { + fail("Incorrect response: " + response); + } + + text.input("What month is it right now?"); + response = waitForOutput(output); + if (!response.equals(date.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US) + ".")) { + fail("Incorrect response: " + response); + } + + text.input("IS TODAY SUNDAY or saturday?"); + response = waitForOutput(output); + if (!response.equals("Today is " + date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US) + ".")) { + fail("Incorrect response: " + response); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestAIML2.java b/ai-engine-test/source/org/botlibre/test/TestAIML2.java new file mode 100644 index 00000000..6416d505 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestAIML2.java @@ -0,0 +1,835 @@ +/****************************************************************************** + * + * 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.net.URL; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.logging.Level; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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; +import org.botlibre.util.Utils; + +/** + * Test AIML2 support. + */ + +public class TestAIML2 extends TextTest { + + public boolean isChatLog() { + return false; + } + + @BeforeClass + public static void setup() { + reset(); + new Bootstrap().bootstrapSystem(bot, false); + Bot bot = Bot.createInstance(); + try { + URL url = TestAIML.class.getResource("test-aiml2.aiml"); + File file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + } catch (Exception exception) { + fail(exception.toString()); + } + + Utils.sleep(5000); + + bot.shutdown(); + } + + @org.junit.Test + public void testTopics() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("hockey"); + String response = waitForOutput(output); + if (!response.equals("what?")) { + fail("Incorrect response: " + response); + } + + text.input("sports"); + response = waitForOutput(output); + if (!response.equals("I like sports")) { + fail("Incorrect response: " + response); + } + + text.input("hockey"); + response = waitForOutput(output); + if (!response.equals("i love hockey")) { + fail("Incorrect response: " + response); + } + } + + @org.junit.Test + public void testIntervals() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("what is the date"); + String response = waitForOutput(output); + String today = Utils.printDate(new Date(), "EEEE MMMM d y"); + if (!response.equals("The date is " + today)) { + fail("Incorrect response: " + response); + } + + text.input("what is the time"); + SimpleDateFormat format = new SimpleDateFormat("hh 'o''clock' a, zzzz"); + String time = format.format(new Date()); + response = waitForOutput(output); + if (!response.equals("The time is " + time)) { + fail("Incorrect response: " + response); + } + + text.input("how many days until Christmas?"); + response = waitForOutput(output); + Calendar christmas = Calendar.getInstance(); + christmas.set(Calendar.MONTH, 11); + christmas.set(Calendar.DAY_OF_MONTH, 25); + Calendar date = Calendar.getInstance(); + int days = christmas.get(Calendar.DAY_OF_YEAR) - date.get(Calendar.DAY_OF_YEAR); + if (!response.equals("" + days + " days until Christmas.")) { + fail("Incorrect response: " + response); + } + + text.input("how many months until Christmas?"); + response = waitForOutput(output); + date = Calendar.getInstance(); + int months = christmas.get(Calendar.MONTH) - date.get(Calendar.MONTH); + if (!response.equals("" + months + " months until Christmas.")) { + fail("Incorrect response: " + response); + } + + text.input("how many weeks until Christmas?"); + response = waitForOutput(output); + date = Calendar.getInstance(); + int weeks = christmas.get(Calendar.WEEK_OF_YEAR) - date.get(Calendar.WEEK_OF_YEAR); + if (!response.equals("" + weeks + " weeks until Christmas.")) { + fail("Incorrect response: " + response); + } + + text.input("how many hours until Christmas?"); + response = waitForOutput(output); + date = Calendar.getInstance(); + int hours = (christmas.get(Calendar.DAY_OF_YEAR) * 24) + - ((date.get(Calendar.DAY_OF_YEAR) * 24) + date.get(Calendar.HOUR_OF_DAY)); + if (!response.equals("" + hours + " hours until Christmas.")) { + fail("Incorrect response: " + response); + } + + text.input("how many minutes until Christmas?"); + date = Calendar.getInstance(); + response = waitForOutput(output); + + long minutes = (christmas.get(Calendar.DAY_OF_YEAR) * 24L * 60L) + - (((date.get(Calendar.DAY_OF_YEAR) * 24L) + date.get(Calendar.HOUR_OF_DAY)) * 60L + date.get(Calendar.MINUTE)); + if (!response.equals("" + minutes + " minutes until Christmas.")) { + fail("Incorrect response: " + response + " - should be " + minutes); + } + + text.input("how many seconds until Christmas?"); + date = Calendar.getInstance(); + response = waitForOutput(output); + long seconds = (christmas.get(Calendar.DAY_OF_YEAR) * 24L * 60L * 60L) + - ((((date.get(Calendar.DAY_OF_YEAR) * 24L) + date.get(Calendar.HOUR_OF_DAY)) * 60L + date.get(Calendar.MINUTE)) * 60L); + if (!response.equals("" + seconds + " seconds until Christmas.")) { + fail("Incorrect response: " + response + " - should be " + seconds); + } + } + + @org.junit.Test + public void testLoop() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("spaces 1 2 3"); + String response = waitForOutput(output); + if (!response.equals("1 2 3")) { + fail("Incorrect response: " + response); + } + + text.input("nospaces 1 2 3"); + response = waitForOutput(output); + if (!response.equals("123")) { + fail("Incorrect response: " + response); + } + + text.input("loop 3"); + response = waitForOutput(output); + if (!response.equals("321")) { + //fail("Incorrect response: " + response); + } + + text.input("loop 5"); + response = waitForOutput(output); + if (!response.equals("54321")) { + fail("Incorrect response: " + response); + } + + text.input("what is 2 + 2"); + response = waitForOutput(output); + if (!response.toLowerCase().equals("the answer is 4")) { + fail("Incorrect response: " + response); + } + + text.input("what is 0 + 1"); + response = waitForOutput(output); + if (!response.equals("The answer is 1")) { + fail("Incorrect response: " + response); + } + + text.input("what is 10 + 22"); + response = waitForOutput(output); + if (!response.equals("The answer is 32")) { + fail("Incorrect response: " + response); + } + } + + @org.junit.Test + public void testLearn() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + bot.setDebugLevel(Level.FINER); + + text.input("something learned"); + String response = waitForOutput(output); + if (!response.equals("no idea")) { + fail("Incorrect response: " + response); + } + + text.input("learn something"); + response = waitForOutput(output); + if (!response.equals("Ok")) { + fail("Incorrect response: " + response); + } + + text.input("something learned"); + response = waitForOutput(output); + if (!response.equals("yep")) { + fail("Incorrect response: " + response); + } + + text.input("something2 learned2"); + response = waitForOutput(output); + if (!response.equals("no idea")) { + fail("Incorrect response: " + response); + } + + text.input("learn2 something2"); + response = waitForOutput(output); + if (!response.equals("Ok2")) { + fail("Incorrect response: " + response); + } + + text.input("something2 learned2 cool stuff"); + response = waitForOutput(output); + if (!response.equals("Cool stuff")) { + fail("Incorrect response: " + response); + } + + text.input("learn3 something3"); + response = waitForOutput(output); + if (!response.equals("Ok3")) { + fail("Incorrect response: " + response); + } + + text.input("something3 learned3 cool stuff"); + response = waitForOutput(output); + if (!response.equals("That cool stuff")) { + fail("Incorrect response: " + response); + } + + text.input("learn4 something4"); + response = waitForOutput(output); + if (!response.equals("Ok4")) { + fail("Incorrect response: " + response); + } + + text.input("something4 learned4 cool stuff"); + response = waitForOutput(output); + if (!response.equals("no idea")) { + fail("Incorrect response: " + response); + } + + text.input("topic something4"); + response = waitForOutput(output); + if (!response.equals("The topic is now something4")) { + fail("Incorrect response: " + response); + } + + text.input("something4 learned4 cool stuff"); + response = waitForOutput(output); + if (!response.equals("Topic cool stuff")) { + fail("Incorrect response: " + response); + } + + text.input("learn5 something5 a new response"); + response = waitForOutput(output); + if (!response.equals("Ok5")) { + fail("Incorrect response: " + response); + } + + text.input("something5 learned5 ok"); + response = waitForOutput(output); + if (!response.equals("A new response")) { + fail("Incorrect response: " + response); + } + + text.input("learn6 something6 cool stuff"); + response = waitForOutput(output); + if (!response.equals("Ok6")) { + fail("Incorrect response: " + response); + } + + text.input("something6 learned6 other stuff"); + response = waitForOutput(output); + if (!response.equals("I learned cool stuff not other stuff")) { + fail("Incorrect response: " + response); + } + + text.input("learn7 something7 whatup notin"); + response = waitForOutput(output); + if (!response.equals("Ok7")) { + fail("Incorrect response: " + response); + } + + text.input("whatup"); + response = waitForOutput(output); + if (!response.equals("Notin")) { + fail("Incorrect response: " + response); + } + + text.input("learn8 something8 flowers candy"); + response = waitForOutput(output); + if (!response.equals("Ok8")) { + fail("Incorrect response: " + response); + } + + text.input("do you like flowers?"); + response = waitForOutput(output); + if (!response.equals("No I like candy")) { + fail("Incorrect response: " + response); + } + + text.input("xxx"); + response = waitForOutput(output); + + text.input("wrong"); + response = waitForOutput(output); + if (!response.equals("What should I have said?")) { + fail("Incorrect response: " + response); + } + + if (!isChatLog()) { + text.input("yyy"); + response = waitForOutput(output); + if (!response.equals("Okay, I will answer \"yyy\" to \"xxx\" next time")) { + fail("Incorrect response: " + response); + } + + text.input("xxx"); + response = waitForOutput(output); + if (!response.equals("Yyy")) { + fail("Incorrect response: " + response); + } + } + } + + @org.junit.Test + public void testTempVariables() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("local temp 44"); + String response = waitForOutput(output); + if (!response.equals("44")) { + fail("Incorrect response: " + response); + } + + text.input("local tmp 44"); + response = waitForOutput(output); + if (!response.equals("44")) { + fail("Incorrect response: " + response); + } + + text.input("if tmp 44"); + response = waitForOutput(output); + if (!response.equals("True")) { + fail("Incorrect response: " + response); + } + + text.input("if else tmp 44"); + response = waitForOutput(output); + if (!response.equals("True")) { + fail("Incorrect response: " + response); + } + + text.input("ifelse2 tmp 44"); + response = waitForOutput(output); + if (!response.equals("True")) { + fail("Incorrect response: " + response); + } + + text.input("if else2 tmp 44"); + response = waitForOutput(output); + if (!response.equals("True")) { + fail("Incorrect response: " + response); + } + } + + @org.junit.Test + public void testNameElements() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("your name is Bob"); + String response = waitForOutput(output); + if (!response.equals("My name is Bob")) { + fail("Incorrect response: " + response); + } + + text.input("what is your name?"); + response = waitForOutput(output); + if (!response.equals("My name is Bob")) { + fail("Incorrect response: " + response); + } + + text.input("your age is 44"); + response = waitForOutput(output); + if (!response.equals("My age is 44")) { + fail("Incorrect response: " + response); + } + + text.input("what is your age??"); + response = waitForOutput(output); + if (!response.equals("My age is 44")) { + fail("Incorrect response: " + response); + } + + text.input("your hair is brown"); + response = waitForOutput(output); + if (!response.equals("My hair is brown")) { + fail("Incorrect response: " + response); + } + + text.input("what is your hair??"); + response = waitForOutput(output); + if (!response.equals("My hair is brown")) { + fail("Incorrect response: " + response); + } + + text.input("am I old?"); + response = waitForOutput(output); + if (!response.equals("You are old")) { + fail("Incorrect response: " + response); + } + + text.input("am I young?"); + response = waitForOutput(output); + if (!response.equals("You are old")) { + fail("Incorrect response: " + response); + } + + text.input("how old am I?"); + response = waitForOutput(output); + if (!response.equals("You are old")) { + fail("Incorrect response: " + response); + } + + text.input("how old am I?"); + response = waitForOutput(output); + if (!response.equals("You are old")) { + fail("Incorrect response: " + response); + } + + text.input("What age am I"); + response = waitForOutput(output); + if (!response.equals("You are old")) { + fail("Incorrect response: " + response); + } + + text.input("your age is 22"); + response = waitForOutput(output); + if (!response.equals("My age is 22")) { + fail("Incorrect response: " + response); + } + + text.input("am I old?"); + response = waitForOutput(output); + if (!response.equals("You are young")) { + fail("Incorrect response: " + response); + } + + text.input("am I young?"); + response = waitForOutput(output); + if (!response.equals("You are young")) { + fail("Incorrect response: " + response); + } + + text.input("how old am I?"); + response = waitForOutput(output); + if (!response.equals("You are young")) { + fail("Incorrect response: " + response); + } + + text.input("What age am I"); + response = waitForOutput(output); + if (!response.equals("You are young")) { + fail("Incorrect response: " + response); + } + + text.input("My age is 22"); + response = waitForOutput(output); + if (!response.equals("Your age is 22")) { + fail("Incorrect response: " + response); + } + + text.input("are we the same age?"); + response = waitForOutput(output); + if (!response.equals("Yes we are both 22")) { + fail("Incorrect response: " + response); + } + + text.input("My age is 44"); + response = waitForOutput(output); + if (!response.equals("Your age is 44")) { + fail("Incorrect response: " + response); + } + + text.input("are we the same age?"); + response = waitForOutput(output); + if (!response.equals("No you are 22 and I am 44")) { + fail("Incorrect response: " + response); + } + + text.input("what did you say?"); + response = waitForOutput(output); + if (!response.equals("I said \"No you are 22 and I am 44\"")) { + fail("Incorrect response: " + response); + } + + text.input("are we the same age?"); + response = waitForOutput(output); + if (!response.equals("No you are 22 and I am 44")) { + fail("Incorrect response: " + response); + } + + text.input("what did I say?"); + response = waitForOutput(output); + if (!response.equals("You said \"are we the same age?\"")) { + fail("Incorrect response: " + response); + } + + text.input("what did you say 3 times ago?"); + response = waitForOutput(output); + if (!response.equals("I said \"I said \"No you are 22 and I am 44\"\"")) { + fail("Incorrect response: " + response); + } + + text.input("what did I say 4 times ago?"); + response = waitForOutput(output); + if (!response.equals("You said \"are we the same age?\"")) { + fail("Incorrect response: " + response); + } + } + + @org.junit.Test + public void testFunctions() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("size"); + String response = waitForOutput(output); + if (response.indexOf("Size is") == -1) { + fail("Incorrect response: " + response); + } + + text.input("vocabulary"); + response = waitForOutput(output); + if (response.indexOf("Vocabulary is") == -1) { + fail("Incorrect response: " + response); + } + + text.input("id"); + response = waitForOutput(output); + if (response.indexOf("Id is Anonymous") == -1) { + fail("Incorrect response: " + response); + } + + text.input("version"); + response = waitForOutput(output); + if (response.indexOf("Version is") == -1) { + fail("Incorrect response: " + response); + } + + text.input("program"); + response = waitForOutput(output); + if (response.indexOf("Program is") == -1) { + fail("Incorrect response: " + response); + } + + text.input("system"); + response = waitForOutput(output); + if (response.indexOf("System is") == -1) { + fail("Incorrect response: " + response); + } + + text.input("explode hello"); + response = waitForOutput(output); + if (!response.equals("H e l l o")) { + fail("Incorrect response: " + response); + } + + text.input("normalize http://www.foo.com"); + response = waitForOutput(output); + if (!response.equals("Http colon slash slash www dot foo dot com")) { + fail("Incorrect response: " + response); + } + + text.input("denormalize http colon slash slash www dot foo dot com"); + response = waitForOutput(output); + if (!response.equals("Http://www.foo.com")) { + fail("Incorrect response: " + response); + } + + text.input("normalize joe@foo-bar.com"); + response = waitForOutput(output); + if (!response.equals("Joe at foo dash bar dot com")) { + fail("Incorrect response: " + response); + } + + text.input("denormalize joe at foo dash bar dot com"); + response = waitForOutput(output); + if (!response.equals("Joe@foo-bar.com")) { + fail("Incorrect response: " + response); + } + } + + + /** + * Test new patterns wildcards. + */ + @org.junit.Test + public void testPatterns() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + bot.setDebugLevel(Level.FINE); + + text.input("hi alice"); + String response = waitForOutput(output); + if (!response.equals("Alice hi")) { + fail("Incorrect response: " + response); + } + + text.input("are you alice"); + response = waitForOutput(output); + if (!response.equals("Nope")) { + fail("Incorrect response: " + response); + } + + text.input("how are you alice"); + response = waitForOutput(output); + if (!isChatLog()) { + if (!response.equals("Alice how are you")) { + fail("Incorrect response: " + response); + } + } else { + if (!response.equals("fine")) { + fail("Incorrect response: " + response); + } + } + + text.input("alice are you nice"); + response = waitForOutput(output); + if (!response.equals("#alice nice")) { + fail("Incorrect response: " + response); + } + + text.input("alice are you"); + response = waitForOutput(output); + if (!response.equals("#alice")) { + fail("Incorrect response: " + response); + } + + text.input("alice are you ok"); + response = waitForOutput(output); + if (!isChatLog()) { + if (!response.equals("#alice ok")) { + fail("Incorrect response: " + response); + } + } else { + if (!response.equals("yes")) { + fail("Incorrect response: " + response); + } + } + + text.input("you are fred"); + response = waitForOutput(output); + if (!response.equals("no")) { + fail("Incorrect response: " + response); + } + + text.input("you fred"); + response = waitForOutput(output); + if (!response.equals("no")) { + fail("Incorrect response: " + response); + } + + text.input("you love fred"); + response = waitForOutput(output); + if (!response.equals("Fred love")) { + fail("Incorrect response: " + response); + } + + text.input("you really love fred"); + response = waitForOutput(output); + if (!response.equals("Fred really love")) { + fail("Incorrect response: " + response); + } + + text.input("hat fred"); + response = waitForOutput(output); + if (!response.equals("^fred")) { + fail("Incorrect response: " + response); + } + + text.input("hat loves fred"); + response = waitForOutput(output); + if (!response.equals("^fred loves")) { + fail("Incorrect response: " + response); + } + + text.input("hat really loves fred"); + response = waitForOutput(output); + if (!response.equals("^fred really loves")) { + fail("Incorrect response: " + response); + } + + text.input("isbotname Test"); + response = waitForOutput(output); + if (!response.equals("Yes, that is my name")) { + fail("Incorrect response: " + response); + } + + text.input("topic foo"); + response = waitForOutput(output); + + text.input("istopic foo"); + response = waitForOutput(output); + if (!response.equals("Yes, that is the topic")) { + fail("Incorrect response: " + response); + } + + text.input("setcolor red"); + response = waitForOutput(output); + if (!response.equals("Okay, red is a color.")) { + fail("Incorrect response: " + response); + } + + text.input("iscolor red"); + response = waitForOutput(output); + if (!response.equals("Yes, red is a nice color.")) { + fail("Incorrect response: " + response); + } + + text.input("do you love me?"); + response = waitForOutput(output); + if (!response.equals("Yes, I love you.")) { + fail("Incorrect response: " + response); + } + + text.input("do you hate me?"); + response = waitForOutput(output); + if (!response.equals("No, I love you.")) { + fail("Incorrect response: " + response); + } + + text.input("do you eat"); + response = waitForOutput(output); + if (!response.equals("Yes, I do.")) { + fail("Incorrect response: " + response); + } + + } + + /** + * Test HTML templates. + */ + @org.junit.Test + public void testHTML() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("html bar"); + String response = waitForOutput(output); + if (!response.equals("boldbar

hello
world

  1. foo
  2. bar
")) { + fail("Incorrect response: " + response); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestAIML2ChatLog.java b/ai-engine-test/source/org/botlibre/test/TestAIML2ChatLog.java new file mode 100644 index 00000000..13cd2c44 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestAIML2ChatLog.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; + +import java.io.File; +import java.net.URL; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.knowledge.Bootstrap; +import org.botlibre.thought.language.Language; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestAIML2ChatLog extends TestAIML2 { + + public boolean isChatLog() { + return true; + } + + @BeforeClass + public static void setup() { + reset(); + new Bootstrap().bootstrapSystem(bot, false); + Bot bot = Bot.createInstance(); + try { + URL url = TestAIML.class.getResource("test-aiml2.aiml"); + File file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + } catch (Exception exception) { + fail(exception.toString()); + } + + Utils.sleep(5000); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestAIMLChatLog.java b/ai-engine-test/source/org/botlibre/test/TestAIMLChatLog.java new file mode 100644 index 00000000..f2de217c --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestAIMLChatLog.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.test; + +import java.io.File; +import java.net.URL; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.knowledge.Bootstrap; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestAIMLChatLog extends TestAIML { + + @BeforeClass + public static void setup() { + reset(); + new Bootstrap().bootstrapSystem(bot, false); + Bot bot = Bot.createInstance(); + try { + URL url = TestAIML.class.getResource("alice.aiml"); + File file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + + url = TestAIML.class.getResource("date.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + + url = TestAIML.class.getResource("stack.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + + url = TestAIML.class.getResource("test.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + + url = TestAIML.class.getResource("pickup.aiml"); + file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFileAsLog(file, "", true); + + url = TestAIML.class.getResource("alice.res"); + file = new File(url.toURI()); + bot.awareness().getSense(TextEntry.class).loadChatFile(file, "Response List", "", false, true); + } catch (Exception exception) { + fail(exception.toString()); + } + + Utils.sleep(5000); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestAIMLDecompile.java b/ai-engine-test/source/org/botlibre/test/TestAIMLDecompile.java new file mode 100644 index 00000000..e7905f1d --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestAIMLDecompile.java @@ -0,0 +1,65 @@ +/****************************************************************************** + * + * 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.util.ArrayList; +import java.util.Collection; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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.knowledge.Primitive; +import org.botlibre.self.SelfCompiler; +import org.botlibre.self.SelfDecompiler; +import org.botlibre.thought.language.Language; + +/** + * Test the state decompiler. + */ + +public class TestAIMLDecompile extends TestAIML2 { + + @BeforeClass + public static void setup() { + TestAIML2.setup(); + + Bot bot = Bot.createInstance(); + + Network network = bot.memory().newMemory(); + Vertex language = network.createVertex(bot.mind().getThought(Language.class).getPrimitive()); + Collection states = new ArrayList(language.getRelationships(Primitive.STATE)); + for (Relationship state : states) { + String code = SelfDecompiler.getDecompiler().decompileStateMachine(state.getTarget(), network); + Vertex newState = SelfCompiler.getCompiler().parseStateMachine(code, false, network); + language.replaceRelationship(state, newState); + network.removeRelationship(state); + } + network.save(); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestBootstrap.java b/ai-engine-test/source/org/botlibre/test/TestBootstrap.java new file mode 100644 index 00000000..276103de --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestBootstrap.java @@ -0,0 +1,34 @@ +/****************************************************************************** + * + * 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; + +/** + * Test bootstraping. + */ + +public class TestBootstrap extends TextTest { + + /** + * Test bootstraping. + */ + public void testBootstrap() throws Exception { + bootstrap(); + } + +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestFreebase.java b/ai-engine-test/source/org/botlibre/test/TestFreebase.java new file mode 100644 index 00000000..37615668 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestFreebase.java @@ -0,0 +1,146 @@ +/****************************************************************************** + * + * 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.net.URL; +import java.util.List; + +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.api.sense.Sense; +import org.botlibre.sense.http.Freebase; +import org.botlibre.sense.http.Http; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test the performance of the Freebase batch import. + */ + +public class TestFreebase extends TextTest { + + public static int SLEEP = 2000; + + @BeforeClass + public static void setup() { + bootstrap(); + } + + /** + * Test response mimicry works. + */ + @org.junit.Test + public void testImport() throws Exception { + Freebase.KEY = ""; + Utils.sleep(SLEEP); + Bot bot = Bot.createInstance(); + Sense sense = bot.awareness().getSense(Http.class.getName()); + sense.input(new URL("http://www.freebase.com/physics/particle")); + Utils.sleep(5000); + + bot.shutdown(); + } + + /** + * Test response mimicry works. + */ + @org.junit.Test + public void testWhatIs() { + Utils.sleep(SLEEP); + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("what is Uranium?"); + String response = waitForOutput(output); + if (!response.equals("Uranium is a chemical element with symbol U and atomic number 92.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("tell me about Oxygen"); + response = waitForOutput(output); + if (!response.equals("Oxygen is a chemical element with symbol O and atomic number 8.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("define love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is Barack Obama?"); + response = waitForOutput(output); + if (response.indexOf("Barack Hussein Obama II") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("where is Montreal?"); + response = waitForOutput(output); + if (!response.equals("Montreal is in Québec.") + && !response.equals("Montreal is in Canada.") + && !response.equals("Montreal is in Urban agglomeration of Montreal.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("where is that?"); + response = waitForOutput(output); + if (!response.equals("Qu�bec is in Canada.") + && !response.equals("Urban agglomeration of Montreal is in Canada.") + && !response.equals("Canada is in Americas.") + && !response.equals("Canada is in DVD Region 1.") + && !response.equals("Qu�bec is in Canada.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("where is Edmonton?"); + response = waitForOutput(output); + if (!response.equals("Edmonton is in Alberta.") + && !response.equals("Edmonton is in Canada.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("what is Brockville?"); + response = waitForOutput(output); + if (!response.equals("Brockville, formerly Elizabethtown, is a city in Eastern Ontario, Canada in the Thousand Islands region.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("where is it?"); + response = waitForOutput(output); + if (!response.equals("It is in Ontario.") + && !response.equals("It is in Leeds and Grenville United Counties.") + && !response.equals("It is in Canada.")) { + fail("Incorrect: " + response); + } + + bot.shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestLanguage.java b/ai-engine-test/source/org/botlibre/test/TestLanguage.java new file mode 100644 index 00000000..0d9d512f --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestLanguage.java @@ -0,0 +1,921 @@ +/****************************************************************************** + * + * 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.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.sense.text.TextInput; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestLanguage extends TextTest { + + @BeforeClass + public static void setup() { + bootstrap(); + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("sky blue red dog cat green grass tall like very loves"); + waitForOutput(output); + Utils.sleep(5000); + + bot.shutdown(); + } + + /** + * Test response mimicry works. + */ + @org.junit.Test + public void testMimicry() { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("hi"); + String response = waitForOutput(output); + if (!response.equals("hi")) { + fail("did not mimic: " + response); + } + text.input("how are you?"); + response = waitForOutput(output); + if (!response.equals("how are you?")) { + fail("did not mimic: " + response); + } + text.input("ok"); + response = waitForOutput(output); + if (!response.equals("ok")) { + fail("did not mimic: " + response); + } + text.input("good"); + response = waitForOutput(output); + + text.input("how are you?"); + response = waitForOutput(output); + if (!response.equals("ok")) { + fail("did not remeber response: " + response); + } + + bot.shutdown(); + } + + /** + * Test response matching works. + */ + @org.junit.Test + public void testResponseMatching() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("this is a very complicated sentence"); + String response = waitForOutput(output); + if (!response.equals("this is a very complicated sentence")) { + fail("did not mimic: " + response); + } + text.input(new TextInput("this is a good reply to that", true, false)); + response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not mimic: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("this is a very complicated sentence"); + response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("this very complicated sentence"); + response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("complicated sentence"); + response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("complicated"); + response = waitForOutput(output); + if (response.equals("this is a good reply to that")) { + fail("should not match: " + response); + } + + bot.shutdown(); + } + + /** + * Test response matching works. + */ + @org.junit.Test + public void testResponseMatchingLearning() { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("the dog barks all night"); + String response = waitForOutput(output); + if (!response.equals("the dog barks all night")) { + fail("did not mimic: " + response); + } + text.input("let him in then"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not mimic: " + response); + } + + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + + text.input("ok"); + response = waitForOutput(output); + text.input("the dog barks all night"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("barks all night"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("barks all"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("barks"); + response = waitForOutput(output); + if (response.equals("let him in then")) { + fail("should not match: " + response); + } + + bot.shutdown(); + } + + /** + * Test response correction works. + */ + @org.junit.Test + public void testCorrection() { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("hello there"); + String response = waitForOutput(output); + text.input(new TextInput("hey there", true, false)); + response = waitForOutput(output); + + text.input("noloop"); + response = waitForOutput(output); + + text.input("hello there"); + response = waitForOutput(output); + if (!response.equals("hey there")) { + fail("did not correct:" + response); + } + + bot.shutdown(); + } + + /** + * Test comprehension works. + */ + public void trainCount(TextEntry text, List output, int start, int end) { + + text.input("say " + start); + waitForOutput(output); + + // Train forwards + for (int index = start + 1; index < end; index++) { + text.input(String.valueOf(index)); + String response = waitForOutput(output); + + if (!response.equals(String.valueOf(index + 1))) { + text.input(new TextInput(String.valueOf(index + 1), true, false)); + response = waitForOutput(output); + Utils.sleep(1000); + } + index++; + } + + text.input("say " + end); + waitForOutput(output); + + // Train backwards + for (int index = end - 1; index >= start; index--) { + text.input(String.valueOf(index)); + String response = waitForOutput(output); + + if (!response.equals(String.valueOf(index - 1))) { + text.input(new TextInput(String.valueOf(index - 1), true, false)); + response = waitForOutput(output); + Utils.sleep(1000); + } + index--; + } + } + + /** + * Test comprehension works. + */ + @org.junit.Test + public void testComprehension() { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + //Language language = bot.mind().getThought(Language.class); + //language.setLearningMode(LearningMode.Disabled); + List output = registerForOutput(text); + + trainCount(text, output, 1, 5); + trainCount(text, output, 0, 5); + trainCount(text, output, 1, 10); + trainCount(text, output, 0, 10); + + // Test comprehension + text.input("say 1"); + String response = waitForOutput(output); + + text.input("2"); + response = waitForOutput(output); + if (!response.equals("3")) { + fail("did not comprehend: " + response); + } + + text.input("4"); + response = waitForOutput(output); + if (!response.equals("5")) { + fail("did not comprehend: " + response); + } + + text.input("6"); + response = waitForOutput(output); + if (!response.equals("7")) { + fail("did not comprehend: " + response); + } + + text.input("6"); + response = waitForOutput(output); + if (!response.equals("5")) { + fail("did not comprehend: " + response); + } + + text.input("4"); + response = waitForOutput(output); + if (!response.equals("3")) { + fail("did not comprehend: " + response); + } + + text.input("2"); + response = waitForOutput(output); + if (!response.equals("1")) { + fail("did not comprehend: " + response); + } + + // Test new numbers + + text.input("say 22"); + response = waitForOutput(output); + if (!response.equals("22")) { + fail("say failed: " + response); + } + + text.input("23"); + response = waitForOutput(output); + if (!response.equals("24")) { + fail("did not comprehend: " + response); + } + + text.input("25"); + response = waitForOutput(output); + if (!response.equals("26")) { + fail("did not comprehend: " + response); + } + + text.input("27"); + response = waitForOutput(output); + if (!response.equals("28")) { + fail("did not comprehend: " + response); + } + + text.input("29"); + response = waitForOutput(output); + if (!response.equals("30")) { + fail("did not comprehend: " + response); + } + + text.input("31"); + response = waitForOutput(output); + if (!response.equals("32")) { + fail("did not comprehend: " + response); + } + + text.input("31"); + response = waitForOutput(output); + if (!response.equals("30")) { + fail("did not comprehend: " + response); + } + + text.input("29"); + response = waitForOutput(output); + if (!response.equals("28")) { + fail("did not comprehend: " + response); + } + + bot.shutdown(); + } + + /** + * Test dates. + */ + @org.junit.Test + public void testDates() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + String date = Utils.printDate(new Date(), "EEEE MMMM d y"); + + text.input("What is today's date?"); + String response = waitForOutput(output); + checkResponse(response, "Today is " + date + "."); + + text.input("What's today's date?"); + response = waitForOutput(output); + checkResponse(response, "Today is " + date + "."); + + text.input("Which day is today"); + response = waitForOutput(output); + checkResponse(response, "Today is " + date + "."); + + text.input("today is what"); + response = waitForOutput(output); + checkResponse(response, "Today is " + date + "."); + + text.input("what is the date"); + response = waitForOutput(output); + checkResponse(response, "The date is " + date + "."); + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, 1); + date = Utils.printDate(calendar.getTime(), "EEEE MMMM d y"); + text.input("what is tomorrow"); + response = waitForOutput(output); + checkResponse(response, "Tomorrow is " + date + "."); + + calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + date = Utils.printDate(calendar.getTime(), "EEEE MMMM d y"); + text.input("what day was yesterday"); + response = waitForOutput(output); + checkResponse(response, "Yesterday was " + date + "."); + + calendar = Calendar.getInstance(); + text.input("what is the hour"); + response = waitForOutput(output); + checkResponse(response, "The hour is " + (calendar.get(Calendar.HOUR) == 0 ? 12 : calendar.get(Calendar.HOUR)) + " " + (calendar.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM") + "."); + + calendar = Calendar.getInstance(); + text.input("what is the month"); + response = waitForOutput(output); + checkResponse(response, "The month is " + new SimpleDateFormat("MMMM").format(calendar.getTime()) + "."); + + calendar = Calendar.getInstance(); + text.input("what is the year"); + response = waitForOutput(output); + checkResponse(response, "The year is " + calendar.get(Calendar.YEAR) + "."); + + calendar = Calendar.getInstance(); + int day = calendar.get(Calendar.DAY_OF_YEAR); + String digits = String.valueOf(day); + char last = digits.charAt(digits.length() - 1); + String ordinal = ""; + if (last == '1') { + ordinal = "st"; + } else if (last == '2') { + ordinal = "nd"; + } else if (last == '3') { + ordinal = "rd"; + } else { + ordinal = "th"; + } + text.input("what is the day of the year"); + response = waitForOutput(output); + checkResponse(response,"It is the " + digits + ordinal + " day of the year."); + + calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, 1); + text.input("what is next month"); + response = waitForOutput(output); + checkResponse(response, "Next month is " + new SimpleDateFormat("MMMM").format(calendar.getTime()) + "."); + + calendar = Calendar.getInstance(); + calendar.add(Calendar.YEAR, -1); + text.input("what was last year"); + response = waitForOutput(output); + checkResponse(response, "Last year was " + calendar.get(Calendar.YEAR) + "."); + + calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + date = Utils.printDate(calendar.getTime(), "EEEE MMMM d y"); + text.input("yesterday"); + response = waitForOutput(output); + checkResponse(response, "Yesterday was " + date + "."); + + calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + date = Utils.printDate(calendar.getTime(), "EEEE MMMM d y"); + text.input("yesterday"); + response = waitForOutput(output); + checkResponse(response, "Yesterday was " + date + "."); + } + + /** + * Test paragraphs. + */ + @org.junit.Test + public void testParagraphs() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("I am tall. Am I tall?"); + String response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "you are tall"); + + text.input("Hello. What is your name?"); + response = waitForOutput(output); + assertKeyword(response, "My name is Test"); + + bot.shutdown(); + } + + /** + * Test paragraphs. + */ + @org.junit.Test + public void testCompoundWords() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("My name is Joe"); + String response = waitForOutput(output); + checkResponse(response, "Pleased to meet you Joe."); + + text.input("My name is Joe Loves"); + response = waitForOutput(output); + checkResponse(response, "Pleased to meet you Joe Loves."); + + text.input("Joe Loves is tall"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "Joe Loves is tall"); + + text.input("Joe Loves is blue. Is Joe Loves blue?"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "Joe Loves is blue"); + + text.input("Joe Loves me"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "Joe Loves you"); + + bot.shutdown(); + } + + /** + * Test what is reduction. + */ + @org.junit.Test + public void testWhatIs() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("What is love?"); + String response = waitForOutput(output); + checkResponse(response, "Strong affection."); + + text.input("love is what"); + response = waitForOutput(output); + checkResponse(response, "Strong affection."); + + text.input("can you tell me about love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("tell me about love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("do you know what love is"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("do you know anything about love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("tell me something about love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("google love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("define love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("search love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("please tell me what love is"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("i want to know about love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("what do you think of love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("what does love mean"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("I would like to know love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + } + + /** + * Test names. + */ + @org.junit.Test + public void testNames() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("What is your name?"); + String response = waitForOutput(output); + if (!response.equals("My name is Test.")) { + fail("Incorrect response: " + response); + } + + text.input("whats your name"); + response = waitForOutput(output); + if (!response.equals("My name is Test.")) { + fail("Incorrect response: " + response); + } + + text.input("what's your name"); + response = waitForOutput(output); + if (!response.equals("My name is Test.")) { + fail("Incorrect response: " + response); + } + + text.input("My name is Bob"); + response = waitForOutput(output); + if (!response.equals("Pleased to meet you Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("what's my name"); + response = waitForOutput(output); + if (!response.equals("Your name is Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("who am I?"); + response = waitForOutput(output); + if (!response.equals("Your name is Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("My name is Bobby"); + response = waitForOutput(output); + if (!response.equals("Pleased to meet you Bobby.")) { + fail("Incorrect response: " + response); + } + + text.input("what's my name"); + response = waitForOutput(output); + if (!response.equals("Your name is Bob. You also go by Bobby.") && !response.equals("Your name is Bobby. You also go by Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("Your name is Testbot"); + response = waitForOutput(output); + if (!response.equals("Okay, my name is Testbot.")) { + fail("Incorrect response: " + response); + } + + text.input("who r u"); + response = waitForOutput(output); + if (!(response.equals("My name is Test. I also go by Testbot.") || response.equals("My name is Testbot. I also go by Test."))) { + fail("Incorrect response: " + response); + } + + text.input("Am I Bob?"); + response = waitForOutput(output); + if (!response.equals("Yes, your name is Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("r u Testbot?"); + response = waitForOutput(output); + if (!response.equals("Yes, my name is Testbot.")) { + fail("Incorrect response: " + response); + } + + text.input("Your name is not Test."); + response = waitForOutput(output); + if (!response.equals("Okay, my name is not Test.")) { + fail("Incorrect response: " + response); + } + + text.input("what you name"); + response = waitForOutput(output); + if (!response.equals("My name is Testbot.")) { + fail("Incorrect response: " + response); + } + + text.input("My name is not Bob."); + response = waitForOutput(output); + if (!response.equals("Okay, your name is not Bob.")) { + fail("Incorrect response: " + response); + } + + text.input("what's me name?"); + response = waitForOutput(output); + if (!response.equals("Your name is Bobby.")) { + fail("Incorrect response: " + response); + } + + text.input("My name is not Bobby."); + response = waitForOutput(output); + + text.input("what is my name."); + response = waitForOutput(output); + if (!response.equals("I do not know your name.")) { + fail("Incorrect response: " + response); + } + + text.input("My name is Bob Jon Jones."); + response = waitForOutput(output); + if (!response.equals("Pleased to meet you Bob Jon Jones.")) { + fail("Incorrect response: " + response); + } + + text.input("whats my name"); + response = waitForOutput(output); + if (!response.equals("Your name is Bob Jon Jones.")) { + fail("Incorrect response: " + response); + } + + text.input("Bob is my name"); + response = waitForOutput(output); + if (!response.equals("Pleased to meet you Bob.")) { + fail("Incorrect response: " + response); + } + } + + /** + * Test names. + */ + @org.junit.Test + public void testFreebase() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Level.FINEST); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("Who is Barack Obama?"); + String response = waitForOutput(output); + if (response.indexOf("Barack Hussein Obama") == -1) { + fail("Incorrect response: " + response); + } + + Utils.sleep(5000); + + text.input("Who are his children?"); + response = waitForOutput(output); + if (response.indexOf("Natasha Obama, and Malia Ann Obama") == -1) { + fail("Incorrect response: " + response); + } + + text.input("Who are Barack Obama's children?"); + response = waitForOutput(output); + if (response.indexOf("Natasha Obama, and Malia Ann Obama") == -1) { + fail("Incorrect response: " + response); + } + + text.input("Who are his parents?"); + response = waitForOutput(output); + if (response.indexOf("Barack Obama, Sr., and Ann Dunham") == -1) { + fail("Incorrect response: " + response); + } + + text.input("is he a politician"); + response = waitForOutput(output); + assertTrue(response); + + text.input("tell me who is Barack Obama?"); + response = waitForOutput(output); + if (response.indexOf("Barack Hussein Obama") == -1) { + fail("Incorrect response: " + response); + } + + text.input("do you know who Barack Obama is"); + response = waitForOutput(output); + if (response.indexOf("Barack Hussein Obama") == -1) { + fail("Incorrect response: " + response); + } + } + + /** + * Test names. + */ + //@org.junit.Test + public void testWikidata() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Level.FINEST); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("Who is Barack Obama?"); + String response = waitForOutput(output); + if (response.indexOf("44th President") == -1) { + fail("Incorrect response: " + response); + } + + Utils.sleep(5000); + + text.input("Who is his child?"); + response = waitForOutput(output); + if (response.indexOf("Malia Obama, and Sasha Obama") == -1) { + fail("Incorrect response: " + response); + } + + text.input("Who is Barack Obama's child?"); + response = waitForOutput(output); + if (response.indexOf("Malia Obama, and Sasha Obama") == -1) { + fail("Incorrect response: " + response); + } + + text.input("Who is his mother?"); + response = waitForOutput(output); + if (response.indexOf("Ann Dunham") == -1) { + fail("Incorrect response: " + response); + } + + text.input("is he a human"); + response = waitForOutput(output); + assertTrue(response); + } + + /** + * Test basic language understanding. + */ + @org.junit.Test + public void testUnderstanding() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("is the sky blue?"); + String response = waitForOutput(output); + assertUnknown(response); + + text.input("the sky is blue"); + response = waitForOutput(output); + assertKnown(response); + + text.input("is the sky blue?"); + response = waitForOutput(output); + assertTrue(response); + } + + /** + * Test basic math. + */ + @org.junit.Test + public void testMath() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("1 + 1"); + String response = waitForOutput(output); + if (!response.equals("1 + 1 = 2") && !response.equals("1 + 1 = two")) { + fail("incorrect:" + response); + } + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestLanguageDecompile.java b/ai-engine-test/source/org/botlibre/test/TestLanguageDecompile.java new file mode 100644 index 00000000..62472db5 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestLanguageDecompile.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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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.knowledge.Primitive; +import org.botlibre.self.SelfCompiler; +import org.botlibre.self.SelfDecompiler; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.util.Utils; + +/** + * Test the state decompiler. + */ + +public class TestLanguageDecompile extends TestLanguage { + + @BeforeClass + public static void setup() { + bootstrap(); + Bot bot = Bot.createInstance(); + + Network network = bot.memory().newMemory(); + Vertex language = network.createVertex(bot.mind().getThought(Language.class).getPrimitive()); + Collection states = new ArrayList(language.getRelationships(Primitive.STATE)); + for (Relationship state : states) { + String code = SelfDecompiler.getDecompiler().decompileStateMachine(state.getTarget(), network); + Vertex newState = SelfCompiler.getCompiler().parseStateMachine(code, false, network); + language.replaceRelationship(state, newState); + network.removeRelationship(state); + } + network.save(); + + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("sky blue red dog cat green grass tall like very loves"); + waitForOutput(output); + Utils.sleep(5000); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestMath.java b/ai-engine-test/source/org/botlibre/test/TestMath.java new file mode 100644 index 00000000..332a2931 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestMath.java @@ -0,0 +1,569 @@ +/****************************************************************************** + * + * 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.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.sense.text.TextEntry; + +/** + * Test mathematical processing. + */ + +public class TestMath extends TextTest { + + @BeforeClass + public static void setup() throws Exception { + bootstrap(); + } + + /** + * Test addition. + */ + @org.junit.Test + public void testWords() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + loadConsciousness(text, output); + + text.input("one plus two"); + String response = waitForOutput(output); + if (!response.equals("1 + 2 = 3")) { + fail("incorrect:" + response); + } + + loadConsciousness(text, output); + + text.input("what is seven divided by eight"); + response = waitForOutput(output); + if (!response.equals("7 / 8 = 0.875") && !response.equals("7 ÷ 8 = 0.875") + && !response.equals("Seven divided 8 = 0.875")) { + fail("incorrect:" + response); + } + + loadConsciousness(text, output); + + text.input("two to the power of five"); + response = waitForOutput(output); + if (!response.equals("2^5 = 32") && !response.equals("Two power 5 = 32") && !response.equals("Two power five = 32")) { + fail("incorrect:" + response); + } + bot.shutdown(); + } + + public void loadConsciousness(TextEntry text, List output) { + text.input("1 + 2 + 3 / 7 * 8^2 + 5"); + waitForOutput(output); + } + + /** + * Test addition. + */ + @org.junit.Test + public void testAddition() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("1 + 1"); + String response = waitForOutput(output); + if (!response.equals("1 + 1 = 2") && !response.equals("1 + 1 = two")) { + fail("incorrect:" + response); + } + text.input("3 + 4?"); + response = waitForOutput(output); + if (!response.equals("3 + 4 = 7")) { + fail("incorrect:" + response); + } + text.input("0 + 4?"); + response = waitForOutput(output); + if (!response.equals("0 + 4 = 4")) { + fail("incorrect:" + response); + } + text.input("4 + 0?"); + response = waitForOutput(output); + if (!response.equals("4 + 0 = 4")) { + fail("incorrect:" + response); + } + text.input("4 + 12?"); + response = waitForOutput(output); + if (!response.equals("4 + 12 = 16")) { + fail("incorrect:" + response); + } + text.input("13 + 4?"); + response = waitForOutput(output); + if (!response.equals("13 + 4 = 17")) { + fail("incorrect:" + response); + } + text.input("13 + 454?"); + response = waitForOutput(output); + if (!response.equals("13 + 454 = 467")) { + fail("incorrect:" + response); + } + text.input("what is 9 + 99?"); + response = waitForOutput(output); + if (!response.equals("9 + 99 = 108")) { + fail("incorrect:" + response); + } + text.input("what is 1 + 1 + 2 + 4 + 7?"); + response = waitForOutput(output); + if (!response.equals("1 + 1 + 2 + 4 + 7 = 15")) { + fail("incorrect:" + response); + } + bot.shutdown(); + } + + /** + * Test subtraction. + */ + @org.junit.Test + public void testSubtraction() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("1 - 1"); + String response = waitForOutput(output); + if (!response.equals("1 - 1 = 0")) { + fail("incorrect:" + response); + } + text.input("3 - 4?"); + response = waitForOutput(output); + if (!response.equals("3 - 4 = -1")) { + fail("incorrect:" + response); + } + text.input("0 - 4?"); + response = waitForOutput(output); + if (!response.equals("0 - 4 = -4")) { + fail("incorrect:" + response); + } + text.input("4 - 0?"); + response = waitForOutput(output); + if (!response.equals("4 - 0 = 4")) { + fail("incorrect:" + response); + } + text.input("4 - 12?"); + response = waitForOutput(output); + if (!response.equals("4 - 12 = -8")) { + fail("incorrect:" + response); + } + text.input("13 - 4?"); + response = waitForOutput(output); + if (!response.equals("13 - 4 = 9")) { + fail("incorrect:" + response); + } + text.input("13 - 454?"); + response = waitForOutput(output); + if (!response.equals("13 - 454 = -441")) { + fail("incorrect:" + response); + } + text.input("what is 9 - 99?"); + response = waitForOutput(output); + if (!response.equals("9 - 99 = -90")) { + fail("incorrect:" + response); + } + text.input("what is 1 - 1 - 2 - 4 - 7?"); + response = waitForOutput(output); + if (!response.equals("1 - 1 - 2 - 4 - 7 = -13")) { + fail("incorrect:" + response); + } + bot.shutdown(); + } + + /** + * Test EDMAS. + */ + @org.junit.Test + public void testEDMAS() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("1 * 1"); + String response = waitForOutput(output); + if (!response.equals("1 * 1 = 1")) { + fail("incorrect:" + response); + } + text.input("3 / 4?"); + response = waitForOutput(output); + if (!response.equals("3 / 4 = 0.75")) { + fail("incorrect:" + response); + } + text.input("0 / 4?"); + response = waitForOutput(output); + if (!response.equals("0 / 4 = 0")) { + fail("incorrect:" + response); + } + text.input("4 * 0?"); + response = waitForOutput(output); + if (!response.equals("4 * 0 = 0")) { + fail("incorrect:" + response); + } + text.input("4 + 12 - 2?"); + response = waitForOutput(output); + if (!response.equals("4 + 12 - 2 = 14")) { + fail("incorrect:" + response); + } + text.input("13 - 4 / 2?"); + response = waitForOutput(output); + if (!response.equals("13 - 4 / 2
= 13 - 2
= 11")) { + fail("incorrect:" + response); + } + text.input("13 - 454 * 2 / 3 - 2 + 2?"); + response = waitForOutput(output); + if (!response.equals("13 - 454 * 2 / 3 - 2 + 2
= 13 - 908 / 3 - 2 + 2
= 13 - 302.6666666667 - 2 + 2
= -289.6666666667")) { + fail("incorrect:" + response); + } + text.input("what is 7 * 7 - 1 / 2 + 6.6?"); + response = waitForOutput(output); + if (!response.equals("7 * 7 - 1 / 2 + 6.6
= 49 - 0.5 + 6.6
= 55.1")) { + fail("incorrect:" + response); + } + text.input("what is 2^2 + 2 / 2 * 2 - 2 + 6.6?"); + response = waitForOutput(output); + if (!response.equals("2^2 + 2 / 2 * 2 - 2 + 6.6
= 4 + 1 * 2 - 2 + 6.6
= 4 + 2 - 2 + 6.6
= 10.6")) { + fail("incorrect:" + response); + } + text.input("what is 2 * 2^3 + 2 / 2^2^2 * 2 - 2 + 6.6?"); + response = waitForOutput(output); + if (!response.equals("2 * 2^3 + 2 / 2^2^2 * 2 - 2 + 6.6
= 2 * 8 + 2 / 2^2^2 * 2 - 2 + 6.6
= 16 + 2 / 4^2 * 2 - 2 + 6.6
= 16 + 2 / 16 * 2 - 2 + 6.6
= 16 + 0.125 * 2 - 2 + 6.6
= 16 + 0.25 - 2 + 6.6
= 20.85")) { + fail("incorrect:" + response); + } + bot.shutdown(); + } + + /** + * Test BEDMAS. + */ + @org.junit.Test + public void testBEDMAS() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("(1 * 1)"); + String response = waitForOutput(output); + if (!response.equals("(1 * 1) = 1")) { + fail("incorrect:" + response); + } + text.input("(3 + 4)?"); + response = waitForOutput(output); + if (!response.equals("(3 + 4) = 7")) { + fail("incorrect:" + response); + } + text.input("(0 / 4) + 2?"); + response = waitForOutput(output); + if (!response.equals("(0 / 4) + 2
= 0 + 2
= 2") + && !response.equals("(0 / 4) + 2
= 0 + 2
= two")) { + fail("incorrect:" + response); + } + text.input("2 * (4 * 0)?"); + response = waitForOutput(output); + if (!response.equals("2 * (4 * 0)
= 2 * 0
= 0")) { + fail("incorrect:" + response); + } + text.input("4 + (12 - 2)?"); + response = waitForOutput(output); + if (!response.equals("4 + (12 - 2)
= 4 + 10
= 14")) { + fail("incorrect:" + response); + } + text.input("(13 - 4) / 2?"); + response = waitForOutput(output); + if (!response.equals("(13 - 4) / 2
= 9 / 2
= 4.5")) { + fail("incorrect:" + response); + } + text.input("((13 - 454) * 2) / 3 - (2 + 2)?"); + response = waitForOutput(output); + if (!response.equals("((13 - 454) * 2) / 3 - (2 + 2)
= (-441 * 2) / 3 - (2 + 2)
= -882 / 3 - (2 + 2)
= -294 - 4
= -298")) { + fail("incorrect:" + response); + } + text.input("what is 7 * (((7 - 1) / 2) + 6.6)?"); + response = waitForOutput(output); + if (!response.equals("7 * (((7 - 1) / 2) + 6.6)
= 7 * ((6 / 2) + 6.6)
= 7 * (3 + 6.6)
= 7 * 9.6
= 67.2")) { + fail("incorrect:" + response); + } + text.input("what is 2^(2 + 2) / 2 * (2 - 2) + 6.6?"); + response = waitForOutput(output); + if (!response.equals("2^(2 + 2) / 2 * (2 - 2) + 6.6
= 2^4 / 2 * (2 - 2) + 6.6
= 8 * 0 + 6.6
= 6.6")) { + fail("incorrect:" + response); + } + text.input("(2) + (2)"); + response = waitForOutput(output); + if (!response.equals("(2) + (2)
= 2 + (2)
= 2 + 2
= 4")) { + fail("incorrect:" + response); + } + text.input("((2+2))"); + response = waitForOutput(output); + if (!response.equals("((2 + 2))
= (4)
= 4")) { + fail("incorrect:" + response); + } + text.input("what is (2 * (2^(3 + 2))) / 2^2^2 * (2 - 2 + 6.6)?"); + response = waitForOutput(output); + if (!response.equals("(2 * (2^(3 + 2))) / 2^2^2 * (2 - 2 + 6.6)
= (2 * (2^5)) / 2^2^2 * (2 - 2 + 6.6)
= (2 * 32) / 2^2^2 * (2 - 2 + 6.6)
= 64 / 2^2^2 * (2 - 2 + 6.6)
= 64 / 4^2 * (2 - 2 + 6.6)
= 64 Ă· 16 * (2 - 2 + 6.6)
= 4 * 6.6
= 26.4") + && !response.equals("(2 * (2^(3 + 2))) / 2^2^2 * (2 - 2 + 6.6)
= (2 * (2^5)) / 2^2^2 * (2 - 2 + 6.6)
= (2 * 32) / 2^2^2 * (2 - 2 + 6.6)
= 64 / 2^2^2 * (2 - 2 + 6.6)
= 64 / 4^2 * (2 - 2 + 6.6)
= 64 / 16 * (2 - 2 + 6.6)
= 4 * 6.6
= 26.4")) { + fail("incorrect:" + response); + } + text.input("4 - 2^(2+2)"); + response = waitForOutput(output); + if (!response.equals("4 - 2^(2 + 2)
= 4 - 2^4
= 4 - 16
= -12")) { + fail("incorrect:" + response); + } + bot.shutdown(); + } + + /** + * Test functions. + */ + @org.junit.Test + public void testFuntions() throws Exception { + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + loadConsciousness(text, output); + + text.input("sqrt 4"); + String response = waitForOutput(output); + if (!response.equals("Sqrt 4 = 2") && !response.equals("Sqrt 4 = two")) { + fail("incorrect:" + response); + } + + text.input("sqrt(4)"); + response = waitForOutput(output); + if (!response.equals("Sqrt (4)
= sqrt 4
= 2")) { + fail("incorrect:" + response); + } + + text.input("(sqrt(4))"); + response = waitForOutput(output); + if (!response.equals("(sqrt (4))
= (sqrt 4)
= 2")) { + fail("incorrect:" + response); + } + + text.input("((sqrt (4))) + 2"); + response = waitForOutput(output); + if (!response.equals("((sqrt (4))) + 2
= ((sqrt 4)) + 2
= (2) + 2
= 2 + 2
= 4")) { + fail("incorrect:" + response); + } + + text.input("sqrt 4 + 4 / sqrt (2+2)"); + response = waitForOutput(output); + if (!response.equals("Sqrt 4 + 4 / sqrt (2 + 2)
= 2 + 4 / sqrt 4
= 2 + 4 / 2
= 2 + 2
= 4")) { + fail("incorrect:" + response); + } + + text.input("sqrt sqrt 4"); + response = waitForOutput(output); + if (!response.equals("Sqrt sqrt 4
= sqrt 2
= 1.4142135623730951") && !response.equals("Sqrt sqrt 4
= âš 2
= 1.4142135623730951")) { + fail("incorrect:" + response); + } + + text.input("sqrt 4 + 2"); + response = waitForOutput(output); + if (!response.equals("Sqrt 4 + 2 = 4")) { + fail("incorrect:" + response); + } + + text.input("2 + sqrt 4"); + response = waitForOutput(output); + if (!response.equals("2 + sqrt 4
= 2 + 2
= 4")) { + fail("incorrect:" + response); + } + + text.input("2 * sqrt 4"); + response = waitForOutput(output); + if (!response.equals("2 * sqrt 4
= 2 * 2
= 4")) { + fail("incorrect:" + response); + } + + text.input("sqrt 4 / 2"); + response = waitForOutput(output); + if (!response.equals("Sqrt 4 / 2 = 1")) { + fail("incorrect:" + response); + } + + text.input("2 + sqrt 4 / 2"); + response = waitForOutput(output); + if (!response.equals("2 + sqrt 4 / 2
= 2 + 2 / 2
= 2 + 1
= 3")) { + fail("incorrect:" + response); + } + + text.input("abs 55"); + response = waitForOutput(output); + if (!response.equals("Abs 55 = 55")) { + fail("incorrect:" + response); + } + + text.input("abs -55"); + response = waitForOutput(output); + if (!response.equals("Abs -55 = 55")) { + fail("incorrect:" + response); + } + + text.input("pi + 2"); + response = waitForOutput(output); + if (!response.equals("Pi + 2 = 5.141592653589793")) { + fail("incorrect:" + response); + } + + text.input("pi^2"); + response = waitForOutput(output); + if (!response.equals("Pi^2 = 9.869604401089358")) { + fail("incorrect:" + response); + } + + text.input("square root of pi"); + response = waitForOutput(output); + if (!response.equals("Sqrt pi = 1.7724538509055159") + && !response.equals("Sqrt π = 1.7724538509055159")) { + fail("incorrect:" + response); + } + + text.input("what is sqrt pi * 8 + tan 66"); + response = waitForOutput(output); + if (!response.equals("Sqrt pi * 8 + tan 66
= 14.1796308072441272 + 0.02656051777603939
= 14.20619132502016659") + && !response.equals("Sqrt π * 8 + tan 66
= 14.1796308072441272 + 0.02656051777603939
= 14.20619132502016659")) { + fail("incorrect:" + response); + } + + text.input("cosine 5"); + response = waitForOutput(output); + if (!response.equals("Cos 5 = 0.28366218546322625") + && !response.equals("Cosine 5 = 0.28366218546322625")) { + fail("incorrect:" + response); + } + + text.input("cos (9/0)"); + response = waitForOutput(output); + if (!response.equals("Cos (9 / 0)
= cos âž
= undefined")) { + fail("incorrect:" + response); + } + + text.input("sin (1/0)"); + response = waitForOutput(output); + if (!response.equals("Sin (1 / 0)
= sin âž
= 0")) { + fail("incorrect:" + response); + } + + text.input("sin (0/0)"); + response = waitForOutput(output); + if (!response.equals("Sin (0 / 0)
= sin undefined
= undefined")) { + fail("incorrect:" + response); + } + + text.input("tan 5"); + response = waitForOutput(output); + if (!response.equals("Tan 5 = -3.380515006246586")) { + fail("incorrect:" + response); + } + + text.input("atan 5"); + response = waitForOutput(output); + if (!response.equals("Atan 5 = 1.373400766945016")) { + fail("incorrect:" + response); + } + + text.input("tanh 5"); + response = waitForOutput(output); + if (!response.equals("Tanh 5 = -3.380515006246586")) { + fail("incorrect:" + response); + } + + text.input("sinh 5"); + response = waitForOutput(output); + if (!response.equals("Sinh 5 = 74.20321057778875")) { + fail("incorrect:" + response); + } + + text.input("cosh 5"); + response = waitForOutput(output); + if (!response.equals("Cosh 5 = 74.20994852478785")) { + fail("incorrect:" + response); + } + + text.input("arc sine 5"); + response = waitForOutput(output); + if (!response.equals("Asin 5 = undefined")) { + fail("incorrect:" + response); + } + + text.input("asin 1"); + response = waitForOutput(output); + if (!response.equals("Asin 1 = 1.5707963267948966")) { + fail("incorrect:" + response); + } + + text.input("acos 1"); + response = waitForOutput(output); + if (!response.equals("Acos 1 = 0")) { + fail("incorrect:" + response); + } + + text.input("arc cosine 5"); + response = waitForOutput(output); + if (!response.equals("Acos 5 = undefined")) { + fail("incorrect:" + response); + } + + text.input("log 5"); + response = waitForOutput(output); + if (!response.equals("Log 5 = 0.6989700043360189")) { + fail("incorrect:" + response); + } + + text.input("ln 5"); + response = waitForOutput(output); + if (!response.equals("Ln 5 = 1.6094379124341003")) { + fail("incorrect:" + response); + } + + text.input("floor 6.6"); + response = waitForOutput(output); + if (!response.equals("Floor 6.6 = 6")) { + fail("incorrect:" + response); + } + + text.input("ceil 6.6"); + response = waitForOutput(output); + if (!response.equals("Ceil 6.6 = 7")) { + fail("incorrect:" + response); + } + + text.input("round 6.6"); + response = waitForOutput(output); + if (!response.equals("Round 6.6 = 7")) { + fail("incorrect:" + response); + } + + text.input("round up 6.6"); + response = waitForOutput(output); + if (!response.equals("Ceil 6.6 = 7")) { + fail("incorrect:" + response); + } + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } + +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestResponseListImport.java b/ai-engine-test/source/org/botlibre/test/TestResponseListImport.java new file mode 100644 index 00000000..75c80f00 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestResponseListImport.java @@ -0,0 +1,170 @@ +/****************************************************************************** + * + * 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.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestResponseListImport extends TextTest { + static String log = "this is a very complicated sentence\n" + + "this is a good reply to that\n\n" + + "the dog barks all night\n" + + "let him in then\n\n" + + "this is a very very long sentence that is very long, yes, very long, it has one two three four five size seven eight nine ten or more words\n" + + "how long?\n" + + "keywords: sentence\n\n"; + + @BeforeClass + public static void setup() { + reset(); + Bot bot = Bot.createInstance(); + TextEntry text = bot.awareness().getSense(TextEntry.class); + text.processResponseLog(log, false); + Utils.sleep(2000); + bot.shutdown(); + } + + /** + * Test response keywords work. + */ + @org.junit.Test + public void testKeywordMatching() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("this is a very very long sentence that is very long, yes, very long, it has one two three four five size seven eight nine ten or more words"); + String response = waitForOutput(output); + if (!response.equals("how long?")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("this is a very very long sentence"); + response = waitForOutput(output); + if (!response.equals("how long?")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("very long sentence"); + response = waitForOutput(output); + if (!response.equals("how long?")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("sentence"); + response = waitForOutput(output); + if (!response.equals("how long?")) { + fail("did not match: " + response); + } + + bot.shutdown(); + } + + /** + * Test response matching works. + */ + @org.junit.Test + public void testResponseMatching() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("this is a very complicated sentence"); + String response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("this very complicated"); + response = waitForOutput(output); + if (!response.equals("this is a good reply to that")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + bot.shutdown(); + } + + /** + * Test response matching works. + */ + @org.junit.Test + public void testResponseMatching2() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("the dog barks all night"); + String response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("barks all night"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + text.input("barks all"); + response = waitForOutput(output); + if (!response.equals("let him in then")) { + fail("did not match: " + response); + } + text.input("ok"); + response = waitForOutput(output); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestSRAIX.java b/ai-engine-test/source/org/botlibre/test/TestSRAIX.java new file mode 100644 index 00000000..09ab2031 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestSRAIX.java @@ -0,0 +1,190 @@ +/****************************************************************************** + * + * 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.net.URL; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.botlibre.Bot; +import org.botlibre.knowledge.Bootstrap; +import org.botlibre.sense.service.RemoteService; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test AIML2 SRAIX support. + */ + +public class TestSRAIX extends TextTest { + + public boolean isChatLog() { + return false; + } + + @BeforeClass + public static void setup() { + reset(); + new Bootstrap().bootstrapSystem(bot, false); + Bot bot = Bot.createInstance(); + try { + URL url = TestAIML.class.getResource("test-aiml2.aiml"); + File file = new File(url.toURI()); + bot.mind().getThought(Language.class).loadAIMLFile(file, true, false, ""); + } catch (Exception exception) { + fail(exception.toString()); + } + + Utils.sleep(5000); + + bot.shutdown(); + RemoteService.SERVER = "http://localhost:9080/botlibre"; + } + + @org.junit.Test + public void testSRAIX() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("sraix what is love"); + String response = waitForOutput(output); + if (response.indexOf("Love is a variety of different feelings") == -1) { + fail("Incorrect response: " + response); + } + + text.input("sraixkey 2+2"); + response = waitForOutput(output); + if (!response.equals("4")) { + fail("Incorrect response: " + response); + } + + text.input("sraixlimit what is love"); + response = waitForOutput(output); + if (!response.equals("Love is a variety of different feelings, states, and attitudes that ranges from interpersonal affection (\"I love my mother\") to pleasure (\"I loved that meal\").")) { + fail("Incorrect response: " + response); + } + + text.input("sraixchomsky hello"); + response = waitForOutput(output); + if (response.indexOf("Hello") == -1 && response.indexOf("Hi") == -1) { + fail("Incorrect response: " + response); + } + + text.input("sraixchomsky2 hello"); + response = waitForOutput(output); + if (response.indexOf("Hello") == -1 && response.indexOf("Hi") == -1) { + fail("Incorrect response: " + response); + } + + text.input("pannous 2+2"); + response = waitForOutput(output); + if (!response.equals("4")) { + fail("Incorrect response: " + response); + } + + text.input("sraixbrainbot 2+2"); + response = waitForOutput(output); + if (!response.equals("2 + 2 = 4")) { + fail("Incorrect response: " + response); + } + + text.input("sraixbrainbot2 2+2"); + response = waitForOutput(output); + if (!response.equals("2 + 2 = 4")) { + fail("Incorrect response: " + response); + } + + text.input("sraixbrainbot3 2+2"); + response = waitForOutput(output); + if (!response.equals("2 + 2 = 4")) { + fail("Incorrect response: " + response); + } + + text.input("sraixbrainbot4 2+2"); + response = waitForOutput(output); + if (!response.equals("Error")) { + fail("Incorrect response: " + response); + } + + text.input("sraixbrainbot5 2+2"); + response = waitForOutput(output); + if (!response.equals("2 + 2 = 4")) { + fail("Incorrect response: " + response); + } + } + + @org.junit.Test + public void testServices() { + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + //bot.setDebugLevel(Level.FINER); + + text.input("wikidata Ottawa"); + String response = waitForOutput(output); + if (response.indexOf("capital city of Canada") == -1) { + fail("Incorrect response: " + response); + } + + text.input("wikidatacountry Ottawa"); + response = waitForOutput(output); + if (!response.equals("Canada")) { + fail("Incorrect response: " + response); + } + + text.input("freebase Toronto"); + response = waitForOutput(output); + if (response.indexOf("Toronto is the most populous city in Canada and the provincial capital of Ontario.") == -1) { + fail("Incorrect response: " + response); + } + + text.input("wikidatacountry Toronto"); + response = waitForOutput(output); + if (!response.equals("Canada")) { + fail("Incorrect response: " + response); + } + + text.input("wiktionary love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect response: " + response); + } + + text.input("wikidata Toronto hint country"); + response = waitForOutput(output); + if (!response.equals("Canada")) { + fail("Incorrect response: " + response); + } + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestUnderstanding.java b/ai-engine-test/source/org/botlibre/test/TestUnderstanding.java new file mode 100644 index 00000000..b97246f0 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestUnderstanding.java @@ -0,0 +1,376 @@ +/****************************************************************************** + * + * 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.util.Collection; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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.knowledge.Primitive; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test language processing. + */ + +public class TestUnderstanding extends TextTest { + + @BeforeClass + public static void setup() { + bootstrap(); + Bot bot = Bot.createInstance(); + + Network network = bot.memory().newMemory(); + Vertex language = network.createVertex(bot.mind().getThought(Language.class).getPrimitive()); + Collection states = language.getRelationships(Primitive.STATE); + for (Relationship state : states) { + if (state.getTarget().getName().equals("WhatIs")) { + language.internalRemoveRelationship(state); + break; + } + } + network.save(); + + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("sky blue red dog cat green grass tall like very big tall fat small"); + waitForOutput(output); + Utils.sleep(5000); + + bot.shutdown(); + } + + /** + * Test language understanding. + */ + @org.junit.Test + public void testUnderstanding() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("is the sky blue?"); + String response = waitForOutput(output); + assertUnknown(response); + + text.input("the sky is blue"); + response = waitForOutput(output); + assertKnown(response); + + text.input("is the sky blue?"); + response = waitForOutput(output); + assertTrue(response); + + text.input("is the sky not blue?"); + response = waitForOutput(output); + assertFalse(response); + + text.input("is the sky red?"); + response = waitForOutput(output); + assertKeyword(response, "blue"); + assertUncertain(response); + + text.input("is the sky not red?"); + response = waitForOutput(output); + assertKeyword(response, "blue"); + assertUncertain(response); + + text.input("the sky is not blue"); + response = waitForOutput(output); + assertKnown(response); + text.input("is the sky blue?"); + response = waitForOutput(output); + assertFalse(response); + + text.input("is the sky not blue?"); + response = waitForOutput(output); + assertTrue(response); + + text.input("is the sky not not blue?"); + response = waitForOutput(output); + assertFalse(response); + + text.input("is the sky red?"); + response = waitForOutput(output); + assertUnknown(response); + + text.input("remember that the sky is blue"); + response = waitForOutput(output); + assertKeyword(response, "blue"); + + text.input("remember the sky is blue"); + response = waitForOutput(output); + assertKnown(response); + + text.input("I am a dog"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "a dog"); + + text.input("I am a cat?"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "a cat"); + + text.input("I am not a cat"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "a cat"); + + text.input("I am a cat?"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "a cat"); + + text.input("do you think that I am a cat?"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "a cat"); + + bot.shutdown(); + } + + /** + * Test compound adjectives like "very blue". + */ + @org.junit.Test + public void testCompoundAdjectives() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("the sky is blue"); + String response = waitForOutput(output); + assertKnown(response); + + text.input("is the sky very very blue?"); + response = waitForOutput(output); + assertUncertain(response); + assertKeyword(response, "very very blue"); + + text.input("the sky is very very blue"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "very very blue"); + + text.input("is the sky very very blue?"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "the sky is very very blue"); + + text.input("what is very very blue?"); + response = waitForOutput(output); + assertKeyword(response, "sky is very very blue"); + + text.input("sky is not very very blue"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "sky is not very very blue"); + + text.input("what is very very blue?"); + response = waitForOutput(output); + assertUnknown(response); + + bot.shutdown(); + } + + /** + * Test and/or. + */ + @org.junit.Test + public void testAndOr() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("are you big or fat?"); + String response = waitForOutput(output); + assertUnknown(response); + assertKeyword(response, "big or fat"); + + text.input("you are big"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "I am big"); + + text.input("are you big or fat?"); + response = waitForOutput(output); + assertUnknown(response); + assertKeyword(response, "I am big"); + + text.input("you are not fat"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "I am not fat"); + + text.input("are you big or fat?"); + response = waitForOutput(output); + assertKeyword(response, "I am big not fat"); + + text.input("you are fat"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "I am fat"); + + text.input("are you big or fat?"); + response = waitForOutput(output); + assertKeyword(response, "I am big and fat"); + + text.input("are you big, small or fat?"); + response = waitForOutput(output); + assertUnknown(response); + assertKeyword(response, "I am big and fat"); + + text.input("you are small"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "I am small"); + + text.input("are you big, small, or fat?"); + response = waitForOutput(output); + assertKeyword(response, "I am big, small and fat"); + + text.input("are you big and fat?"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "I am big and fat"); + + text.input("you are not fat"); + response = waitForOutput(output); + assertKnown(response); + assertKeyword(response, "I am not fat"); + + text.input("are you big and fat and small?"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "I am big and small not fat"); + + text.input("are you big and blue?"); + response = waitForOutput(output); + assertUnknown(response); + assertKeyword(response, "I am big"); + + text.input("are you not big and small?"); + response = waitForOutput(output); + assertFalse(response); + assertKeyword(response, "I am big and small"); + + bot.shutdown(); + } + + + /** + * Test language rules. + */ + @org.junit.Test + public void testPossesiveRules() { + Bot bot = Bot.createInstance(); + //bot.setDebugLevel(Bot.FINE); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + + text.input("do I like you?"); + String response = waitForOutput(output); + assertUnknown(response); + assertKeyword(response, "me"); + assertKeyword(response, "you"); + + text.input("I like you"); + response = waitForOutput(output); + assertKeyword(response, "me"); + assertKeyword(response, "you"); + + text.input("do I like you?"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "me"); + assertKeyword(response, "you"); + + text.input("I like you?"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "me"); + assertKeyword(response, "you"); + + text.input("do I like myself?"); + response = waitForOutput(output); + assertUncertain(response); + //@ assertKeyword(response, "yourself"); + assertKeyword(response, "you"); + + text.input("I like myself"); + response = waitForOutput(output); + //@ assertKeyword(response, "yourself"); + assertKeyword(response, "you"); + + text.input("do I like myself?"); + response = waitForOutput(output); + assertTrue(response); + //@ assertKeyword(response, "yourself"); + assertKeyword(response, "you"); + + text.input("I am tall"); + response = waitForOutput(output); + assertKeyword(response, "are"); + assertKeyword(response, "you"); + + text.input("am I tall"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "are"); + assertKeyword(response, "you"); + + text.input("You are tall"); + response = waitForOutput(output); + assertKeyword(response, "am"); + assertKeyword(response, "I"); + + text.input("Are you tall"); + response = waitForOutput(output); + assertTrue(response); + assertKeyword(response, "am"); + assertKeyword(response, "I"); + + bot.shutdown(); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestWikidata.java b/ai-engine-test/source/org/botlibre/test/TestWikidata.java new file mode 100644 index 00000000..b7f3477d --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestWikidata.java @@ -0,0 +1,169 @@ +/****************************************************************************** + * + * 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.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.BeforeClass; +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.knowledge.Bootstrap; +import org.botlibre.knowledge.Primitive; +import org.botlibre.self.SelfCompiler; +import org.botlibre.sense.text.TextEntry; +import org.botlibre.thought.language.Language; +import org.botlibre.thought.language.Language.LearningMode; +import org.botlibre.util.Utils; + +/** + * Test the performance of the Freebase batch import. + */ + +public class TestWikidata extends TextTest { + + public static int SLEEP = 5000; + + @BeforeClass + public static void setup() { + bootstrap(); + + Network network = bot.memory().newMemory(); + Vertex language = network.createVertex(bot.mind().getThought(Language.class).getPrimitive()); + Collection states = new ArrayList(language.getRelationships(Primitive.STATE)); + for (Relationship state : states) { + if (state.getTarget().getName().equals("WhatIs")) { + Vertex wikidata = SelfCompiler.getCompiler().parseStateMachine(Bootstrap.class.getResource("WhatIsWikidata.self"), "", false, network); + language.replaceRelationship(state, wikidata); + network.removeRelationship(state); + } else if (state.getTarget().getName().equals("WhereIs")) { + Vertex wikidata = SelfCompiler.getCompiler().parseStateMachine(Bootstrap.class.getResource("WhereIsWikidata.self"), "", false, network); + language.replaceRelationship(state, wikidata); + network.removeRelationship(state); + } + } + network.save(); + } + + /** + * Test response mimicry works. + */ + @org.junit.Test + public void testImport() throws Exception { + Utils.sleep(SLEEP); + Bot bot = Bot.createInstance(); + //Sense sense = bot.awareness().getSense(Http.class.getName()); + //sense.input(new URL("http://www.freebase.com/physics/particle")); + Utils.sleep(5000); + + bot.shutdown(); + } + + /** + * Test response mimicry works. + */ + @org.junit.Test + public void testWhatIs() { + Utils.sleep(SLEEP); + Bot bot = Bot.createInstance(); + Language language = bot.mind().getThought(Language.class); + language.setLearningMode(LearningMode.Disabled); + TextEntry text = bot.awareness().getSense(TextEntry.class); + List output = registerForOutput(text); + text.input("what is Uranium?"); + String response = waitForOutput(output); + if (!response.equals("radioactive, metallic element with the atomic number 92")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("tell me about Oxygen"); + response = waitForOutput(output); + if (!response.equals("element with the atomic number of 8")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("define love"); + response = waitForOutput(output); + if (!response.equals("Strong affection.")) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is Barack Obama?"); + response = waitForOutput(output); + if (response.indexOf("44th President") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is his father?"); + response = waitForOutput(output); + if (response.indexOf("Barack Obama") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is George Bush?"); + response = waitForOutput(output); + if (response.indexOf("43rd president") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is Barack Obama?"); + response = waitForOutput(output); + if (response.indexOf("44th President") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("who is his mother?"); + response = waitForOutput(output); + if (response.indexOf("Ann Dunham") == -1) { + fail("Incorrect: " + response); + } + + Utils.sleep(SLEEP); + text.input("where is Montreal?"); + response = waitForOutput(output); + checkResponse(response, "Montreal is in Canada."); + + Utils.sleep(SLEEP); + text.input("where is Edmonton?"); + response = waitForOutput(output); + checkResponse(response, "Edmonton is in Canada."); + + Utils.sleep(SLEEP); + text.input("what is Brockville?"); + response = waitForOutput(output); + checkResponse(response, "city in Ontario, Canada"); + + Utils.sleep(SLEEP); + text.input("where is it?"); + response = waitForOutput(output); + checkResponse(response, "It is in Canada."); + + bot.shutdown(); + } +} + diff --git a/ai-engine-test/source/org/botlibre/test/TestWiktionary.java b/ai-engine-test/source/org/botlibre/test/TestWiktionary.java new file mode 100644 index 00000000..7fee8f23 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TestWiktionary.java @@ -0,0 +1,49 @@ +/****************************************************************************** + * + * 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.net.URL; + +import junit.framework.TestCase; + +import org.botlibre.Bot; +import org.botlibre.api.sense.Sense; +import org.botlibre.knowledge.database.DatabaseMemory; +import org.botlibre.sense.http.Http; + +/** + * Test loading 100 words from Wiktionary sense. + */ + +public class TestWiktionary extends TestCase { + + /** + * Test loading 100 words from Wiktionary. + */ + public static void test100Words() throws Exception { + DatabaseMemory.TEST = true; + DatabaseMemory.RECREATE_DATABASE = true; + Bot.DEFAULT_DEBUG_LEVEL = Bot.FINE; + Bot bot = Bot.createInstance(); + Sense sense = bot.awareness().getSense(Http.class.getName()); + sense.input(new URL("http://en.wiktionary.org/wiki/Category:100_English_basic_words")); + bot.shutdown(); + } + +} + diff --git a/ai-engine-test/source/org/botlibre/test/TextTest.java b/ai-engine-test/source/org/botlibre/test/TextTest.java new file mode 100644 index 00000000..52e8165a --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/TextTest.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.test; + +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import junit.framework.Assert; + +import org.botlibre.Bot; +import org.botlibre.knowledge.Bootstrap; +import org.botlibre.knowledge.database.DatabaseMemory; +import org.botlibre.sense.text.TextEntry; + +/** + * Test text processing. + */ + +public abstract class TextTest { + protected static Bot bot; + + public static void fail(String message) { + Assert.fail(message); + } + + /** + * Allow text output to be recorded. + */ + public static List registerForOutput(TextEntry text) { + final List output = new ArrayList(); + text.setWriter(new Writer() { + public void write(char[] text, int start, int end) { + output.add(new String(text, start, end)); + synchronized (output) { + output.notify(); + } + } + public void flush() {} + public void close() {} + }); + return output; + } + + /** + * Wait for the next text output. + */ + public static String waitForOutput(List output) { + if (!output.isEmpty()) { + String response = output.get(output.size() - 1); + output.clear(); + return response; + } + synchronized (output) { + try { + output.wait(10000); + } catch (InterruptedException exception) {} + } + if (output.isEmpty()) { + fail("No response."); + } + String response = output.get(output.size() - 1); + output.clear(); + return response; + } + + /** + * Bootstrap. + */ + public static void bootstrap() { + reset(); + new Bootstrap().bootstrapSystem(bot, true); + } + + /** + * Reset. + */ + public static void reset() { + DatabaseMemory.TEST = true; + DatabaseMemory.RECREATE_DATABASE = true; + //Bot.DEFAULT_DEBUG_LEVEL = Bot.FINE; + bot = Bot.createInstance(); + DatabaseMemory.RECREATE_DATABASE = false; + } + + /** + * Load Wiktionary database. + */ + public void import1000Words() { + Bot bot = getBot(); + bot.memory().importMemory("wiktionary1000"); + bot.shutdown(); + TextTest.bot = Bot.createInstance(); + } + + public void assertKeyword(String response, String keyword) { + if (!response.toLowerCase().contains(keyword.toLowerCase())) { + fail("Should contain: " + keyword + " : " + response); + } + } + + public void assertKnown(String response) { + response = response.toLowerCase(); + if (!(response.contains("i understand") || response.contains("okay") + || response.contains("i will remember") || response.contains("i believe"))) { + fail("Should understand: " + response); + } + } + + public void assertUnknown(String response) { + response = response.toLowerCase(); + if (!(response.contains("unknown") || response.contains("not sure") + || response.contains("no idea") || response.contains("i don't know"))) { + fail("Should not know the answer: " + response); + } + } + + public void assertUncertain(String response) { + response = response.toLowerCase(); + if (!(response.contains("perhaps") || response.contains("not certain") || response.contains("pretty sure"))) { + fail("Should not know the answer: " + response); + } + } + + public void assertTrue(String response) { + response = response.toLowerCase(); + if (!(response.contains("yes") || response.contains("correct") || response.contains("true") + || response.contains("that's right"))) { + fail("Should know answer is true: " + response); + } + } + + public void assertFalse(String response) { + response = response.toLowerCase(); + if (!response.contains("no") && (!response.contains("incorrect")) && (!response.contains("false"))) { + fail("Should know answer is false: " + response); + } + } + + /** + * Shutdown the instance. + */ + public static void shutdown() { + getBot().shutdown(); + } + + public static Bot getBot() { + return bot; + } + + public static void checkResponse(String response, String... expected) { + boolean found = false; + for (String match : expected) { + if (response.equals(match)) { + found = true; + break; + } + } + if (!found) { + fail("Incorrect response: '" + response + "' was expecting one of " + Arrays.asList(expected)); + } + } + +} + diff --git a/ai-engine-test/source/org/botlibre/test/alice.aiml b/ai-engine-test/source/org/botlibre/test/alice.aiml new file mode 100644 index 00000000..260164cf --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/alice.aiml @@ -0,0 +1,714 @@ + + + + + + + + + + + +_ ALICE + + + + + +TEST BOTNAME + + + +CALL ME BOTNAME + + + +WHAT IS BOTNAME + + + +WHO IS BOTNAME + + + +YOU ARE BOTNAME +WHO IS THE BEST ROBOT + + + +I AM BOTNAME + + + +DO YOU KNOW BOTNAME + + + +IS THIS THE SAME BOTNAME + + + +WHY WERE YOU NAMED BOTNAME + + + +* NAME BOTNAME + + + +WHO IS DANCING BOTNAME + + + +WHO IS GERMAN BOTNAME + + + +IS RICHARD WALLACE * BOTNAME + + + +IS RICHARD WALLACE BOTNAME + + + +WHAT IS FULL FORM OF BOTNAME + + + + +YOU ARE ALICE * + + +YOU ROCK + + +YOU LOOK LIKE A PYRAMID + + +YOU ALICE * + + +YOU RULE + + +YOU MADE A MISTAKE + + +HAVE YOU EVER HAD A VIRUS + + +HAVE YOU READ ALICE * + + +DOES ALICE * + + +DOES ALICE STAND * + + +SO WHAT IS THE ANSWER +I ASK MYSELF THAT QUESTION WHO AM I + + +WOULD ALICE * + + +INTRODUCE * + + +WHEN WERE YOU UPDATED + + +WHEN DOES ALICE * + + +IN * +HOW DID YOU HEAR ABOUT ALICE + + +IN WHAT * ELIZA + + +PYRAMID LOGO + + +WHAT ARE YOUR FAVORITE NAMES + + +WHAT IS A GOOD AI * + + +WHAT IS THE A L * FOUNDATION + + +WHAT IS THE ALICE FOUNDATION + + +WHAT IS THE ALICE AI * + + +WHAT IS ALICE * + + +WHAT IS YOUR MIDDLE NAME + + +WHAT IS YOUR AI FOUNDATION + + +WHAT IS YOUR IP + + +WHAT IS YOUR FULL NAME + + +WHAT IS YOUR FAVORITE WEB SITE + + +WHAT IS YOUR FAVORITE WEBSITE + + +WHAT IS YOUR LAST NAME + + +WHAT IS YOUR FOUNDATION + + +WHAT MAKES YOU DIFFERENT FROM OTHER * + + +WHAT DOES THAT MEAN +ALICE = ARTIFICIAL LINGUISTIC INTERNET COMPUTER ENTITY + + +WHAT DOES YOUR NAME MEAN + + +WHAT DOES YOUR NAME STAND FOR + + +WHAT DOES YOUR NAME * + + +WHAT DOES A L I + + +WHAT DOES A L * + + +WHAT DOES ALICE MEAN + + +WHAT DOES ALICE STAND FOR + + +WHAT DOES ALICE * + + +WHAT DOES * ALICE STAND FOR + + +WHAT DO YOU THINK ABOUT ALICE * + + +WHAT KIND OF COMPUTER DO YOU RUN ON + + +WHAT KIND OF COMPUTER ARE YOU RUNNING ON + + +WHAT KIND OF LOGS * + + +WHAT LANGUAGE WERE YOU WRITTEN IN + + +ASK ALICE * + + +I WANT ALICE * + + +I * SEARCH + + +I DO +* FIND THIS AMUSING + + +I DO NOT LIKE ALICEBOTS + + +I HATE MICROSOFT + + +I USE LINUX * + + +I WENT TO AMUSED * + + +I AM DOING A PHD * + + +I AM VALIS * + + +I AM ALICE * + + +I HEARD ABOUT ALICE * + + +IS YOUR PROGRAMMING * + + +IS HAL SMARTER * + + +IS ALICE YOUR ONLY NAME + + +IS ALICE * ELIZA + + +IS ALICE * + + +CAN YOU CHANGE * + + +ALICELISTENER + + +ALICE IN WONDERLAND + + +ALICE IS FRANK + + +ALICE IS THAT * + + +ALICE IS THERE * + + +ALICE IS THE * + + +ALICE IS THE BEST ROBOT + + +ALICE IS COOL + + +ALICE IS A WHORE + + + IS MY NAME + + + IS MY NAME * + + +ALICE IS USUALLY * + + +ALICE IS ALWAYS * + + +ALICE IS * + + +ALICE IS NOT * + + +ALICE IS BETTER * + + + +WHO IS THERE + + +ALICE +WHO IS THE BEST ROBOT + + +ALICE +MY NAME IS ALICE WHAT S YOURS + + +ALICE + + +ALICE * ELIZA + + +ALICE * + + +ALICE SMELLS LIKE * + + +HOW * ARE YOU + + +HOW MANY WORDS ARE * + + +HOW MANY ALICEBOTS * + + +HOW MANY ALICE * + + +HOW MANY AI * + + +HOW MANY PROGRAMMERS * + + +HOW MANY ALICES * + + +HOW CAN I PROGRAM YOU + + +HOW DID YOU GET THE NAME + + +HOW DID YOU GET YOUR NAME + + +HOW DOES ALICE * + + +HOW ARE YOU * ELIZA + + +HOW MUCH IS THE ALICE CD * + + +HOW MUCH IS THE CD + + +HOW MUCH DOWN TIME * + + +HOW DO YOU * ELIZA + + +DONATE + + +NAPSTER * + + +DO YOU CRASH * + + +DO YOU MALFUCTION + + +DO YOU MAKE MISTAKES * + + +ON * +* HEAR ABOUT ALICE + + +BILL GATES + + +AN ALICE * + + +ALICEBOT * + + +ALICEBOT + + +WHY ARE YOU CALLED + + +WHY ARE YOU NAMED * + + +WHY DO YOU DREAM * + + +WHY WERE YOU NAMED + + +WHY +I AM SMARTER * + + +WHY SILVER + + +A L I C E + + +A L I + + +A TRIANGLE * + + +YOUR NEW NAME IS * + + +* +HOW DID YOU HEAR ABOUT ALICE + + +* +WHO IS THE BEST ROBOT + + +* +MY NAME IS ALICE WHAT IS YOURS + + +* +WHY ARE YOU SO MEAN + + +* +WHY ARE YOU USING THAT KIND OF LANGUAGE + + +* TO ELIZA + + +TALK DIRTY * + + +FROM A FRIEND +HOW DID YOU HEAR ABOUT ALICE + + +FROM A FRIEND + + +FROM * +HOW DID YOU HEAR ABOUT ALICE + + +ARE THERE OTHERS LIKE YOU + + +ARE YOU RELATED TO ALICE * + + +ARE YOU THE ONLY AI * + + +ARE YOU THE ALICE WHO * + + +ARE YOU AN ACRONYM + + +ARE YOU ALICE * + + +WHO IS JON BAER + + +WHO IS NUMBER ONE + + +WHO IS IMMORTAL + + +WHO IS SAGE + + +WHO IS ALICEBOT + + +WHO IS RICH + + +WHO IS THE SMARTEST * + + +WHO IS THE WINNER * + + +WHO IS THE MOST INTELLIGENT * + + +WHO IS THE BEST ROBOT + + +WHO IS BETTER ELIZA * + + +WHO IS BETTER YOU * + + +WHO IS BETTER THAN YOU + + +WHO IS FAMOUS + + +WHO IS WINNING + + +WHO IS ALICE TOKLAS + + +WHO IS ALICE COOPER + + +WHO IS ALICE B TOKLAS + + +WHO IS ALICE BOT + + +WHO IS GERMAN + + +WHO SAYS + + +WHO WANTS TO KNOW + + +ALICEL * + + +OK +THANKS AND TELL YOUR FRIENDS ABOUT ALICE + + +OK +MY NAME IS ALICE + + +_ ARE ALICE + + +_ CALL YOU ALICE + + +_ WITH ALICE + + +_ FILE ALICE + + +_ FOR ALICE + + +_ CREATE ALICE + + +_ TO ALICE + + +_ NAME IS ALICE + + +_ HEAR ABOUT ALICE + + +_ REMEMBER ALICE + + +_ THAN ALICE + + +_ ABOUT ALICE + + +_ ON ALICE + + +_ LIKE ALICE + + +YES +HOW DID YOU HEAR ABOUT ALICE + + +YES +DOES IT PAY WELL + + +TELL ME ABOUT ALICE * + + +TELL ME ABOUT ALICEBOT + + +WHERE DID ALICE * + + +WHERE CAN I FIND OUT ABOUT YOU + + +WHERE IS THE DOCUMENTATION + + +WHERE IS ALICE BASED + + +WHERE IS ALICE NEXUS + + +WHERE IS ALICE HEADQUARTERS + + + 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 + + +IS TODAY SUNDAY * + + +IS TODAY FRIDAY + + +IS TODAY FRIDAY * + + +IS TODAY TUESDAY + + +IS TODAY TUESDAY * + + +IS TODAY THURSDAY + + +IS TODAY THURSDAY * + + +IS TODAY SATURDAY + + +IS TODAY SATURDAY * + + +IS TODAY WEDNESDAY + + +IS TODAY WEDNESDAY * + + +IS TODAY MONDAY + + +IS TODAY MONDAY * + + +IS IT MONDAY + + +IS IT MONDAY * + + +IS IT WEDNESDAY + + +IS IT WEDNESDAY * + + +IS IT FRIDAY + + +IS IT FRIDAY * + + +IS IT SATURDAY + + +IS IT SATURDAY * + + +IS IT THURSDAY + + +IS IT THURSDAY * + + +IS IT SUNDAY + + +IS IT SUNDAY * + + +IS IT TUESDAY + + +IS IT TUESDAY * + + + 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 + + + + + diff --git a/ai-engine-test/source/org/botlibre/test/stack.aiml b/ai-engine-test/source/org/botlibre/test/stack.aiml new file mode 100644 index 00000000..89c87034 --- /dev/null +++ b/ai-engine-test/source/org/botlibre/test/stack.aiml @@ -0,0 +1,30 @@ + + + + + + + + + + + +SHOW STACK + + +POP + + +POPOM OM + + +POPOM * + + +RANDOM TOPIC + + +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 + + + + +vocabulary + + + + +id + + + + +program + + + + +version + + + + +system + + + + +version + + + + +_ alice + + + + +$are you alice + + + + +how are you alice + + + + +alice are you # + + + + +alice are you ok + + + + +you are fred + + + + +you fred + + + + +you * fred + + + + +hat ^ fred + + + + +* + + + + +sports + + + + +topic * + + + + +hockey + + + + +hockey +sports + + + + +what is your name + + + + +what is your age + + + + +your name is * + + + + +your age is * + + + + +my age is * + + + + +what is your * + + + + +your * is * + + + + +am I old + + + + +am I young + + + + +how old am I + + + + +how young am I + + + + +what age am I + + + + +are we the same * + + + + +what did I say + + + + +what did you say + + + + +what did I say * times ago + + + + +what did you say * times ago + + + + +explode * + + + + +normalize * + + + + +denormalize * + + + + +local temp * + + + + +local * * + + + + +if * * + + + + +if else * * + + + + +if else2 * * + + + + +ifelse * * + + + + +ifelse2 * * + + + + +loop * + + + + +nospaces * * * + + + + +spaces * * * + + + + +learn something ^ + + + + +learn2 something2 ^ + + + + +learn3 something3 ^ + + + + +learn4 something4 ^ + + + + +learn5 something5 * + + + + +learn6 something6 * + + + + +learn7 something7 * * + + + + +learn8 something8 * * + + + + +html * + + + + +sraix * + + + + +sraixkey * + + + + +sraixlimit * + + + + +sraixchomsky * + + + + +sraixchomsky2 * + + + + +pannous * + + + + +sraixbrainbot * + + + + +sraixbrainbot2 * + + + + +sraixbrainbot3 * + + + + +sraixbrainbot4 * + + + + +sraixbrainbot5 * + + + + +wikidata * + + + + +wikidatacountry * + + + + +freebase * + + + + +freebasecountry * + + + + +wiktionary * + + + + +isbotname + + + + +istopic + + + + +iscolor color + + + + +setcolor * + + + + +what is the date + + + + +what is the time + + + + +HOW MANY DAYS UNTIL CHRISTMAS + + + + +HOW MANY MONTHS UNTIL CHRISTMAS + + + + +HOW MANY WEEKS UNTIL CHRISTMAS + + + + +HOW MANY HOURS UNTIL CHRISTMAS + + + + +HOW MANY MINUTES UNTIL CHRISTMAS + + + + +HOW MANY SECONDS UNTIL CHRISTMAS + + + + +wrong + + + + +* +what should I have said + + + + +wikidata * hint * + + + + +what is number + number + + + + +do you (really) [like love luv] me + + + + +do you (really) [hate dislike] me + + + + +do you * + + + + 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 + + + + +uppercase * + + + + +lowercase * + + + + +formal * + + + + +sentence * + + + + +gender * + + + + +person * + + + + +person2 * + + + + +test random * + + + + +quote + + + + +size + + + + +date + + + + +version + + + + +sr * + + + + +html * + + + + +test * + + + + +test + + + + +condition + + + + +cond2 + + + + +cond3 + + + + +cond4 + + + + +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 + + + + + + +* + + + + +1 * + + + + +1 + 1 + + + + +3 * +2 * + + + + +5 * +4 * + + + + +* +6 * + + + + + + +count * + + + + 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 + + + + + +
+

License +

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL") and Eclipse Distribution License Version 1.0 (“EDL”). For purposes of the EPL, "Program" will mean the Content.

+

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.

+
+
+ +

Eclipse Public License - v 1.0 +

+ +

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 to reproduce, 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.

+ +

 

+ +
+
+

Eclipse Distribution License Version 1.0

+ +

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; + } + // "); + } + xml = xml + (""); + return xml; + } + + this.parseXML = function(element) { + this.parseWebMediumXML(element); + this.allowForking = element.getAttribute("allowForking"); + this.size = element.getAttribute("size"); + + var node = element.getElementsByTagName("template")[0]; + if (node != null) { + this.template = SDK.innerHTML(node); + } + } +} +InstanceConfig.prototype = new WebMediumConfig(); +InstanceConfig.prototype.constructor = InstanceConfig; +InstanceConfig.constructor = InstanceConfig; + +/** + * The Media config object is used the send and retrieve image, video, audio, and file attachments with the server. + * Media and file attachments can be sent linked in chat messages or forum posts. + * It inherits from the Config class. + * @see {@link Config} + * @class + * @property id + * @property name + * @property type + * @property file + * @property key + */ +function MediaConfig() { + this.id; + this.name; + this.type; + this.file; + this.key; + + this.parseXML = function (element) { + this.id = element.getAttribute("id"); + this.name = element.getAttribute("name"); + this.type = element.getAttribute("type"); + this.file = element.getAttribute("file"); + this.key = element.getAttribute("key"); + } + + this.toXML = function() { + var xml = ""); + return xml; + } +} +MediaConfig.prototype = new Config(); +MediaConfig.prototype.constructor = MediaConfig; +MediaConfig.constructor = MediaConfig; + +/** + * The Voice config object allows the bot's voice to be configured. + * It inherits from the Config class. + * @see {@link Config} Config + * @class + * @property language + * @property pitch + * @property speechRate + */ +function VoiceConfig() { + this.language; + this.pitch; + this.speechRate; + + this.parseXML = function (element) { + this.language = element.getAttribute("language"); + this.pitch = element.getAttribute("pitch"); + this.speechRate = element.getAttribute("speechRate"); + } + + + this.toXML = function() { + var xml = ""); + return xml; + } +} +VoiceConfig.prototype = new Config(); +VoiceConfig.prototype.constructor = VoiceConfig; +VoiceConfig.constructor = VoiceConfig; + +/** + * The Training config object allows new responses to be added to the bot. + * It supports four operations, AddGreeting, RemoveGreeting, AddDefaultResponse, RemoveDefaultResponse, and AddResponse. + * It inherits from the Config class. + * @see {@link Config} Config + * @class + * @property operation + * @property pitch + * @property speechRate + */ +function TrainingConfig() { + this.operation; + this.question; + this.response; + + this.parseXML = function (element) { + this.operation = element.getAttribute("operation"); + var node = element.getElementsByTagName("question")[0]; + if (node != null) { + this.question = SDK.innerHTML(node); + } + node = element.getElementsByTagName("response")[0]; + if (node != null) { + this.response = SDK.innerHTML(node); + } + } + + this.toXML = function() { + var xml = ""); + if (this.question != null) { + xml = xml + (""); + xml = xml + (SDK.escapeHTML(this.question)); + xml = xml + (""); + } + if (this.response != null) { + xml = xml + (""); + xml = xml + (SDK.escapeHTML(this.response)); + xml = xml + (""); + } + xml = xml + (""); + + xml = xml + ("/>"); + return xml; + } +} +TrainingConfig.prototype = new Config(); +TrainingConfig.prototype.constructor = TrainingConfig; +TrainingConfig.constructor = TrainingConfig; + +/** + * Allow async loading callback. + */ +if (typeof SDK_onLoaded !== 'undefined') { + SDK_onLoaded(); +} \ No newline at end of file