├── .gitignore ├── LICENSE ├── README.md ├── app ├── build.gradle ├── libs │ ├── ATTSpeechKit.jar │ ├── AlchemyAPI_Java-0.9 │ │ ├── ChangeLog │ │ ├── README │ │ ├── build.xml │ │ ├── build_no_tests.xml │ │ ├── build_with_tests.xml │ │ ├── src │ │ │ └── com │ │ │ │ └── alchemyapi │ │ │ │ ├── api │ │ │ │ ├── AlchemyAPI.java │ │ │ │ ├── AlchemyAPI_CategoryParams.java │ │ │ │ ├── AlchemyAPI_CombinedParams.java │ │ │ │ ├── AlchemyAPI_ConceptParams.java │ │ │ │ ├── AlchemyAPI_ConstraintQueryParams.java │ │ │ │ ├── AlchemyAPI_ImageParams.java │ │ │ │ ├── AlchemyAPI_KeywordParams.java │ │ │ │ ├── AlchemyAPI_LanguageParams.java │ │ │ │ ├── AlchemyAPI_NamedEntityParams.java │ │ │ │ ├── AlchemyAPI_Params.java │ │ │ │ ├── AlchemyAPI_RelationParams.java │ │ │ │ ├── AlchemyAPI_TargetedSentimentParams.java │ │ │ │ ├── AlchemyAPI_TaxonomyParams.java │ │ │ │ └── AlchemyAPI_TextParams.java │ │ │ │ └── test │ │ │ │ ├── AuthorTest.java │ │ │ │ ├── CategoryTest.java │ │ │ │ ├── CombinedTest.java │ │ │ │ ├── ConceptTest.java │ │ │ │ ├── ConstraintQueryTest.java │ │ │ │ ├── EntityTest.java │ │ │ │ ├── FeedLinksTest.java │ │ │ │ ├── ImageTest.java │ │ │ │ ├── KeywordTest.java │ │ │ │ ├── LanguageTest.java │ │ │ │ ├── MicroformatTest.java │ │ │ │ ├── ParameterTest.java │ │ │ │ ├── RelationsTest.java │ │ │ │ ├── SentimentTest.java │ │ │ │ ├── TaxonomyTest.java │ │ │ │ └── TextExtractTest.java │ │ └── testdir │ │ │ ├── api_key.txt │ │ │ └── data │ │ │ ├── example.html │ │ │ ├── example2.html │ │ │ ├── example2_nolinks.html │ │ │ ├── example3.html │ │ │ └── microformats.html │ ├── cardboard.jar │ ├── easyadapter-1.2.0.jar │ ├── gson-2.3.jar │ └── retrofit-1.7.1.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── dwai │ │ └── yhack │ │ └── captor │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── fonts │ │ ├── Roboto-Black.ttf │ │ ├── Roboto-BlackItalic.ttf │ │ ├── Roboto-Bold.ttf │ │ ├── Roboto-BoldItalic.ttf │ │ ├── Roboto-Italic.ttf │ │ ├── Roboto-Light.ttf │ │ ├── Roboto-LightItalic.ttf │ │ ├── Roboto-Medium.ttf │ │ ├── Roboto-MediumItalic.ttf │ │ ├── Roboto-Regular.ttf │ │ ├── Roboto-Thin.ttf │ │ └── Roboto-ThinItalic.ttf │ ├── java │ └── dwai │ │ └── yhack │ │ └── captor │ │ └── ui │ │ ├── activity │ │ ├── ArActivity.java │ │ ├── DatePosted.java │ │ ├── HistoryActivity.java │ │ ├── HistoryViewHolder.java │ │ ├── JSONParser.java │ │ ├── MyActivity.java │ │ ├── OneItem.java │ │ ├── SpeechAuth.java │ │ ├── SpeechConfig.java │ │ └── User.java │ │ ├── ar │ │ ├── GLUtils.java │ │ ├── Renderer.java │ │ └── WorldLayoutData.java │ │ └── widget │ │ └── CardboardOverlayView.java │ └── res │ ├── anim │ └── slide_up.xml │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ ├── asdfsadf.png │ ├── camera_b.xml │ ├── camera_icon.png │ ├── camera_pressed.png │ ├── cardboard_b.xml │ ├── cardboard_icon.png │ ├── cardboard_pressed.png │ ├── cardboard_splash.png │ ├── history_button.png │ ├── ic_history_black_48dp.png │ ├── ic_launcher.png │ ├── ic_search_white_48dp.png │ └── kitten.jpg │ ├── layout │ ├── activity_ar.xml │ ├── activity_history.xml │ ├── activity_my.xml │ └── subtitle_item.xml │ ├── menu │ ├── history.xml │ ├── my.xml │ └── options_menu.xml │ ├── raw │ ├── grid_fragment.shader │ └── light_vertex.shader │ ├── values-v21 │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | 6 | # built application files 7 | *.apk 8 | *.ap_ 9 | 10 | # files for the dex VM 11 | *.dex 12 | 13 | # Java class files 14 | *.class 15 | 16 | # generated files 17 | bin/ 18 | gen/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Eclipse/IntelliJ project files 24 | .classpath 25 | .project 26 | default.properties 27 | .idea 28 | *.iml 29 | gen-external-apklibs 30 | target 31 | build 32 | 33 | # Output folder 34 | out/** 35 | 36 | # Misc 37 | .DS_Store 38 | app/res/values/keys.xml 39 | *.diff 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Captor 2 | 3 | ## WARNING: This code was built at a hackathon, therefore it is the most convoluted and messy code you will ever see. I might fix in in the future but for right now, it is what it is. 4 | 5 | If you would like to contribute, check out the issues of this repo and try to fix one! 6 | 7 | ## What is this? 8 | Automatic subtitles for the deaf using Google Cardboard. You can check out a video demo of it [here](https://www.youtube.com/watch?v=7iE2NuSeD9c) 9 | 10 | Built at YHack 2014 by Stefan, Fisher, Sashank and Alex. 11 | 12 | We used CardAR for the augmented reality portion of this hack. It is awesome. To find out more about it, [go here][0]. 13 | 14 | This is an augmented reality hack that allows deaf people the ability to see subtitles in real life as they are speaking with somebody. We used Google's speech recognition to continously recognize speech and produced subtitles with it. 15 | 16 | 17 | ... 18 | [0]: https://github.com/mauimauer/cardar 19 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "dwai.yhack.cardar" 9 | minSdkVersion 15 10 | targetSdkVersion 20 11 | versionCode 3 12 | versionName "0.0.3" 13 | } 14 | buildTypes { 15 | release { 16 | runProguard false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.jakewharton:butterknife:5.1.1' 25 | compile 'com.jakewharton.timber:timber:2.4.1' 26 | compile files('libs/ATTSpeechKit.jar') 27 | compile files('libs/easyadapter-1.2.0.jar') 28 | compile files('libs/gson-2.3.jar') 29 | } 30 | -------------------------------------------------------------------------------- /app/libs/ATTSpeechKit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/ATTSpeechKit.jar -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/ChangeLog: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | 3 | 0.9 - Added support for combined call, ranked taxonomy & image extraction. 4 | 0.8 - Added support for author extraction & targeted sentiment. 5 | 0.7 - Added support for relations extraction. 6 | 0.6 - Added support for sentiment analysis. 7 | 0.5 - Added GetRankedConcepts calls and parameter object. 8 | 0.4.2 - Added Parameters, added RDF support 9 | 0.4.1 - Fixed compilation error in Entities example code. 10 | 0.4 - Added GetRankedKeywords calls, added TextGetCategory call. 11 | 0.3 - Added ConstraintQuery call, imports changes, exception reporting 12 | changes, general improvements. 13 | 0.2 - Added setApiKey() call, setApiHost() call, updated API endpoint. 14 | 0.1 - Initial Release 15 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/README: -------------------------------------------------------------------------------- 1 | ================================ 2 | AlchemyAPI Java SDK: version 0.9 3 | ================================ 4 | 5 | This is a Java implementation of the AlchemyAPI SDK. 6 | 7 | 8 | INSTALLATION 9 | 10 | AlchemyAPI Java SDK provides Ant build files for systems lacking JUnit, 11 | an addition to JUnit-enabled build files. To build AlchemyAPI Java SDK 12 | without JUnit tests, type the following Ant command: 13 | 14 | ant jar 15 | 16 | If you desire to build AlchemyAPI Java SDK with JUnit tests enabled, 17 | rename your Ant .xml files and build using the following commands: 18 | 19 | ln -sf build_with_tests.xml build.xml; ant jar 20 | 21 | 22 | RUNNING EXAMPLES 23 | 24 | Several code examples are included to illustrate using the AlchemyAPI 25 | for named entity extraction, text classification, language identification, 26 | and other tasks. 27 | 28 | All code samples should be run from within the "testdir" directory. 29 | 30 | To run these code samples you must first edit the (testdir/api_key.txt) file, 31 | adding your assigned AlchemyAPI key. 32 | 33 | Code Samples: 34 | 35 | 1. Entity Extraction: java -jar ../dist/AlchemyAPI-Entity-Test.jar 36 | 37 | 2. Concept Tagging: java -jar ../dist/AlchemyAPI-Concept-Test.jar 38 | 39 | 3. Keyword Extraction: java -jar ../dist/AlchemyAPI-Keyword-Test.jar 40 | 41 | 4. Text Categorization: java -jar ../dist/AlchemyAPI-Category-Test.jar 42 | 43 | 5. Language Identification: java -jar ../dist/AlchemyAPI-Language-Test.jar 44 | 45 | 6. HTML Text Extraction: java -jar ../dist/AlchemyAPI-TextExtract-Test.jar 46 | 47 | 7. HTML Structured Content Scraping: java -jar ../dist/AlchemyAPI-ConstraintQuery-Test.jar 48 | 49 | 8. Microformats Extraction: java -jar ../dist/AlchemyAPI-Microformats-Test.jar 50 | 51 | 9. RSS / ATOM Feed Links Extraction: java -jar ../dist/AlchemyAPI-FeedLinks-Test.jar 52 | 53 | 10. Sentiment Analysis: java -jar ../dist/AlchemyAPI-Sentiment-Test.jar 54 | 55 | 11. Relations: java -jar ../dist/AlchemyAPI-Relations-Test.jar 56 | 57 | 12. Example of using the parameters object: java -jar ../dist/AlchemyAPI-Parameter-Test.jar 58 | 59 | 13. Author Extraction: java -jar ../dist/AlchemyAPI-Author-Test.jar 60 | 61 | 14. Combined Data Extraction: java -jar ../dist/AlchemyAPI-Combined-Test.jar 62 | 63 | 15. Ranked Taxonomy Extraction: java -jar ../dist/AlchemyAPI-Taxonomy-Test.jar 64 | 65 | 16. Image Extraction: java -jar ../dist/AlchemyAPI-Image-Test.jar 66 | 67 | 68 | DEPENDENCIES 69 | 70 | This module requires these other modules and libraries: 71 | 72 | Java JDK 1.5.x 73 | ANT (to build the packages) 74 | JUnit (optional, to build the tests) 75 | 76 | 77 | COPYRIGHT AND LICENCE 78 | 79 | Copyright (C) Orchestr8, LLC. 80 | 81 | This library is free software; you can redistribute it and/or modify 82 | it under the same terms as Perl version 5.8.5 or, at your option, 83 | any later version of Perl 5 you may have available. 84 | 85 | 86 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build file for AlchemyAPI code / examples. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/build_no_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build file for AlchemyAPI code / examples. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/build_with_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build file for AlchemyAPI code / examples. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_CategoryParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.net.URLEncoder; 5 | 6 | public class AlchemyAPI_CategoryParams extends AlchemyAPI_Params { 7 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 8 | public static final String CQUERY = "cquery"; 9 | public static final String XPATH = "xpath"; 10 | 11 | private String sourceText; 12 | private String cQuery; 13 | private String xPath; 14 | private String baseUrl; 15 | 16 | public String getSourceText() { 17 | return sourceText; 18 | } 19 | public void setSourceText(String sourceText) { 20 | if( !sourceText.equals(AlchemyAPI_CategoryParams.CLEANED_OR_RAW) 21 | && !sourceText.equals(AlchemyAPI_CategoryParams.CQUERY) 22 | && !sourceText.equals(AlchemyAPI_CategoryParams.XPATH)) 23 | { 24 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 25 | } 26 | this.sourceText = sourceText; 27 | } 28 | public String getCQuery() { 29 | return cQuery; 30 | } 31 | public void setCQuery(String cQuery) { 32 | this.cQuery = cQuery; 33 | } 34 | public String getXPath() { 35 | return xPath; 36 | } 37 | public void setXPath(String xPath) { 38 | this.xPath = xPath; 39 | } 40 | public String getBaseUrl() { 41 | return baseUrl; 42 | } 43 | public void setBaseUrl(String baseUrl) { 44 | this.baseUrl = baseUrl; 45 | } 46 | 47 | public String getParameterString(){ 48 | String retString = super.getParameterString(); 49 | try{ 50 | if(sourceText!=null) retString+="&sourceText="+sourceText; 51 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 52 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 53 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 54 | } 55 | catch(UnsupportedEncodingException e ){ 56 | retString = ""; 57 | } 58 | return retString; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_CombinedParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_CombinedParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | public static final String EXTRACT_MODE_TRUST = "trust-metadata"; 14 | public static final String EXTRACT_MODE_INFER = "always-infer"; 15 | public static final String EXTRACT_PAGE_IMAGE = "page-image"; 16 | public static final String EXTRACT_ENTITY = "entity"; 17 | public static final String EXTRACT_KEYWORD = "keyword"; 18 | public static final String EXTRACT_TITLE = "title"; 19 | public static final String EXTRACT_AUTHOR = "author"; 20 | public static final String EXTRACT_TAXONOMY = "taxonomy"; 21 | public static final String EXTRACT_CONCEPT = "concept"; 22 | public static final String EXTRACT_RELATION = "relation"; 23 | public static final String EXTRACT_DOC_SENTIMENT = "doc-sentiment"; 24 | 25 | private Boolean disambiguate; 26 | private Boolean linkedData; 27 | private Boolean coreference; 28 | private Boolean quotations; 29 | private String sourceText; 30 | private Boolean showSourceText; 31 | private String cQuery; 32 | private String xPath; 33 | private Integer maxRetrieve; 34 | private String baseUrl; 35 | private Boolean sentiment = false; 36 | private String extractMode; 37 | private String extract; 38 | 39 | public boolean isDisambiguate() { 40 | return disambiguate; 41 | } 42 | public void setDisambiguate(boolean disambiguate) { 43 | this.disambiguate = disambiguate; 44 | } 45 | public boolean isLinkedData() { 46 | return linkedData; 47 | } 48 | public void setLinkedData(boolean linkedData) { 49 | this.linkedData = linkedData; 50 | } 51 | public boolean isCoreference() { 52 | return coreference; 53 | } 54 | public void setCoreference(boolean coreference) { 55 | this.coreference = coreference; 56 | } 57 | public boolean isQuotations() { 58 | return quotations; 59 | } 60 | public void setQuotations(boolean quotations) { 61 | this.quotations = quotations; 62 | } 63 | public String getSourceText() { 64 | return sourceText; 65 | } 66 | public void setSourceText(String sourceText) { 67 | if( !sourceText.equals(AlchemyAPI_CombinedParams.CLEANED) && !sourceText.equals(AlchemyAPI_CombinedParams.CLEANED_OR_RAW) 68 | && !sourceText.equals(AlchemyAPI_CombinedParams.RAW) && !sourceText.equals(AlchemyAPI_CombinedParams.CQUERY) 69 | && !sourceText.equals(AlchemyAPI_CombinedParams.XPATH)) 70 | { 71 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 72 | } 73 | this.sourceText = sourceText; 74 | } 75 | public boolean isShowSourceText() { 76 | return showSourceText; 77 | } 78 | public void setShowSourceText(boolean showSourceText) { 79 | this.showSourceText = showSourceText; 80 | } 81 | public String getCQuery() { 82 | return cQuery; 83 | } 84 | public void setCQuery(String cQuery) { 85 | this.cQuery = cQuery; 86 | } 87 | public String getXPath() { 88 | return xPath; 89 | } 90 | public void setXPath(String xPath) { 91 | this.xPath = xPath; 92 | } 93 | public int getMaxRetrieve() { 94 | return maxRetrieve; 95 | } 96 | public void setMaxRetrieve(int maxRetrieve) { 97 | this.maxRetrieve = maxRetrieve; 98 | } 99 | public String getBaseUrl() { 100 | return baseUrl; 101 | } 102 | public void setBaseUrl(String baseUrl) { 103 | this.baseUrl = baseUrl; 104 | } 105 | public boolean isSentiment() { 106 | return sentiment; 107 | } 108 | public void setSentiment(boolean sentiment) { 109 | this.sentiment = sentiment; 110 | } 111 | public void setExtractMode(String extractMode) { 112 | if( !extractMode.equals(EXTRACT_MODE_TRUST) && !extractMode.equals(EXTRACT_MODE_INFER) ) 113 | { 114 | throw new RuntimeException("Invalid setting " + extractMode + " for parameter extractMode"); 115 | } 116 | this.extractMode = extractMode; 117 | } 118 | public void setExtractAll() { 119 | this.extract = EXTRACT_PAGE_IMAGE + EXTRACT_ENTITY + EXTRACT_KEYWORD 120 | + EXTRACT_TITLE + EXTRACT_AUTHOR + EXTRACT_TAXONOMY 121 | + EXTRACT_CONCEPT + EXTRACT_RELATION + EXTRACT_DOC_SENTIMENT; 122 | } 123 | public void setExtract(String extractArg) { 124 | if( !extractArg.equals(EXTRACT_PAGE_IMAGE) 125 | && !extractArg.equals(EXTRACT_ENTITY) 126 | && !extractArg.equals(EXTRACT_KEYWORD) 127 | && !extractArg.equals(EXTRACT_TITLE) 128 | && !extractArg.equals(EXTRACT_AUTHOR) 129 | && !extractArg.equals(EXTRACT_TAXONOMY) 130 | && !extractArg.equals(EXTRACT_CONCEPT) 131 | && !extractArg.equals(EXTRACT_RELATION) 132 | && !extractArg.equals(EXTRACT_DOC_SENTIMENT) ) 133 | { 134 | throw new RuntimeException("Invalid setting " + extractArg + " for parameter extract"); 135 | } 136 | if ((null == this.extract) || (0 == this.extract.length())) 137 | this.extract = extractArg; 138 | else 139 | this.extract += "," + extractArg; 140 | } 141 | public String getParameterString(){ 142 | String retString = super.getParameterString(); 143 | try{ 144 | if (extractMode!=null) retString+="&extractMode="+extractMode; 145 | if (extract!=null) retString+="&extract="+extract; 146 | if(sentiment!=null) retString+="&sentiment="+(sentiment?"1":"0"); 147 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 148 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 149 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 150 | if(disambiguate!=null) retString+="&disambiguate="+(disambiguate ? "1":"0"); 151 | if(linkedData!=null) retString+="&linkedData="+(linkedData?"1":"0"); 152 | if(coreference!=null) retString+="&coreference="+(coreference?"1":"0"); 153 | if(quotations!=null) retString+=""ations="+(quotations?"1":"0"); 154 | if(sourceText!=null) retString+="&sourceText="+sourceText; 155 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 156 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 157 | } 158 | catch(UnsupportedEncodingException e ){ 159 | retString = ""; 160 | } 161 | return retString; 162 | } 163 | } 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_ConceptParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_ConceptParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | 14 | private Integer maxRetrieve; 15 | private String sourceText; 16 | private Boolean showSourceText; 17 | private String cQuery; 18 | private String xPath; 19 | private Boolean linkedData; 20 | 21 | public String getSourceText() { 22 | return sourceText; 23 | } 24 | 25 | public void setSourceText(String sourceText) { 26 | if( !sourceText.equals(AlchemyAPI_ConceptParams.CLEANED) && !sourceText.equals(AlchemyAPI_ConceptParams.CLEANED_OR_RAW) 27 | && !sourceText.equals(AlchemyAPI_ConceptParams.RAW) && !sourceText.equals(AlchemyAPI_ConceptParams.CQUERY) 28 | && !sourceText.equals(AlchemyAPI_ConceptParams.XPATH)) 29 | { 30 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 31 | } 32 | this.sourceText = sourceText; 33 | } 34 | 35 | public boolean isShowSourceText() { 36 | return showSourceText; 37 | } 38 | 39 | public void setShowSourceText(boolean showSourceText) { 40 | this.showSourceText = showSourceText; 41 | } 42 | 43 | public String getCQuery() { 44 | return cQuery; 45 | } 46 | 47 | public void setCQuery(String cQuery) { 48 | this.cQuery = cQuery; 49 | } 50 | 51 | public String getXPath() { 52 | return xPath; 53 | } 54 | 55 | public void setXPath(String xPath) { 56 | this.xPath = xPath; 57 | } 58 | 59 | public int getMaxRetrieve() { 60 | return maxRetrieve; 61 | } 62 | 63 | public void setMaxRetrieve(int maxRetrieve) { 64 | this.maxRetrieve = maxRetrieve; 65 | } 66 | 67 | public boolean isLinkedData() { 68 | return linkedData; 69 | } 70 | 71 | public void setLinkedData(boolean linkedData) { 72 | this.linkedData = linkedData; 73 | } 74 | 75 | public String getParameterString(){ 76 | String retString = super.getParameterString(); 77 | try{ 78 | if(sourceText!=null) retString+="&sourceText="+sourceText; 79 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 80 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 81 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 82 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 83 | if(linkedData!=null) retString+="&linkedData="+(linkedData?"1":"0"); 84 | } 85 | catch(UnsupportedEncodingException e ){ 86 | retString = ""; 87 | } 88 | return retString; 89 | } 90 | 91 | 92 | 93 | } 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_ConstraintQueryParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_ConstraintQueryParams extends AlchemyAPI_Params{ 8 | 9 | private String cQuery; 10 | 11 | public String getCQuery() { 12 | return cQuery; 13 | } 14 | public void setCQuery(String cQuery) { 15 | this.cQuery = cQuery; 16 | } 17 | 18 | 19 | public String getParameterString(){ 20 | String retString = super.getParameterString(); 21 | try{ 22 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 23 | } 24 | catch(UnsupportedEncodingException e ){ 25 | retString = ""; 26 | } 27 | return retString; 28 | } 29 | 30 | 31 | 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_ImageParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_ImageParams extends AlchemyAPI_Params{ 8 | public static final String CQUERY = "cquery"; 9 | public static final String XPATH = "xpath"; 10 | 11 | private String cQuery; 12 | private String xPath; 13 | private Integer maxRetrieve; 14 | private String baseUrl; 15 | 16 | public String getCQuery() { 17 | return cQuery; 18 | } 19 | public void setCQuery(String cQuery) { 20 | this.cQuery = cQuery; 21 | } 22 | public String getXPath() { 23 | return xPath; 24 | } 25 | public void setXPath(String xPath) { 26 | this.xPath = xPath; 27 | } 28 | public int getMaxRetrieve() { 29 | return maxRetrieve; 30 | } 31 | public void setMaxRetrieve(int maxRetrieve) { 32 | this.maxRetrieve = maxRetrieve; 33 | } 34 | public String getBaseUrl() { 35 | return baseUrl; 36 | } 37 | public void setBaseUrl(String baseUrl) { 38 | this.baseUrl = baseUrl; 39 | } 40 | 41 | public String getParameterString(){ 42 | String retString = super.getParameterString(); 43 | try{ 44 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 45 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 46 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 47 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 48 | } 49 | catch(UnsupportedEncodingException e ){ 50 | retString = ""; 51 | } 52 | return retString; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_KeywordParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_KeywordParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | 14 | public static final String EXTRACT_MODE_STRICT = "strict"; 15 | 16 | private Integer maxRetrieve; 17 | private String sourceText; 18 | private Boolean showSourceText; 19 | private Boolean sentiment; 20 | private String cQuery; 21 | private String xPath; 22 | private String baseUrl; 23 | private String keywordExtractMode; 24 | 25 | public String getKeywordExtractMode() { 26 | return keywordExtractMode; 27 | } 28 | 29 | public void setKeywordExtractMode(String keywordExtractMode) { 30 | if( !keywordExtractMode.equals(AlchemyAPI_KeywordParams.EXTRACT_MODE_STRICT)) 31 | { 32 | throw new RuntimeException("Invalid setting " + keywordExtractMode + " for parameter keywordExtractMode"); 33 | } 34 | this.keywordExtractMode = keywordExtractMode; 35 | } 36 | 37 | public String getSourceText() { 38 | return sourceText; 39 | } 40 | 41 | public void setSourceText(String sourceText) { 42 | if( !sourceText.equals(AlchemyAPI_KeywordParams.CLEANED) && !sourceText.equals(AlchemyAPI_KeywordParams.CLEANED_OR_RAW) 43 | && !sourceText.equals(AlchemyAPI_KeywordParams.RAW) && !sourceText.equals(AlchemyAPI_KeywordParams.CQUERY) 44 | && !sourceText.equals(AlchemyAPI_KeywordParams.XPATH)) 45 | { 46 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 47 | } 48 | this.sourceText = sourceText; 49 | } 50 | 51 | public boolean isShowSourceText() { 52 | return showSourceText; 53 | } 54 | 55 | public void setShowSourceText(boolean showSourceText) { 56 | this.showSourceText = showSourceText; 57 | } 58 | 59 | public boolean isSentiment() { 60 | return sentiment; 61 | } 62 | 63 | public void setSentiment(boolean sentiment) { 64 | this.sentiment = sentiment; 65 | } 66 | 67 | public String getCQuery() { 68 | return cQuery; 69 | } 70 | 71 | public void setCQuery(String cQuery) { 72 | this.cQuery = cQuery; 73 | } 74 | 75 | public String getXPath() { 76 | return xPath; 77 | } 78 | 79 | public void setXPath(String xPath) { 80 | this.xPath = xPath; 81 | } 82 | 83 | public int getMaxRetrieve() { 84 | return maxRetrieve; 85 | } 86 | 87 | public void setMaxRetrieve(int maxRetrieve) { 88 | this.maxRetrieve = maxRetrieve; 89 | } 90 | 91 | public String getBaseUrl() { 92 | return baseUrl; 93 | } 94 | 95 | public void setBaseUrl(String baseUrl) { 96 | this.baseUrl = baseUrl; 97 | } 98 | 99 | public String getParameterString(){ 100 | String retString = super.getParameterString(); 101 | try{ 102 | if(sourceText!=null) retString+="&sourceText="+sourceText; 103 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 104 | if(sentiment!=null) retString+="&sentiment="+(sentiment?"1":"0"); 105 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 106 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 107 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 108 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 109 | if(keywordExtractMode!=null) retString+="&keywordExtractMode="+URLEncoder.encode(keywordExtractMode,"UTF-8"); 110 | } 111 | catch(UnsupportedEncodingException e ){ 112 | retString = ""; 113 | } 114 | return retString; 115 | } 116 | 117 | 118 | 119 | } 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_LanguageParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.net.URLEncoder; 5 | 6 | public class AlchemyAPI_LanguageParams extends AlchemyAPI_Params { 7 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 8 | public static final String CLEANED = "cleaned"; 9 | public static final String RAW = "raw"; 10 | public static final String CQUERY = "cquery"; 11 | public static final String XPATH = "xpath"; 12 | 13 | private String sourceText; 14 | private String cQuery; 15 | private String xPath; 16 | 17 | public String getSourceText() { 18 | return sourceText; 19 | } 20 | 21 | public void setSourceText(String sourceText) { 22 | if( !sourceText.equals(AlchemyAPI_LanguageParams.CLEANED_OR_RAW) 23 | && !sourceText.equals(AlchemyAPI_LanguageParams.CQUERY) 24 | && !sourceText.equals(AlchemyAPI_LanguageParams.XPATH)) 25 | { 26 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 27 | } 28 | this.sourceText = sourceText; 29 | } 30 | 31 | public String getCQuery() { 32 | return cQuery; 33 | } 34 | 35 | public void setCQuery(String cQuery) { 36 | this.cQuery = cQuery; 37 | } 38 | 39 | public String getXPath() { 40 | return xPath; 41 | } 42 | 43 | public void setXPath(String xPath) { 44 | this.xPath = xPath; 45 | } 46 | 47 | public String getParameterString(){ 48 | String retString = super.getParameterString(); 49 | try{ 50 | if(sourceText!=null) retString+="&sourceText="+sourceText; 51 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 52 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 53 | } 54 | catch(UnsupportedEncodingException e ){ 55 | retString = ""; 56 | } 57 | return retString; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_NamedEntityParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_NamedEntityParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | 14 | private Boolean disambiguate; 15 | private Boolean linkedData; 16 | private Boolean coreference; 17 | private Boolean quotations; 18 | private String sourceText; 19 | private Boolean showSourceText; 20 | private String cQuery; 21 | private String xPath; 22 | private Integer maxRetrieve; 23 | private String baseUrl; 24 | private Boolean sentiment; 25 | 26 | public boolean isDisambiguate() { 27 | return disambiguate; 28 | } 29 | public void setDisambiguate(boolean disambiguate) { 30 | this.disambiguate = disambiguate; 31 | } 32 | public boolean isLinkedData() { 33 | return linkedData; 34 | } 35 | public void setLinkedData(boolean linkedData) { 36 | this.linkedData = linkedData; 37 | } 38 | public boolean isCoreference() { 39 | return coreference; 40 | } 41 | public void setCoreference(boolean coreference) { 42 | this.coreference = coreference; 43 | } 44 | public boolean isQuotations() { 45 | return quotations; 46 | } 47 | public void setQuotations(boolean quotations) { 48 | this.quotations = quotations; 49 | } 50 | public String getSourceText() { 51 | return sourceText; 52 | } 53 | public void setSourceText(String sourceText) { 54 | if( !sourceText.equals(AlchemyAPI_NamedEntityParams.CLEANED) && !sourceText.equals(AlchemyAPI_NamedEntityParams.CLEANED_OR_RAW) 55 | && !sourceText.equals(AlchemyAPI_NamedEntityParams.RAW) && !sourceText.equals(AlchemyAPI_NamedEntityParams.CQUERY) 56 | && !sourceText.equals(AlchemyAPI_NamedEntityParams.XPATH)) 57 | { 58 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 59 | } 60 | this.sourceText = sourceText; 61 | } 62 | public boolean isShowSourceText() { 63 | return showSourceText; 64 | } 65 | public void setShowSourceText(boolean showSourceText) { 66 | this.showSourceText = showSourceText; 67 | } 68 | public String getCQuery() { 69 | return cQuery; 70 | } 71 | public void setCQuery(String cQuery) { 72 | this.cQuery = cQuery; 73 | } 74 | public String getXPath() { 75 | return xPath; 76 | } 77 | public void setXPath(String xPath) { 78 | this.xPath = xPath; 79 | } 80 | public int getMaxRetrieve() { 81 | return maxRetrieve; 82 | } 83 | public void setMaxRetrieve(int maxRetrieve) { 84 | this.maxRetrieve = maxRetrieve; 85 | } 86 | public String getBaseUrl() { 87 | return baseUrl; 88 | } 89 | public void setBaseUrl(String baseUrl) { 90 | this.baseUrl = baseUrl; 91 | } 92 | public boolean isSentiment() { 93 | return sentiment; 94 | } 95 | public void setSentiment(boolean sentiment) { 96 | this.sentiment = sentiment; 97 | } 98 | 99 | public String getParameterString(){ 100 | String retString = super.getParameterString(); 101 | try{ 102 | if(disambiguate!=null) retString+="&disambiguate="+(disambiguate ? "1":"0"); 103 | if(linkedData!=null) retString+="&linkedData="+(linkedData?"1":"0"); 104 | if(coreference!=null) retString+="&coreference="+(coreference?"1":"0"); 105 | if(quotations!=null) retString+=""ations="+(quotations?"1":"0"); 106 | if(sourceText!=null) retString+="&sourceText="+sourceText; 107 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 108 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 109 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 110 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 111 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 112 | if(sentiment!=null) retString+="&sentiment="+(sentiment?"1":"0"); 113 | } 114 | catch(UnsupportedEncodingException e ){ 115 | retString = ""; 116 | } 117 | return retString; 118 | } 119 | 120 | 121 | 122 | } 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_Params.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.net.URLEncoder; 5 | 6 | 7 | 8 | public class AlchemyAPI_Params { 9 | public static final String OUTPUT_XML = "xml"; 10 | public static final String OUTPUT_RDF = "rdf"; 11 | 12 | private String url; 13 | private String html; 14 | private String text; 15 | private String outputMode = OUTPUT_XML; 16 | private String customParameters; 17 | 18 | public String getUrl() { 19 | return url; 20 | } 21 | public void setUrl(String url) { 22 | this.url = url; 23 | } 24 | public String getHtml() { 25 | return html; 26 | } 27 | public void setHtml(String html) { 28 | this.html = html; 29 | } 30 | public String getText() { 31 | return text; 32 | } 33 | public void setText(String text) { 34 | this.text = text; 35 | } 36 | public String getOutputMode() { 37 | return outputMode; 38 | } 39 | public void setOutputMode(String outputMode) { 40 | if( !outputMode.equals(AlchemyAPI_Params.OUTPUT_XML) && !outputMode.equals(OUTPUT_RDF) ) 41 | { 42 | throw new RuntimeException("Invalid setting " + outputMode + " for parameter outputMode"); 43 | } 44 | this.outputMode = outputMode; 45 | } 46 | public String getCustomParameters() { 47 | return customParameters; 48 | } 49 | 50 | public void setCustomParameters(String... customParameters) { 51 | StringBuilder data = new StringBuilder(); 52 | try{ 53 | for (int i = 0; i < customParameters.length; ++i) { 54 | data.append('&').append(customParameters[i]); 55 | if (++i < customParameters.length) 56 | data.append('=').append(URLEncoder.encode(customParameters[i], "UTF8")); 57 | } 58 | } 59 | catch(UnsupportedEncodingException e){ 60 | this.customParameters = ""; 61 | return; 62 | } 63 | this.customParameters = data.toString(); 64 | } 65 | 66 | public String getParameterString(){ 67 | String retString = ""; 68 | try{ 69 | if(url!=null) retString+="&url="+URLEncoder.encode(url,"UTF-8"); 70 | if(html!=null) retString+="&html="+URLEncoder.encode(html,"UTF-8"); 71 | if(text!=null) retString+="&text="+URLEncoder.encode(text,"UTF-8"); 72 | if(customParameters!=null) retString+=customParameters; 73 | if(outputMode!=null) retString+="&outputMode="+outputMode; 74 | } 75 | catch(UnsupportedEncodingException e ){ 76 | retString = ""; 77 | } 78 | return retString; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_RelationParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_RelationParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | 14 | private Boolean disambiguate; 15 | private Boolean linkedData; 16 | private Boolean coreference; 17 | private String sourceText; 18 | private Boolean showSourceText; 19 | private Boolean entities; 20 | private Boolean sentimentExcludeEntities; 21 | private Boolean requireEntities; 22 | private String cQuery; 23 | private String xPath; 24 | private Integer maxRetrieve; 25 | private String baseUrl; 26 | private Boolean sentiment; 27 | 28 | public boolean isDisambiguate() { 29 | return disambiguate; 30 | } 31 | public void setDisambiguate(boolean disambiguate) { 32 | this.disambiguate = disambiguate; 33 | } 34 | public boolean isLinkedData() { 35 | return linkedData; 36 | } 37 | public void setLinkedData(boolean linkedData) { 38 | this.linkedData = linkedData; 39 | } 40 | public boolean isCoreference() { 41 | return coreference; 42 | } 43 | public void setCoreference(boolean coreference) { 44 | this.coreference = coreference; 45 | } 46 | 47 | public String getSourceText() { 48 | return sourceText; 49 | } 50 | public void setSourceText(String sourceText) { 51 | if( !sourceText.equals(AlchemyAPI_NamedEntityParams.CLEANED) && !sourceText.equals(AlchemyAPI_NamedEntityParams.CLEANED_OR_RAW) 52 | && !sourceText.equals(AlchemyAPI_NamedEntityParams.RAW) && !sourceText.equals(AlchemyAPI_NamedEntityParams.CQUERY) 53 | && !sourceText.equals(AlchemyAPI_NamedEntityParams.XPATH)) 54 | { 55 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 56 | } 57 | this.sourceText = sourceText; 58 | } 59 | public boolean isShowSourceText() { 60 | return showSourceText; 61 | } 62 | public void setShowSourceText(boolean showSourceText) { 63 | this.showSourceText = showSourceText; 64 | } 65 | public boolean isEntities() { 66 | return entities; 67 | } 68 | public void setEntities(boolean entities) { 69 | this.entities = entities; 70 | } 71 | public boolean isSentimentExcludeEntities() { 72 | return sentimentExcludeEntities; 73 | } 74 | public void setSentimentExcludeEntities(boolean sentimentExcludeEntities) { 75 | this.sentimentExcludeEntities = sentimentExcludeEntities; 76 | } 77 | public boolean isRequireEntities() { 78 | return requireEntities; 79 | } 80 | public void setRequireEntities(boolean requireEntities) { 81 | this.requireEntities = requireEntities; 82 | } 83 | public String getCQuery() { 84 | return cQuery; 85 | } 86 | public void setCQuery(String cQuery) { 87 | this.cQuery = cQuery; 88 | } 89 | public String getXPath() { 90 | return xPath; 91 | } 92 | public void setXPath(String xPath) { 93 | this.xPath = xPath; 94 | } 95 | public int getMaxRetrieve() { 96 | return maxRetrieve; 97 | } 98 | public void setMaxRetrieve(int maxRetrieve) { 99 | this.maxRetrieve = maxRetrieve; 100 | } 101 | public String getBaseUrl() { 102 | return baseUrl; 103 | } 104 | public void setBaseUrl(String baseUrl) { 105 | this.baseUrl = baseUrl; 106 | } 107 | public boolean isSentiment() { 108 | return sentiment; 109 | } 110 | public void setSentiment(boolean sentiment) { 111 | this.sentiment = sentiment; 112 | } 113 | 114 | public String getParameterString(){ 115 | String retString = super.getParameterString(); 116 | try{ 117 | if(disambiguate!=null) retString+="&disambiguate="+(disambiguate ? "1":"0"); 118 | if(linkedData!=null) retString+="&linkedData="+(linkedData?"1":"0"); 119 | if(coreference!=null) retString+="&coreference="+(coreference?"1":"0"); 120 | if(sourceText!=null) retString+="&sourceText="+sourceText; 121 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 122 | if(entities!=null) retString+="&entities="+(entities?"1":"0"); 123 | if(sentimentExcludeEntities!=null) retString+="&sentimentExcludeEntities="+(sentimentExcludeEntities?"1":"0"); 124 | if(requireEntities!=null) retString+="&requireEntities="+(requireEntities?"1":"0"); 125 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 126 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 127 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 128 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 129 | if(sentiment!=null) retString+="&sentiment="+(sentiment?"1":"0"); 130 | } 131 | catch(UnsupportedEncodingException e ){ 132 | retString = ""; 133 | } 134 | return retString; 135 | } 136 | 137 | } 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_TargetedSentimentParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.net.URLEncoder; 5 | 6 | public class AlchemyAPI_TargetedSentimentParams extends AlchemyAPI_Params { 7 | 8 | private Boolean showSourceText; 9 | private String target; 10 | 11 | public boolean isShowSourceText() { 12 | return showSourceText; 13 | } 14 | 15 | public void setShowSourceText(boolean showSourceText) { 16 | this.showSourceText = showSourceText; 17 | } 18 | 19 | public String getTarget(){ 20 | return target; 21 | } 22 | 23 | public void setTarget(String target) { 24 | this.target = target; 25 | } 26 | 27 | public String getParameterString(){ 28 | String retString = super.getParameterString(); 29 | try{ 30 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 31 | if(target!=null) retString+="&target="+URLEncoder.encode(target, "UTF-8"); 32 | 33 | } 34 | catch(UnsupportedEncodingException e ){ 35 | retString = ""; 36 | } 37 | 38 | return retString; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_TaxonomyParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | import java.net.URLEncoder; 3 | import java.io.UnsupportedEncodingException; 4 | 5 | 6 | 7 | public class AlchemyAPI_TaxonomyParams extends AlchemyAPI_Params{ 8 | public static final String CLEANED_OR_RAW = "cleaned_or_raw"; 9 | public static final String CLEANED = "cleaned"; 10 | public static final String RAW = "raw"; 11 | public static final String CQUERY = "cquery"; 12 | public static final String XPATH = "xpath"; 13 | 14 | private Boolean disambiguate; 15 | private Boolean linkedData; 16 | private Boolean coreference; 17 | private Boolean quotations; 18 | private String sourceText; 19 | private Boolean showSourceText; 20 | private String cQuery; 21 | private String xPath; 22 | private Integer maxRetrieve; 23 | private String baseUrl; 24 | private Boolean sentiment; 25 | 26 | public boolean isDisambiguate() { 27 | return disambiguate; 28 | } 29 | public void setDisambiguate(boolean disambiguate) { 30 | this.disambiguate = disambiguate; 31 | } 32 | public boolean isLinkedData() { 33 | return linkedData; 34 | } 35 | public void setLinkedData(boolean linkedData) { 36 | this.linkedData = linkedData; 37 | } 38 | public boolean isCoreference() { 39 | return coreference; 40 | } 41 | public void setCoreference(boolean coreference) { 42 | this.coreference = coreference; 43 | } 44 | public boolean isQuotations() { 45 | return quotations; 46 | } 47 | public void setQuotations(boolean quotations) { 48 | this.quotations = quotations; 49 | } 50 | public String getSourceText() { 51 | return sourceText; 52 | } 53 | public void setSourceText(String sourceText) { 54 | if( !sourceText.equals(AlchemyAPI_TaxonomyParams.CLEANED) && !sourceText.equals(AlchemyAPI_TaxonomyParams.CLEANED_OR_RAW) 55 | && !sourceText.equals(AlchemyAPI_TaxonomyParams.RAW) && !sourceText.equals(AlchemyAPI_TaxonomyParams.CQUERY) 56 | && !sourceText.equals(AlchemyAPI_TaxonomyParams.XPATH)) 57 | { 58 | throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText"); 59 | } 60 | this.sourceText = sourceText; 61 | } 62 | public boolean isShowSourceText() { 63 | return showSourceText; 64 | } 65 | public void setShowSourceText(boolean showSourceText) { 66 | this.showSourceText = showSourceText; 67 | } 68 | public String getCQuery() { 69 | return cQuery; 70 | } 71 | public void setCQuery(String cQuery) { 72 | this.cQuery = cQuery; 73 | } 74 | public String getXPath() { 75 | return xPath; 76 | } 77 | public void setXPath(String xPath) { 78 | this.xPath = xPath; 79 | } 80 | public int getMaxRetrieve() { 81 | return maxRetrieve; 82 | } 83 | public void setMaxRetrieve(int maxRetrieve) { 84 | this.maxRetrieve = maxRetrieve; 85 | } 86 | public String getBaseUrl() { 87 | return baseUrl; 88 | } 89 | public void setBaseUrl(String baseUrl) { 90 | this.baseUrl = baseUrl; 91 | } 92 | public boolean isSentiment() { 93 | return sentiment; 94 | } 95 | public void setSentiment(boolean sentiment) { 96 | this.sentiment = sentiment; 97 | } 98 | 99 | public String getParameterString(){ 100 | String retString = super.getParameterString(); 101 | try{ 102 | if(disambiguate!=null) retString+="&disambiguate="+(disambiguate ? "1":"0"); 103 | if(linkedData!=null) retString+="&linkedData="+(linkedData?"1":"0"); 104 | if(coreference!=null) retString+="&coreference="+(coreference?"1":"0"); 105 | if(quotations!=null) retString+=""ations="+(quotations?"1":"0"); 106 | if(sourceText!=null) retString+="&sourceText="+sourceText; 107 | if(showSourceText!=null) retString+="&showSourceText="+(showSourceText?"1":"0"); 108 | if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8"); 109 | if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8"); 110 | if(maxRetrieve!=null) retString+="&maxRetrieve="+maxRetrieve.toString(); 111 | if(baseUrl!=null) retString+="&baseUrl="+URLEncoder.encode(baseUrl,"UTF-8"); 112 | if(sentiment!=null) retString+="&sentiment="+(sentiment?"1":"0"); 113 | } 114 | catch(UnsupportedEncodingException e ){ 115 | retString = ""; 116 | } 117 | return retString; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/api/AlchemyAPI_TextParams.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.api; 2 | 3 | 4 | public class AlchemyAPI_TextParams extends AlchemyAPI_Params{ 5 | private Boolean useMetaData; 6 | private Boolean extractLinks; 7 | 8 | public boolean isUseMetaData() { 9 | return useMetaData; 10 | } 11 | 12 | public void setUseMetaData(boolean useMetaData) { 13 | this.useMetaData = useMetaData; 14 | } 15 | 16 | public boolean isExtractLinks() { 17 | return extractLinks; 18 | } 19 | 20 | public void setExtractLinks(boolean extractLinks) { 21 | this.extractLinks = extractLinks; 22 | } 23 | 24 | public String getParameterString(){ 25 | String retString = super.getParameterString(); 26 | 27 | if(useMetaData!=null) retString+="&useMetaData="+(useMetaData?"1":"0"); 28 | if(extractLinks!=null) retString+="&extractLinks="+(extractLinks?"1":"0"); 29 | 30 | return retString; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/AuthorTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | 9 | import javax.xml.parsers.ParserConfigurationException; 10 | import javax.xml.xpath.XPathExpressionException; 11 | import javax.xml.transform.Transformer; 12 | import javax.xml.transform.TransformerException; 13 | import javax.xml.transform.TransformerFactory; 14 | import javax.xml.transform.dom.DOMSource; 15 | import javax.xml.transform.stream.StreamResult; 16 | 17 | public class AuthorTest { 18 | 19 | 20 | public static void main(String[] args) 21 | throws IOException, SAXException, 22 | ParserConfigurationException, XPathExpressionException 23 | { 24 | // Create an AlchemyAPI object. 25 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 26 | 27 | // Load a HTML document to analyze. 28 | String htmlDoc = getFileContents("data/example.html"); 29 | 30 | Document doc = alchemyObj.URLGetAuthor("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html"); 31 | System.out.println(getStringFromDocument(doc)); 32 | 33 | doc = alchemyObj.HTMLGetAuthor(htmlDoc, "http://www.test.com/"); 34 | System.out.println(getStringFromDocument(doc)); 35 | } 36 | 37 | // utility function 38 | private static String getFileContents(String filename) 39 | throws IOException, FileNotFoundException 40 | { 41 | File file = new File(filename); 42 | StringBuilder contents = new StringBuilder(); 43 | 44 | BufferedReader input = new BufferedReader(new FileReader(file)); 45 | 46 | try { 47 | String line = null; 48 | 49 | while ((line = input.readLine()) != null) { 50 | contents.append(line); 51 | contents.append(System.getProperty("line.separator")); 52 | } 53 | } finally { 54 | input.close(); 55 | } 56 | 57 | return contents.toString(); 58 | } 59 | 60 | // utility method 61 | private static String getStringFromDocument(Document doc) { 62 | try { 63 | DOMSource domSource = new DOMSource(doc); 64 | StringWriter writer = new StringWriter(); 65 | StreamResult result = new StreamResult(writer); 66 | 67 | TransformerFactory tf = TransformerFactory.newInstance(); 68 | Transformer transformer = tf.newTransformer(); 69 | transformer.transform(domSource, result); 70 | 71 | return writer.toString(); 72 | } catch (TransformerException ex) { 73 | ex.printStackTrace(); 74 | return null; 75 | } 76 | } 77 | 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/CategoryTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class CategoryTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Categorize a web URL by topic. 25 | Document doc = alchemyObj.URLGetCategory("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Categorize some text. 29 | doc = alchemyObj.TextGetCategory("Latest on the War in Iraq."); 30 | System.out.println(getStringFromDocument(doc)); 31 | 32 | // Load a HTML document to analyze. 33 | String htmlDoc = getFileContents("data/example.html"); 34 | 35 | // Categorize a HTML document by topic. 36 | doc = alchemyObj.HTMLGetCategory(htmlDoc, "http://www.test.com/"); 37 | System.out.println(getStringFromDocument(doc)); 38 | 39 | AlchemyAPI_CategoryParams categoryParams = new AlchemyAPI_CategoryParams(); 40 | categoryParams.setOutputMode(AlchemyAPI_Params.OUTPUT_RDF); 41 | doc = alchemyObj.HTMLGetCategory(htmlDoc, "http://www.test.com/", categoryParams); 42 | System.out.println(getStringFromDocument(doc)); 43 | } 44 | 45 | // utility function 46 | private static String getFileContents(String filename) 47 | throws IOException, FileNotFoundException 48 | { 49 | File file = new File(filename); 50 | StringBuilder contents = new StringBuilder(); 51 | 52 | BufferedReader input = new BufferedReader(new FileReader(file)); 53 | 54 | try { 55 | String line = null; 56 | 57 | while ((line = input.readLine()) != null) { 58 | contents.append(line); 59 | contents.append(System.getProperty("line.separator")); 60 | } 61 | } finally { 62 | input.close(); 63 | } 64 | 65 | return contents.toString(); 66 | } 67 | 68 | // utility method 69 | private static String getStringFromDocument(Document doc) { 70 | try { 71 | DOMSource domSource = new DOMSource(doc); 72 | StringWriter writer = new StringWriter(); 73 | StreamResult result = new StreamResult(writer); 74 | 75 | TransformerFactory tf = TransformerFactory.newInstance(); 76 | Transformer transformer = tf.newTransformer(); 77 | transformer.transform(domSource, result); 78 | 79 | return writer.toString(); 80 | } catch (TransformerException ex) { 81 | ex.printStackTrace(); 82 | return null; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/CombinedTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class CombinedTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract combined data for a web URL. 25 | Document doc = alchemyObj.URLGetCombined("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Extract combined data from a text string. 29 | doc = alchemyObj.TextGetCombined( 30 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 31 | "Where do you live, Fred?"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Only extract entities & keywords 35 | AlchemyAPI_CombinedParams combinedParams = new AlchemyAPI_CombinedParams(); 36 | combinedParams.setSentiment(true); 37 | combinedParams.setExtract("entity"); 38 | combinedParams.setExtract("keyword"); 39 | doc = alchemyObj.TextGetCombined("Madonna enjoys tasty Pepsi. I love her style.", combinedParams); 40 | System.out.println(getStringFromDocument(doc)); 41 | } 42 | 43 | // utility function 44 | private static String getFileContents(String filename) 45 | throws IOException, FileNotFoundException 46 | { 47 | File file = new File(filename); 48 | StringBuilder contents = new StringBuilder(); 49 | 50 | BufferedReader input = new BufferedReader(new FileReader(file)); 51 | 52 | try { 53 | String line = null; 54 | 55 | while ((line = input.readLine()) != null) { 56 | contents.append(line); 57 | contents.append(System.getProperty("line.separator")); 58 | } 59 | } finally { 60 | input.close(); 61 | } 62 | 63 | return contents.toString(); 64 | } 65 | 66 | // utility method 67 | private static String getStringFromDocument(Document doc) { 68 | try { 69 | DOMSource domSource = new DOMSource(doc); 70 | StringWriter writer = new StringWriter(); 71 | StreamResult result = new StreamResult(writer); 72 | 73 | TransformerFactory tf = TransformerFactory.newInstance(); 74 | Transformer transformer = tf.newTransformer(); 75 | transformer.transform(domSource, result); 76 | 77 | return writer.toString(); 78 | } catch (TransformerException ex) { 79 | ex.printStackTrace(); 80 | return null; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/ConceptTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class ConceptTest { 17 | public static void main(String[] args) throws IOException, SAXException, 18 | ParserConfigurationException, XPathExpressionException { 19 | // Create an AlchemyAPI object. 20 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 21 | 22 | // Extract concept tags for a web URL. 23 | Document doc = alchemyObj.URLGetRankedConcepts("http://www.techcrunch.com/"); 24 | System.out.println(getStringFromDocument(doc)); 25 | 26 | // Extract concept tags for a text string. 27 | doc = alchemyObj.TextGetRankedConcepts( 28 | "This thing has a steering wheel, tires, and an engine. Do you know what it is?"); 29 | System.out.println(getStringFromDocument(doc)); 30 | 31 | // Load a HTML document to analyze. 32 | String htmlDoc = getFileContents("data/example.html"); 33 | 34 | // Extract concept tags for a HTML document. 35 | doc = alchemyObj.HTMLGetRankedConcepts(htmlDoc, "http://www.test.com/"); 36 | System.out.println(getStringFromDocument(doc)); 37 | } 38 | 39 | // utility function 40 | private static String getFileContents(String filename) 41 | throws IOException, FileNotFoundException 42 | { 43 | File file = new File(filename); 44 | StringBuilder contents = new StringBuilder(); 45 | 46 | BufferedReader input = new BufferedReader(new FileReader(file)); 47 | 48 | try { 49 | String line = null; 50 | 51 | while ((line = input.readLine()) != null) { 52 | contents.append(line); 53 | contents.append(System.getProperty("line.separator")); 54 | } 55 | } finally { 56 | input.close(); 57 | } 58 | 59 | return contents.toString(); 60 | } 61 | 62 | // utility method 63 | private static String getStringFromDocument(Document doc) { 64 | try { 65 | DOMSource domSource = new DOMSource(doc); 66 | StringWriter writer = new StringWriter(); 67 | StreamResult result = new StreamResult(writer); 68 | 69 | TransformerFactory tf = TransformerFactory.newInstance(); 70 | Transformer transformer = tf.newTransformer(); 71 | transformer.transform(domSource, result); 72 | 73 | return writer.toString(); 74 | } catch (TransformerException ex) { 75 | ex.printStackTrace(); 76 | return null; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/ConstraintQueryTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class ConstraintQueryTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract first link from an URL. 25 | Document doc = alchemyObj.URLGetConstraintQuery("http://microformats.org/wiki/hcard", 26 | "1st link"); 27 | System.out.println(getStringFromDocument(doc)); 28 | 29 | // Extract first link from a HTML. 30 | String htmlDoc = getFileContents("data/example.html"); 31 | doc = alchemyObj.HTMLGetConstraintQuery(htmlDoc, "http://www.test.com/", "1st link"); 32 | System.out.println(getStringFromDocument(doc)); 33 | } 34 | 35 | // utility function 36 | private static String getFileContents(String filename) 37 | throws IOException, FileNotFoundException 38 | { 39 | File file = new File(filename); 40 | StringBuilder contents = new StringBuilder(); 41 | 42 | BufferedReader input = new BufferedReader(new FileReader(file)); 43 | 44 | try { 45 | String line = null; 46 | 47 | while ((line = input.readLine()) != null) { 48 | contents.append(line); 49 | contents.append(System.getProperty("line.separator")); 50 | } 51 | } finally { 52 | input.close(); 53 | } 54 | 55 | return contents.toString(); 56 | } 57 | 58 | // utility method 59 | private static String getStringFromDocument(Document doc) { 60 | try { 61 | DOMSource domSource = new DOMSource(doc); 62 | StringWriter writer = new StringWriter(); 63 | StreamResult result = new StreamResult(writer); 64 | 65 | TransformerFactory tf = TransformerFactory.newInstance(); 66 | Transformer transformer = tf.newTransformer(); 67 | transformer.transform(domSource, result); 68 | 69 | return writer.toString(); 70 | } catch (TransformerException ex) { 71 | ex.printStackTrace(); 72 | return null; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/EntityTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class EntityTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract a ranked list of named entities for a web URL. 25 | Document doc = alchemyObj.URLGetRankedNamedEntities("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Extract a ranked list of named entities from a text string. 29 | doc = alchemyObj.TextGetRankedNamedEntities( 30 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 31 | "Where do you live, Fred?"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Load a HTML document to analyze. 35 | String htmlDoc = getFileContents("data/example.html"); 36 | 37 | // Extract a ranked list of named entities from a HTML document. 38 | doc = alchemyObj.HTMLGetRankedNamedEntities(htmlDoc, "http://www.test.com/"); 39 | System.out.println(getStringFromDocument(doc)); 40 | } 41 | 42 | // utility function 43 | private static String getFileContents(String filename) 44 | throws IOException, FileNotFoundException 45 | { 46 | File file = new File(filename); 47 | StringBuilder contents = new StringBuilder(); 48 | 49 | BufferedReader input = new BufferedReader(new FileReader(file)); 50 | 51 | try { 52 | String line = null; 53 | 54 | while ((line = input.readLine()) != null) { 55 | contents.append(line); 56 | contents.append(System.getProperty("line.separator")); 57 | } 58 | } finally { 59 | input.close(); 60 | } 61 | 62 | return contents.toString(); 63 | } 64 | 65 | // utility method 66 | private static String getStringFromDocument(Document doc) { 67 | try { 68 | DOMSource domSource = new DOMSource(doc); 69 | StringWriter writer = new StringWriter(); 70 | StreamResult result = new StreamResult(writer); 71 | 72 | TransformerFactory tf = TransformerFactory.newInstance(); 73 | Transformer transformer = tf.newTransformer(); 74 | transformer.transform(domSource, result); 75 | 76 | return writer.toString(); 77 | } catch (TransformerException ex) { 78 | ex.printStackTrace(); 79 | return null; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/FeedLinksTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class FeedLinksTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract RSS / ATOM feed links from a web URL. 25 | Document doc = alchemyObj.URLGetFeedLinks("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Load a HTML document to analyze. 29 | String htmlDoc = getFileContents("data/example.html"); 30 | 31 | // Extract RSS / ATOM feed links from a HTML document. 32 | doc = alchemyObj.HTMLGetFeedLinks(htmlDoc, "http://www.test.com/"); 33 | System.out.println(getStringFromDocument(doc)); 34 | } 35 | 36 | // utility function 37 | private static String getFileContents(String filename) 38 | throws IOException, FileNotFoundException 39 | { 40 | File file = new File(filename); 41 | StringBuilder contents = new StringBuilder(); 42 | 43 | BufferedReader input = new BufferedReader(new FileReader(file)); 44 | 45 | try { 46 | String line = null; 47 | 48 | while ((line = input.readLine()) != null) { 49 | contents.append(line); 50 | contents.append(System.getProperty("line.separator")); 51 | } 52 | } finally { 53 | input.close(); 54 | } 55 | 56 | return contents.toString(); 57 | } 58 | 59 | // utility method 60 | private static String getStringFromDocument(Document doc) { 61 | try { 62 | DOMSource domSource = new DOMSource(doc); 63 | StringWriter writer = new StringWriter(); 64 | StreamResult result = new StreamResult(writer); 65 | 66 | TransformerFactory tf = TransformerFactory.newInstance(); 67 | Transformer transformer = tf.newTransformer(); 68 | transformer.transform(domSource, result); 69 | 70 | return writer.toString(); 71 | } catch (TransformerException ex) { 72 | ex.printStackTrace(); 73 | return null; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/ImageTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class ImageTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract image for a web URL. 25 | Document doc = alchemyObj.URLGetImage("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | } 28 | 29 | // utility function 30 | private static String getFileContents(String filename) 31 | throws IOException, FileNotFoundException 32 | { 33 | File file = new File(filename); 34 | StringBuilder contents = new StringBuilder(); 35 | 36 | BufferedReader input = new BufferedReader(new FileReader(file)); 37 | 38 | try { 39 | String line = null; 40 | 41 | while ((line = input.readLine()) != null) { 42 | contents.append(line); 43 | contents.append(System.getProperty("line.separator")); 44 | } 45 | } finally { 46 | input.close(); 47 | } 48 | 49 | return contents.toString(); 50 | } 51 | 52 | // utility method 53 | private static String getStringFromDocument(Document doc) { 54 | try { 55 | DOMSource domSource = new DOMSource(doc); 56 | StringWriter writer = new StringWriter(); 57 | StreamResult result = new StreamResult(writer); 58 | 59 | TransformerFactory tf = TransformerFactory.newInstance(); 60 | Transformer transformer = tf.newTransformer(); 61 | transformer.transform(domSource, result); 62 | 63 | return writer.toString(); 64 | } catch (TransformerException ex) { 65 | ex.printStackTrace(); 66 | return null; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/KeywordTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class KeywordTest { 17 | public static void main(String[] args) throws IOException, SAXException, 18 | ParserConfigurationException, XPathExpressionException { 19 | // Create an AlchemyAPI object. 20 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 21 | 22 | // Extract topic keywords for a web URL. 23 | Document doc = alchemyObj.URLGetRankedKeywords("http://www.techcrunch.com/"); 24 | System.out.println(getStringFromDocument(doc)); 25 | 26 | // Extract topic keywords for a text string. 27 | doc = alchemyObj.TextGetRankedKeywords( 28 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 29 | "Where do you live, Fred?"); 30 | System.out.println(getStringFromDocument(doc)); 31 | 32 | // Load a HTML document to analyze. 33 | String htmlDoc = getFileContents("data/example.html"); 34 | 35 | // Extract topic keywords for a HTML document. 36 | doc = alchemyObj.HTMLGetRankedKeywords(htmlDoc, "http://www.test.com/"); 37 | System.out.println(getStringFromDocument(doc)); 38 | } 39 | 40 | // utility function 41 | private static String getFileContents(String filename) 42 | throws IOException, FileNotFoundException 43 | { 44 | File file = new File(filename); 45 | StringBuilder contents = new StringBuilder(); 46 | 47 | BufferedReader input = new BufferedReader(new FileReader(file)); 48 | 49 | try { 50 | String line = null; 51 | 52 | while ((line = input.readLine()) != null) { 53 | contents.append(line); 54 | contents.append(System.getProperty("line.separator")); 55 | } 56 | } finally { 57 | input.close(); 58 | } 59 | 60 | return contents.toString(); 61 | } 62 | 63 | // utility method 64 | private static String getStringFromDocument(Document doc) { 65 | try { 66 | DOMSource domSource = new DOMSource(doc); 67 | StringWriter writer = new StringWriter(); 68 | StreamResult result = new StreamResult(writer); 69 | 70 | TransformerFactory tf = TransformerFactory.newInstance(); 71 | Transformer transformer = tf.newTransformer(); 72 | transformer.transform(domSource, result); 73 | 74 | return writer.toString(); 75 | } catch (TransformerException ex) { 76 | ex.printStackTrace(); 77 | return null; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/LanguageTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class LanguageTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Detect the language for a web URL. 25 | Document doc = alchemyObj.URLGetLanguage("http://news.google.fr/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Detect the language for a text string (requires at least 100 29 | // characters). 30 | String htmlDoc = getFileContents("data/example.html"); 31 | doc = alchemyObj.TextGetLanguage("This is some english language text. What language do you speak?"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Load a HTML document to analyze. 35 | htmlDoc = getFileContents("data/example.html"); 36 | 37 | // Detect the language for a HTML document. 38 | doc = alchemyObj.HTMLGetLanguage(htmlDoc, "http://www.test.com/"); 39 | System.out.println(getStringFromDocument(doc)); 40 | } 41 | 42 | // utility function 43 | private static String getFileContents(String filename) throws IOException, 44 | FileNotFoundException { 45 | File file = new File(filename); 46 | StringBuilder contents = new StringBuilder(); 47 | 48 | BufferedReader input = new BufferedReader(new FileReader(file)); 49 | 50 | try { 51 | String line = null; 52 | 53 | while ((line = input.readLine()) != null) { 54 | contents.append(line); 55 | contents.append(System.getProperty("line.separator")); 56 | } 57 | } finally { 58 | input.close(); 59 | } 60 | 61 | return contents.toString(); 62 | } 63 | 64 | // utility method 65 | private static String getStringFromDocument(Document doc) { 66 | try { 67 | DOMSource domSource = new DOMSource(doc); 68 | StringWriter writer = new StringWriter(); 69 | StreamResult result = new StreamResult(writer); 70 | 71 | TransformerFactory tf = TransformerFactory.newInstance(); 72 | Transformer transformer = tf.newTransformer(); 73 | transformer.transform(domSource, result); 74 | 75 | return writer.toString(); 76 | } catch (TransformerException ex) { 77 | ex.printStackTrace(); 78 | return null; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/MicroformatTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class MicroformatsTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract microformats data from a web URL. 25 | Document doc = alchemyObj.URLGetMicroformats("http://microformats.org/wiki/hcard"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Load a HTML document to analyze. 29 | String htmlDoc = getFileContents("data/microformats.html"); 30 | 31 | // Extract microformats data from a HTML document. 32 | doc = alchemyObj.HTMLGetMicroformats(htmlDoc, "http://www.test.com/"); 33 | System.out.println(getStringFromDocument(doc)); 34 | } 35 | 36 | // utility function 37 | private static String getFileContents(String filename) 38 | throws IOException, FileNotFoundException 39 | { 40 | File file = new File(filename); 41 | StringBuilder contents = new StringBuilder(); 42 | 43 | BufferedReader input = new BufferedReader(new FileReader(file)); 44 | 45 | try { 46 | String line = null; 47 | 48 | while ((line = input.readLine()) != null) { 49 | contents.append(line); 50 | contents.append(System.getProperty("line.separator")); 51 | } 52 | } finally { 53 | input.close(); 54 | } 55 | 56 | return contents.toString(); 57 | } 58 | 59 | // utility method 60 | private static String getStringFromDocument(Document doc) { 61 | try { 62 | DOMSource domSource = new DOMSource(doc); 63 | StringWriter writer = new StringWriter(); 64 | StreamResult result = new StreamResult(writer); 65 | 66 | TransformerFactory tf = TransformerFactory.newInstance(); 67 | Transformer transformer = tf.newTransformer(); 68 | transformer.transform(domSource, result); 69 | 70 | return writer.toString(); 71 | } catch (TransformerException ex) { 72 | ex.printStackTrace(); 73 | return null; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/ParameterTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class ParameterTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract a ranked list of named entities for a web URL. Turn off disambiguation 25 | AlchemyAPI_NamedEntityParams entityParams = new AlchemyAPI_NamedEntityParams(); 26 | entityParams.setDisambiguate(false); 27 | entityParams.setSentiment(true); 28 | Document doc = alchemyObj.URLGetRankedNamedEntities("http://www.techcrunch.com/", entityParams); 29 | System.out.println(getStringFromDocument(doc)); 30 | 31 | // Extract a ranked list of named entities from a text string. 32 | doc = alchemyObj.TextGetRankedNamedEntities( 33 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 34 | "Where do you live, Fred?", entityParams); 35 | System.out.println(getStringFromDocument(doc)); 36 | 37 | // Load a HTML document to analyze. 38 | String htmlDoc = getFileContents("data/example.html"); 39 | 40 | // Extract a ranked list of named entities from a HTML document. 41 | doc = alchemyObj.HTMLGetRankedNamedEntities(htmlDoc, "http://www.test.com/", entityParams); 42 | System.out.println(getStringFromDocument(doc)); 43 | 44 | } 45 | 46 | // utility function 47 | private static String getFileContents(String filename) 48 | throws IOException, FileNotFoundException 49 | { 50 | File file = new File(filename); 51 | StringBuilder contents = new StringBuilder(); 52 | 53 | BufferedReader input = new BufferedReader(new FileReader(file)); 54 | 55 | try { 56 | String line = null; 57 | 58 | while ((line = input.readLine()) != null) { 59 | contents.append(line); 60 | contents.append(System.getProperty("line.separator")); 61 | } 62 | } finally { 63 | input.close(); 64 | } 65 | 66 | return contents.toString(); 67 | } 68 | 69 | // utility method 70 | private static String getStringFromDocument(Document doc) { 71 | try { 72 | DOMSource domSource = new DOMSource(doc); 73 | StringWriter writer = new StringWriter(); 74 | StreamResult result = new StreamResult(writer); 75 | 76 | TransformerFactory tf = TransformerFactory.newInstance(); 77 | Transformer transformer = tf.newTransformer(); 78 | transformer.transform(domSource, result); 79 | 80 | return writer.toString(); 81 | } catch (TransformerException ex) { 82 | ex.printStackTrace(); 83 | return null; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/RelationsTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class RelationsTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract a ranked list of relations for a web URL. 25 | Document doc = alchemyObj.URLGetRelations("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Extract a ranked list of relations from a text string. 29 | doc = alchemyObj.TextGetRelations( 30 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 31 | "Where do you live, Fred?"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Load a HTML document to analyze. 35 | String htmlDoc = getFileContents("data/example.html"); 36 | 37 | // Extract a ranked list of relations from a HTML document. 38 | doc = alchemyObj.HTMLGetRelations(htmlDoc, "http://www.test.com/"); 39 | System.out.println(getStringFromDocument(doc)); 40 | 41 | AlchemyAPI_RelationParams relationParams = new AlchemyAPI_RelationParams(); 42 | relationParams.setSentiment(true); 43 | relationParams.setEntities(true); 44 | relationParams.setDisambiguate(true); 45 | relationParams.setSentimentExcludeEntities(true); 46 | doc = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi. I love her style.", relationParams); 47 | System.out.println(getStringFromDocument(doc)); 48 | 49 | relationParams.setSentiment(true); 50 | relationParams.setRequireEntities(true); 51 | relationParams.setSentimentExcludeEntities(true); 52 | doc = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi. I love her style.", relationParams); 53 | System.out.println(getStringFromDocument(doc)); 54 | } 55 | 56 | // utility function 57 | private static String getFileContents(String filename) 58 | throws IOException, FileNotFoundException 59 | { 60 | File file = new File(filename); 61 | StringBuilder contents = new StringBuilder(); 62 | 63 | BufferedReader input = new BufferedReader(new FileReader(file)); 64 | 65 | try { 66 | String line = null; 67 | 68 | while ((line = input.readLine()) != null) { 69 | contents.append(line); 70 | contents.append(System.getProperty("line.separator")); 71 | } 72 | } finally { 73 | input.close(); 74 | } 75 | 76 | return contents.toString(); 77 | } 78 | 79 | // utility method 80 | private static String getStringFromDocument(Document doc) { 81 | try { 82 | DOMSource domSource = new DOMSource(doc); 83 | StringWriter writer = new StringWriter(); 84 | StreamResult result = new StreamResult(writer); 85 | 86 | TransformerFactory tf = TransformerFactory.newInstance(); 87 | Transformer transformer = tf.newTransformer(); 88 | transformer.transform(domSource, result); 89 | 90 | return writer.toString(); 91 | } catch (TransformerException ex) { 92 | ex.printStackTrace(); 93 | return null; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/SentimentTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | import com.alchemyapi.api.*; 5 | 6 | import org.xml.sax.SAXException; 7 | import org.w3c.dom.Document; 8 | import java.io.*; 9 | import javax.xml.parsers.ParserConfigurationException; 10 | import javax.xml.xpath.XPathExpressionException; 11 | import javax.xml.transform.Transformer; 12 | import javax.xml.transform.TransformerException; 13 | import javax.xml.transform.TransformerFactory; 14 | import javax.xml.transform.dom.DOMSource; 15 | import javax.xml.transform.stream.StreamResult; 16 | 17 | class SentimentTest { 18 | public static void main(String[] args) throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException { 20 | // Create an AlchemyAPI object. 21 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 22 | 23 | // Extract sentiment for a web URL. 24 | Document doc = alchemyObj.URLGetTextSentiment("http://www.techcrunch.com/"); 25 | System.out.println(getStringFromDocument(doc)); 26 | 27 | // Extract sentiment for a text string. 28 | doc = alchemyObj.TextGetTextSentiment( 29 | "That hat is ridiculous, Charles."); 30 | System.out.println(getStringFromDocument(doc)); 31 | 32 | // Load a HTML document to analyze. 33 | String htmlDoc = getFileContents("data/example.html"); 34 | 35 | // Extract sentiment for a HTML document. 36 | doc = alchemyObj.HTMLGetTextSentiment(htmlDoc, "http://www.test.com/"); 37 | System.out.println(getStringFromDocument(doc)); 38 | 39 | // Extract entity-targeted sentiment from a HTML document. 40 | AlchemyAPI_NamedEntityParams entityParams = new AlchemyAPI_NamedEntityParams(); 41 | entityParams.setSentiment(true); 42 | doc = alchemyObj.TextGetRankedNamedEntities("That Mike Tyson is such a sweetheart.", entityParams); 43 | System.out.println(getStringFromDocument(doc)); 44 | 45 | // Extract keyword-targeted sentiment from a HTML document. 46 | AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams(); 47 | keywordParams.setSentiment(true); 48 | doc = alchemyObj.TextGetRankedKeywords("That Mike Tyson is such a sweetheart.", keywordParams); 49 | System.out.println(getStringFromDocument(doc)); 50 | 51 | //Extract Targeted Sentiment from text 52 | AlchemyAPI_TargetedSentimentParams sentimentParams = new AlchemyAPI_TargetedSentimentParams(); 53 | sentimentParams.setShowSourceText(true); 54 | doc = alchemyObj.TextGetTargetedSentiment("This car is terrible.", "car", sentimentParams); 55 | System.out.print(getStringFromDocument(doc)); 56 | 57 | //Extract Targeted Sentiment from url 58 | doc = alchemyObj.URLGetTargetedSentiment("http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/", "Walmart",sentimentParams); 59 | System.out.print(getStringFromDocument(doc)); 60 | 61 | //Extract Targeted Sentiment from html 62 | doc = alchemyObj.HTMLGetTargetedSentiment(htmlDoc, "http://www.test.com/", "WujWuj", sentimentParams); 63 | System.out.print(getStringFromDocument(doc)); 64 | } 65 | 66 | // utility function 67 | private static String getFileContents(String filename) 68 | throws IOException, FileNotFoundException 69 | { 70 | File file = new File(filename); 71 | StringBuilder contents = new StringBuilder(); 72 | 73 | BufferedReader input = new BufferedReader(new FileReader(file)); 74 | 75 | try { 76 | String line = null; 77 | 78 | while ((line = input.readLine()) != null) { 79 | contents.append(line); 80 | contents.append(System.getProperty("line.separator")); 81 | } 82 | } finally { 83 | input.close(); 84 | } 85 | 86 | return contents.toString(); 87 | } 88 | 89 | // utility method 90 | private static String getStringFromDocument(Document doc) { 91 | try { 92 | DOMSource domSource = new DOMSource(doc); 93 | StringWriter writer = new StringWriter(); 94 | StreamResult result = new StreamResult(writer); 95 | 96 | TransformerFactory tf = TransformerFactory.newInstance(); 97 | Transformer transformer = tf.newTransformer(); 98 | transformer.transform(domSource, result); 99 | 100 | return writer.toString(); 101 | } catch (TransformerException ex) { 102 | ex.printStackTrace(); 103 | return null; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/TaxonomyTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.*; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class TaxonomyTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract a ranked list of relations for a web URL. 25 | Document doc = alchemyObj.URLGetTaxonomy("http://www.techcrunch.com/"); 26 | System.out.println(getStringFromDocument(doc)); 27 | 28 | // Extract a ranked taxonomy from a text string. 29 | doc = alchemyObj.TextGetTaxonomy( 30 | "Hello there, my name is Bob Jones. I live in the United States of America. " + 31 | "Where do you live, Fred?"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Load a HTML document to analyze. 35 | String htmlDoc = getFileContents("data/example.html"); 36 | 37 | // Extract a ranked taxonomy from a HTML document. 38 | doc = alchemyObj.HTMLGetTaxonomy(htmlDoc, "http://www.test.com/"); 39 | System.out.println(getStringFromDocument(doc)); 40 | } 41 | 42 | // utility function 43 | private static String getFileContents(String filename) 44 | throws IOException, FileNotFoundException 45 | { 46 | File file = new File(filename); 47 | StringBuilder contents = new StringBuilder(); 48 | 49 | BufferedReader input = new BufferedReader(new FileReader(file)); 50 | 51 | try { 52 | String line = null; 53 | 54 | while ((line = input.readLine()) != null) { 55 | contents.append(line); 56 | contents.append(System.getProperty("line.separator")); 57 | } 58 | } finally { 59 | input.close(); 60 | } 61 | 62 | return contents.toString(); 63 | } 64 | 65 | // utility method 66 | private static String getStringFromDocument(Document doc) { 67 | try { 68 | DOMSource domSource = new DOMSource(doc); 69 | StringWriter writer = new StringWriter(); 70 | StreamResult result = new StreamResult(writer); 71 | 72 | TransformerFactory tf = TransformerFactory.newInstance(); 73 | Transformer transformer = tf.newTransformer(); 74 | transformer.transform(domSource, result); 75 | 76 | return writer.toString(); 77 | } catch (TransformerException ex) { 78 | ex.printStackTrace(); 79 | return null; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/src/com/alchemyapi/test/TextExtractTest.java: -------------------------------------------------------------------------------- 1 | package com.alchemyapi.test; 2 | 3 | import com.alchemyapi.api.AlchemyAPI; 4 | 5 | import org.xml.sax.SAXException; 6 | import org.w3c.dom.Document; 7 | import java.io.*; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | import javax.xml.transform.Transformer; 11 | import javax.xml.transform.TransformerException; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.dom.DOMSource; 14 | import javax.xml.transform.stream.StreamResult; 15 | 16 | class TextExtractTest { 17 | public static void main(String[] args) 18 | throws IOException, SAXException, 19 | ParserConfigurationException, XPathExpressionException 20 | { 21 | // Create an AlchemyAPI object. 22 | AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt"); 23 | 24 | // Extract page text from a web URL. (ignoring ads, navigation links, 25 | // and other content). 26 | Document doc = alchemyObj.URLGetText("http://www.techcrunch.com/"); 27 | System.out.println(getStringFromDocument(doc)); 28 | 29 | // Extract raw page text from a web URL. (including ads, navigation 30 | // links, and other content). 31 | doc = alchemyObj.URLGetRawText("http://www.techcrunch.com/"); 32 | System.out.println(getStringFromDocument(doc)); 33 | 34 | // Extract a title from a web URL. 35 | doc = alchemyObj.URLGetTitle("http://www.techcrunch.com/"); 36 | System.out.println(getStringFromDocument(doc)); 37 | 38 | // Load a HTML document to analyze. 39 | String htmlDoc = getFileContents("data/example.html"); 40 | 41 | // Extract page text from a HTML document. (ignoring ads, navigation 42 | // links, and other content). 43 | doc = alchemyObj.HTMLGetText(htmlDoc, "http://www.test.com/"); 44 | System.out.println(getStringFromDocument(doc)); 45 | 46 | // Extract raw page text from a HTML document. (including ads, 47 | // navigation links, and other content). 48 | doc = alchemyObj.HTMLGetRawText(htmlDoc, "http://www.test.com/"); 49 | System.out.println(getStringFromDocument(doc)); 50 | 51 | // Extract a title from a HTML document. 52 | doc = alchemyObj.HTMLGetTitle(htmlDoc, "http://www.test.com/"); 53 | System.out.println(getStringFromDocument(doc)); 54 | } 55 | 56 | // utility function 57 | private static String getFileContents(String filename) 58 | throws IOException, FileNotFoundException 59 | { 60 | File file = new File(filename); 61 | StringBuilder contents = new StringBuilder(); 62 | 63 | BufferedReader input = new BufferedReader(new FileReader(file)); 64 | 65 | try { 66 | String line = null; 67 | 68 | while ((line = input.readLine()) != null) { 69 | contents.append(line); 70 | contents.append(System.getProperty("line.separator")); 71 | } 72 | } finally { 73 | input.close(); 74 | } 75 | 76 | return contents.toString(); 77 | } 78 | 79 | // utility method 80 | private static String getStringFromDocument(Document doc) { 81 | try { 82 | DOMSource domSource = new DOMSource(doc); 83 | StringWriter writer = new StringWriter(); 84 | StreamResult result = new StreamResult(writer); 85 | 86 | TransformerFactory tf = TransformerFactory.newInstance(); 87 | Transformer transformer = tf.newTransformer(); 88 | transformer.transform(domSource, result); 89 | 90 | return writer.toString(); 91 | } catch (TransformerException ex) { 92 | ex.printStackTrace(); 93 | return null; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/testdir/api_key.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/AlchemyAPI_Java-0.9/testdir/api_key.txt -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/testdir/data/example2_nolinks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | b> John P. Avlon is a CNN contributor and senior political columnist for The Daily Beast. He is the author of "Wingnuts: How the Lunatic Fringe is Hijacking America."

4 | New York (CNN) -- In a time of voter anger at unsustainable government spending and Washington hypocrisy, here's a story that should get your blood up.

5 |

Last week, the House of Representatives considered eliminating a nearly half-billion dollar earmark that was snuck into a defense authorization bill. But members of both parties 6 | voted to keep the corporate pork in the bill -- despite a supposed moratorium on earmarks and despite that the Pentagon has repeatedly said it doesn't want the money.

Only in 7 | Washington would bureaucracy be force-fed a project it doesn't want or need.

But so far, we haven't seen this contempt for taxpayer dollars make its way to protest signs or 8 | talk radio driven talking points. That's because President Obama opposes the earmark and the Republican congressional leadership voted for it.

This doesn't fit neatly into the 9 | hyperpartisan narrative of screaming about socialism -- in which Republicans bewail overspending by Democrats -- but it's a perfect illustration of how deep the dysfunction is in Washington. 10 |

At issue is the alternate engine for the Joint Strike Fighter platform, a corporate subsidized boondoggle that has cost taxpayers $1.2 billion in earmarks since 2004. It is 11 | estimated to cost at least $2.9 billion more until its completion.

Defenders argue that paying GE and Rolls Royce to develop a second engine for Air Force fighters will stimulate 12 | competition in the defense industry and bring down costs in the long run while protecting jobs in the short run.

Critics point out that crony capitalism can't create a true free 13 | market in the defense industry -- it's the equivalent of diet hucksters who claim you can eat yourself fitter. This is about money: pork barrel politics hiding under the noble banner of 14 | national defense.

Here's how the sordid story unfolded:

An anonymous earmark was added to the defense authorization bill, requesting $485 million in new funds for the 15 | alternate engine program, despite a much-ballyhooed moratorium on earmarks going to for-profit entities (agreed to by Democrats), and a total ban on earmark requests agreed to by 16 | Republicans for fiscal year 2011.

In reaction, a small bipartisan group of members of Congress -- led by Democrat Chellie Pingree of Maine and Republican Tom Rooney of Florida, 17 | joined by Democrat John Larson of Connecticut and Republican Lynn Westmoreland of Georgia -- proposed an amendment to strip the bill of the ugly anonymous earmark. Their principled stand 18 | went down to defeat by a vote of 193 to 231.

It's no surprise that in a recession, the congressional representatives of Ohio and Indiana would vote to keep the earmark subsidy in the 19 | bill, including the normally stalwart fiscal conservative Mike Pence of Indiana. Those states are benefiting most from the development of the engines in terms of jobs on the ground.

What's 20 | more surprising is why so many of their colleagues would climb on this pork-barrel bandwagon, including the Republican congressional leadership led by John Boehner and Eric Cantor, who are 21 | trying to build the midterm election campaign around a promise to restore fiscal discipline.

That selling job that should be even tougher since a majority of Democrats voted to kill 22 | the alternate engine and a majority of Republicans voted to keep it going.

"This was the first big earmark test for 2010, and Congress failed," said Thomas A. Schatz, the 23 | President of Citizens Against Government Waste, which has been a steadfast critic of the alternate engine and recently released a 24 | detailed report on the subject.

"Neither party 25 | comes out looking good, but Republicans in particular missed a golden opportunity to show that they are really serious about getting government spending under control."

The next 26 | chance to stop the half-billion dollar alternate engine earmark is the Senate, when it takes up the defense authorization bill later this month. But even success there from genuine fiscal 27 | conservatives such as John McCain could be undone when the bill goes to conference -- it's the Washington way.

The final stop would be a presidential veto, which President Obama has 28 | promised, under advice from Defense Secretary Gates.

A half century ago, Republican President Eisenhower warned about the influence of the military-industrial complex.

29 |

The former five-star general crusaded against government waste, especially in the military, because he knew that a figure with lesser credibility could be attacked 30 | as being "soft on communism" for proposing responsible cuts from the Pentagon budget during the Cold War.

We are at war today on two fronts, even 31 | as we face down a fiscal crisis and escalating deficits and debt.

We owe it to our troops to see that every dollar allocated to the military is spent where 32 | they need it, not where congressional appropriators want it. And if fiscal conservative protesters cannot marshal their energy to oppose this half-billion dollar 33 | boondoggle, then it is not just Congress' hypocrisy they should be angry at -- it is their own.

The opinions expressed in this 34 | commentary are solely those of John P. Avlon.

35 | 36 | -------------------------------------------------------------------------------- /app/libs/AlchemyAPI_Java-0.9/testdir/data/example3.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/AlchemyAPI_Java-0.9/testdir/data/example3.html -------------------------------------------------------------------------------- /app/libs/cardboard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/cardboard.jar -------------------------------------------------------------------------------- /app/libs/easyadapter-1.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/easyadapter-1.2.0.jar -------------------------------------------------------------------------------- /app/libs/gson-2.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/gson-2.3.jar -------------------------------------------------------------------------------- /app/libs/retrofit-1.7.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/libs/retrofit-1.7.1.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Program Files (x86)\Android\android-studio\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/dwai/yhack/captor/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Black.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Bold.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Italic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Light.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-Thin.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/assets/fonts/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/ArActivity.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Canvas; 8 | import android.media.AudioManager; 9 | import android.os.AsyncTask; 10 | import android.os.Bundle; 11 | import android.os.Vibrator; 12 | import android.speech.RecognitionListener; 13 | import android.speech.RecognizerIntent; 14 | import android.speech.SpeechRecognizer; 15 | import android.telephony.TelephonyManager; 16 | import android.util.Base64; 17 | import android.util.Log; 18 | 19 | import com.google.vrtoolkit.cardboard.CardboardActivity; 20 | import com.google.vrtoolkit.cardboard.CardboardView; 21 | 22 | import org.apache.http.HttpResponse; 23 | import org.apache.http.NameValuePair; 24 | import org.apache.http.client.ClientProtocolException; 25 | import org.apache.http.client.HttpClient; 26 | import org.apache.http.client.entity.UrlEncodedFormEntity; 27 | import org.apache.http.client.methods.HttpPost; 28 | import org.apache.http.impl.client.DefaultHttpClient; 29 | import org.apache.http.message.BasicNameValuePair; 30 | 31 | import java.io.ByteArrayOutputStream; 32 | import java.io.IOException; 33 | import java.net.URLEncoder; 34 | import java.util.ArrayList; 35 | import java.util.List; 36 | 37 | import dwai.yhack.captor.R; 38 | import dwai.yhack.captor.ui.ar.Renderer; 39 | import dwai.yhack.captor.ui.widget.CardboardOverlayView; 40 | import butterknife.ButterKnife; 41 | import butterknife.InjectView; 42 | 43 | public class ArActivity extends CardboardActivity { 44 | 45 | @InjectView(R.id.overlay) 46 | CardboardOverlayView overlayView; 47 | 48 | @InjectView(R.id.cardboard_view) 49 | CardboardView cardboardView; 50 | //private String MY_ACTIVITY = "ARActivity"; 51 | private Renderer mRenderer; 52 | 53 | private Vibrator mVibrator; 54 | 55 | 56 | 57 | @Override 58 | protected void onCreate(Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | 61 | 62 | setContentView(R.layout.activity_ar); 63 | 64 | ((AudioManager)getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_MUSIC,true); 65 | // Inject views 66 | ButterKnife.inject(this); 67 | 68 | 69 | mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); 70 | 71 | // Associate a CardboardView.StereoRenderer with cardboardView. 72 | mRenderer = new Renderer(this); 73 | cardboardView.setRenderer(mRenderer); 74 | 75 | // Associate the cardboardView with this activity. 76 | setCardboardView(cardboardView); 77 | 78 | overlayView.show3DToast("Welcome to Captor!"); 79 | 80 | 81 | 82 | 83 | 84 | 85 | final SpeechRecognizer speechRec = SpeechRecognizer.createSpeechRecognizer(this); 86 | final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 87 | intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 88 | RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 89 | intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "VoiceIME"); 90 | intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true); 91 | intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 10000L); 92 | 93 | speechRec.startListening(intent); 94 | speechRec.setRecognitionListener(new RecognitionListener() { 95 | @Override 96 | public void onReadyForSpeech(Bundle bundle) { 97 | 98 | } 99 | 100 | @Override 101 | public void onBeginningOfSpeech() { 102 | 103 | } 104 | 105 | @Override 106 | public void onRmsChanged(float v) { 107 | 108 | } 109 | 110 | @Override 111 | public void onBufferReceived(byte[] bytes) { 112 | 113 | } 114 | 115 | @Override 116 | public void onEndOfSpeech() { 117 | 118 | } 119 | 120 | @Override 121 | public void onError(int i) { 122 | 123 | } 124 | 125 | @Override 126 | public void onResults(Bundle bundle) { 127 | 128 | String someString = ""; 129 | List listOfWords = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); 130 | overlayView.show3DToast(listOfWords.get(0)); 131 | Bitmap b = Bitmap.createBitmap(200,200, Bitmap.Config.ARGB_8888); 132 | Canvas c = new Canvas(b); 133 | 134 | new PostMoreStuff().execute(encodeTobase64(b)); 135 | 136 | overlayView.getmLeftView().getImageView().draw(c); 137 | 138 | someString = listOfWords.get(0); 139 | try{ 140 | 141 | someString = URLEncoder.encode(someString,"UTF-8"); 142 | 143 | } 144 | catch(Exception e){ 145 | e.printStackTrace(); 146 | } 147 | 148 | 149 | new PostStuff().execute("http://captor.thupukair.com",someString); 150 | try { 151 | Thread.sleep(100); 152 | } catch (Exception e) { 153 | e.printStackTrace(); 154 | } 155 | 156 | speechRec.stopListening(); 157 | speechRec.setRecognitionListener(this); 158 | speechRec.startListening(intent); 159 | } 160 | 161 | public void onPartialResults(Bundle partialResults) { 162 | // WARNING: The following is specific to Google Voice Search 163 | ArrayList results = 164 | partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); 165 | 166 | String b = ""; 167 | if (results != null) { 168 | if(results.size() > 6){ 169 | results.clear(); 170 | } 171 | for (String p : results) { 172 | b += p; 173 | } 174 | } 175 | overlayView.show3DToast(b); 176 | } 177 | 178 | @Override 179 | public void onEvent(int i, Bundle bundle) { 180 | 181 | } 182 | }); 183 | } 184 | 185 | private class PostMoreStuff extends AsyncTask { 186 | 187 | @Override 188 | protected Void doInBackground(final String... strings) { 189 | HttpClient httpclient = new DefaultHttpClient(); 190 | HttpPost httppost = new HttpPost("http://65b62e4e.ngrok.com/api/img?username=" + getMy10DigitPhoneNumber()); 191 | 192 | try { 193 | // Add your data 194 | List nameValuePairs = new ArrayList(2); 195 | nameValuePairs.add(new BasicNameValuePair("baseEncoded", strings[0])); 196 | httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 197 | 198 | 199 | // Execute HTTP Post Request 200 | HttpResponse response = httpclient.execute(httppost); 201 | 202 | } catch (ClientProtocolException e) { 203 | e.printStackTrace(); 204 | } catch (IOException e) { 205 | e.printStackTrace(); 206 | } 207 | 208 | return null; 209 | } 210 | } 211 | 212 | 213 | 214 | public static String encodeTobase64(Bitmap image) 215 | { 216 | Bitmap immagex=image; 217 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 218 | immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos); 219 | byte[] b = baos.toByteArray(); 220 | String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT); 221 | 222 | Log.e("LOOK", imageEncoded); 223 | return imageEncoded; 224 | } 225 | public static Bitmap decodeBase64(String input) 226 | { 227 | byte[] decodedByte = Base64.decode(input, 0); 228 | return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length); 229 | } 230 | 231 | 232 | 233 | private class PostStuff extends AsyncTask { 234 | @Override 235 | protected Void doInBackground(String... strings) { 236 | 237 | // Create a new HttpClient and Post Header 238 | HttpClient httpclient = new DefaultHttpClient(); 239 | HttpPost httppost = new HttpPost(HistoryActivity.URL + "/api/data?username=" + getMy10DigitPhoneNumber() + "&string=" + strings[1]); 240 | 241 | try { 242 | // Execute HTTP Post Request 243 | HttpResponse response = httpclient.execute(httppost); 244 | } catch (Exception e) { 245 | e.printStackTrace(); 246 | } 247 | return null; 248 | 249 | 250 | } 251 | 252 | } 253 | 254 | 255 | public String getMy10DigitPhoneNumber() { 256 | String s = getPhoneNumber(); 257 | return s != null && s.length() > 1 ? s.substring(1) : null; 258 | } 259 | private String getPhoneNumber() { 260 | TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 261 | String mPhoneNumber = tMgr.getLine1Number(); 262 | 263 | return mPhoneNumber; 264 | } 265 | 266 | } 267 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/DatePosted.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Stefan on 11/1/2014. 8 | */ 9 | public class DatePosted implements Comparable{ 10 | 11 | private int year,month,day,hour,minute,second; 12 | 13 | 14 | public int getYear() { 15 | return year; 16 | } 17 | 18 | public DatePosted setYear(int year) { 19 | this.year = year; 20 | return this; 21 | } 22 | 23 | public int getMonth() { 24 | return month; 25 | } 26 | 27 | public DatePosted setMonth(int month) { 28 | this.month = month; 29 | return this; 30 | } 31 | 32 | public int getDay() { 33 | return day; 34 | } 35 | 36 | public DatePosted setDay(int day) { 37 | this.day = day; 38 | return this; 39 | } 40 | 41 | public int getHour() { 42 | return hour; 43 | } 44 | 45 | public DatePosted setHour(int hour) { 46 | this.hour = hour; 47 | return this; 48 | } 49 | 50 | public int getMinute() { 51 | return minute; 52 | } 53 | 54 | public DatePosted setMinute(int minute) { 55 | this.minute = minute; 56 | return this; 57 | } 58 | 59 | public int getSecond() { 60 | return second; 61 | } 62 | 63 | public DatePosted setSecond(int second) { 64 | this.second = second; 65 | return this; 66 | } 67 | 68 | @Override 69 | public int compareTo(DatePosted dp) { 70 | return dp.year - year 71 | + dp.month - month 72 | + dp.day - day 73 | + dp.hour - hour 74 | + dp.minute - minute 75 | + dp.second - second; 76 | } 77 | 78 | 79 | // @Override 80 | // public String toString() { 81 | // StringBuffer finalString = new StringBuffer(); 82 | // 83 | // List allCombined = new ArrayList(); 84 | // allCombined.add(year); 85 | // allCombined.add(month); 86 | // allCombined.add(day); 87 | // allCombined.add(hour); 88 | // allCombined.add(minute); 89 | // allCombined.add(second); 90 | // String[] shortened = new String[]{"yr, ", "mnth, ", "d, ", "h, ", "min, ", "s"}; 91 | // 92 | // for(int i = 0; i < allCombined.size();i++){ 93 | // int oneCombined = allCombined.get(i); 94 | // if(oneCombined >= 0){ 95 | // finalString.append(oneCombined + " " + shortened[i]); 96 | // } 97 | // } 98 | // return finalString.toString(); 99 | // 100 | // 101 | // } 102 | public String toString(){ 103 | return month + "/" + day + "/" + year; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/HistoryActivity.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.app.Activity; 4 | import android.app.SearchManager; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.graphics.Bitmap; 8 | import android.graphics.BitmapFactory; 9 | import android.graphics.Typeface; 10 | import android.os.AsyncTask; 11 | import android.os.Bundle; 12 | import android.telephony.TelephonyManager; 13 | import android.util.Log; 14 | import android.view.Menu; 15 | import android.view.MenuItem; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.AdapterView; 19 | import android.widget.ListView; 20 | import android.view.animation.Animation; 21 | import android.view.animation.AnimationUtils; 22 | import android.widget.LinearLayout; 23 | import android.widget.SearchView; 24 | import android.widget.TextView; 25 | 26 | import org.apache.http.HttpResponse; 27 | import org.apache.http.NameValuePair; 28 | import org.apache.http.client.ClientProtocolException; 29 | import org.apache.http.client.HttpClient; 30 | import org.apache.http.client.entity.UrlEncodedFormEntity; 31 | import org.apache.http.client.methods.HttpPost; 32 | import org.apache.http.impl.client.DefaultHttpClient; 33 | import org.apache.http.message.BasicNameValuePair; 34 | import org.json.JSONArray; 35 | 36 | import java.io.IOException; 37 | import java.lang.reflect.Method; 38 | import java.text.DateFormat; 39 | import java.text.FieldPosition; 40 | import java.text.ParsePosition; 41 | import java.text.SimpleDateFormat; 42 | import java.util.Date; 43 | import java.util.List; 44 | 45 | import dwai.yhack.captor.R; 46 | 47 | import java.util.ArrayList; 48 | import java.util.Collections; 49 | import java.util.List; 50 | 51 | import uk.co.ribot.easyadapter.EasyAdapter; 52 | 53 | public class HistoryActivity extends Activity { 54 | 55 | public static final String URL = "http://captor.thupukari.com"; 56 | private ListView lv; 57 | 58 | private List items = new ArrayList(); 59 | 60 | @Override 61 | protected void onCreate(Bundle savedInstanceState) { 62 | super.onCreate(savedInstanceState); 63 | setContentView(R.layout.activity_history); 64 | 65 | final Typeface mFont = Typeface.createFromAsset(getAssets(), 66 | "fonts/Roboto-Medium.ttf"); 67 | final ViewGroup mContainer = (ViewGroup) findViewById( 68 | android.R.id.content).getRootView(); 69 | HistoryActivity.setAppFont(mContainer, mFont, true); 70 | 71 | 72 | 73 | new JSONParse().execute(); 74 | } 75 | 76 | private String getPhoneNumber() { 77 | TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 78 | String mPhoneNumber = tMgr.getLine1Number(); 79 | 80 | return mPhoneNumber; 81 | } 82 | 83 | public String getMy10DigitPhoneNumber() { 84 | String s = getPhoneNumber(); 85 | return s != null && s.length() > 1 ? s.substring(1) : null; 86 | } 87 | 88 | private class JSONParse extends AsyncTask { 89 | 90 | @Override 91 | protected void onPreExecute() { 92 | super.onPreExecute(); 93 | } 94 | 95 | @Override 96 | protected JSONArray doInBackground(String... args) { 97 | JSONParser jParser = new JSONParser(); 98 | // Getting JSON from URL 99 | JSONArray json = jParser.getJsonFromUrl(URL + "/api/data?username=" + getMy10DigitPhoneNumber()); 100 | Log.d("Joe", URL + "/api/data?username=" + getMy10DigitPhoneNumber()); 101 | //System.out.println(json + "555"); 102 | Log.d("Joe", json + "555"); 103 | return json; 104 | } 105 | 106 | @Override 107 | protected void onPostExecute(JSONArray json) { 108 | //pDialog.dismiss(); 109 | Log.d("Joe", "hi"); 110 | Bitmap icon = BitmapFactory.decodeResource(getResources(), 111 | R.drawable.kitten); 112 | try { 113 | for (int i = 0; i < json.length(); i++) { 114 | String year = json.getJSONObject(i).getJSONObject("date").getString("year"); 115 | String month = json.getJSONObject(i).getJSONObject("date").getString("month"); 116 | String day = json.getJSONObject(i).getJSONObject("date").getString("day"); 117 | 118 | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm+s:SSSS"); 119 | // Date date = format.parse(dateString); 120 | // format = new SimpleDateFormat("MM-dd-yyyy hh:mm a"); 121 | // dateString = format.format(date); 122 | 123 | 124 | OneItem o = new OneItem(icon, json.getJSONObject(i).getString("text") + "..." , new DatePosted().setYear(Integer.parseInt(year)).setMonth(Integer.parseInt(month)).setDay(Integer.parseInt(day))); 125 | items.add(o); 126 | } 127 | Collections.sort(items); 128 | lv = ((ListView) findViewById(R.id.rootListView)); 129 | lv.setAdapter(new EasyAdapter(getApplicationContext(), HistoryViewHolder.class, items)); 130 | } catch (Exception e) { 131 | Log.d("Joe", "hello"); 132 | e.printStackTrace(); 133 | } 134 | } 135 | } 136 | 137 | public void clickedCardboardIcon(View v){ 138 | startActivity(new Intent(HistoryActivity.this,ArActivity.class)); 139 | } 140 | 141 | @Override 142 | public boolean onCreateOptionsMenu(Menu menu) { 143 | getMenuInflater().inflate(R.menu.history, menu); 144 | 145 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); 146 | SearchView searchView = (SearchView) menu.findItem(R.id.search) 147 | .getActionView(); 148 | if (null != searchView) { 149 | searchView.setSearchableInfo(searchManager 150 | .getSearchableInfo(getComponentName())); 151 | searchView.setIconifiedByDefault(false); 152 | } 153 | 154 | SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { 155 | public boolean onQueryTextChange(String newText) { 156 | List newItems = new ArrayList(); 157 | for(OneItem item : items){ 158 | 159 | if(item.getText().toLowerCase().contains(newText.toLowerCase())){ 160 | newItems.add(item); 161 | } 162 | } 163 | lv.setAdapter(new EasyAdapter(getApplicationContext(), HistoryViewHolder.class, newItems)); 164 | return true; 165 | } 166 | 167 | public boolean onQueryTextSubmit(String query) { 168 | //Here u can get the value "query" which is entered in the search box. 169 | return true; 170 | 171 | } 172 | }; 173 | searchView.setOnQueryTextListener(queryTextListener); 174 | 175 | return super.onCreateOptionsMenu(menu); 176 | } 177 | 178 | @Override 179 | public boolean onOptionsItemSelected(MenuItem item) { 180 | // Handle action bar item clicks here. The action bar will 181 | // automatically handle clicks on the Home/Up button, so long 182 | // as you specify a parent activity in AndroidManifest.xml. 183 | int id = item.getItemId(); 184 | if (id == R.id.action_settings) { 185 | return true; 186 | } 187 | return super.onOptionsItemSelected(item); 188 | } 189 | 190 | 191 | 192 | public static final void setAppFont(ViewGroup mContainer, Typeface mFont, boolean reflect) { 193 | if (mContainer == null || mFont == null) return; 194 | final int mCount = mContainer.getChildCount(); 195 | // Loop through all of the children. 196 | for (int i = 0; i < mCount; ++i) { 197 | final View mChild = mContainer.getChildAt(i); 198 | if (mChild instanceof TextView) { 199 | // Set the font if it is a TextView. 200 | ((TextView) mChild).setTypeface(mFont); 201 | } else if (mChild instanceof ViewGroup) { 202 | // Recursively attempt another ViewGroup. 203 | setAppFont((ViewGroup) mChild, mFont, true); 204 | } else if (reflect) { 205 | try { 206 | Method mSetTypeface = mChild.getClass().getMethod("setTypeface", Typeface.class); 207 | mSetTypeface.invoke(mChild, mFont); 208 | } catch (Exception e) { 209 | e.printStackTrace(); 210 | } 211 | } 212 | } 213 | } 214 | 215 | } 216 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/HistoryViewHolder.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.media.Image; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.LinearLayout; 10 | import android.widget.RelativeLayout; 11 | import android.widget.TextView; 12 | 13 | import dwai.yhack.captor.R; 14 | import uk.co.ribot.easyadapter.ItemViewHolder; 15 | import uk.co.ribot.easyadapter.PositionInfo; 16 | import uk.co.ribot.easyadapter.annotations.LayoutId; 17 | import uk.co.ribot.easyadapter.annotations.ViewId; 18 | 19 | /** 20 | * Created by Stefan on 11/1/2014. 21 | */ 22 | @LayoutId(R.layout.subtitle_item) 23 | public class HistoryViewHolder extends ItemViewHolder{ 24 | 25 | @ViewId(R.id.mainText) 26 | TextView mainText; 27 | 28 | @ViewId(R.id.dateText) 29 | TextView dateText; 30 | 31 | @ViewId(R.id.imageItem) 32 | ImageView imageItem; 33 | 34 | public HistoryViewHolder(View view) { 35 | super(view); 36 | } 37 | 38 | @Override 39 | public void onSetValues(OneItem oneItem, PositionInfo positionInfo) { 40 | imageItem.setImageBitmap(oneItem.getImage()); 41 | // imageItem.setImageDrawable(getContext().getResources().getDrawable(android.R.color.white)); 42 | dateText.setText(oneItem.getDatePosted().toString()); 43 | mainText.setText(oneItem.getText()); 44 | 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/JSONParser.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.util.Log; 4 | 5 | import org.apache.http.HttpEntity; 6 | import org.apache.http.HttpResponse; 7 | import org.apache.http.client.ClientProtocolException; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.impl.client.DefaultHttpClient; 10 | import org.json.JSONArray; 11 | import org.json.JSONObject; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.io.InputStreamReader; 17 | import java.io.UnsupportedEncodingException; 18 | 19 | /** 20 | * Created by Fisher on 11/1/14. 21 | */ 22 | public class JSONParser { 23 | 24 | static InputStream is = null; 25 | static JSONArray jObj = null; 26 | static String json = null; 27 | 28 | public JSONArray getJsonFromUrl(String url) { 29 | 30 | // Make request 31 | try { 32 | DefaultHttpClient httpClient = new DefaultHttpClient(); 33 | HttpGet httpGet = new HttpGet(url); 34 | HttpResponse httpResponse = httpClient.execute(httpGet); 35 | HttpEntity httpEntity = httpResponse.getEntity(); 36 | is = httpEntity.getContent(); 37 | } catch(UnsupportedEncodingException e) { 38 | e.printStackTrace(); 39 | } catch(ClientProtocolException e) { 40 | e.printStackTrace(); 41 | } catch(IOException e) { 42 | e.printStackTrace(); 43 | } 44 | 45 | try { 46 | BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"), 8); 47 | StringBuilder sb = new StringBuilder(); 48 | String line; 49 | while((line = reader.readLine()) != null) { 50 | Log.d("Bob", line); 51 | sb.append(line); 52 | } 53 | is.close(); 54 | json = sb.toString(); 55 | } catch (Exception e) { 56 | Log.e("Buffer Error", "Error converting result " + e.toString()); 57 | } 58 | 59 | try { 60 | // try parsing the string to a JSON object 61 | jObj = new JSONArray(json); 62 | } catch(Exception e) { 63 | Log.e("JSON Parser", "Error parsing data " + e.toString()); 64 | } 65 | 66 | // return json string 67 | //Log.d("Bob", jObj.toString()) 68 | 69 | return jObj; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/MyActivity.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.app.ActionBar; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import org.json.JSONObject; 10 | 11 | import dwai.yhack.captor.R; 12 | 13 | 14 | public class MyActivity extends Activity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_my); 21 | 22 | View decorView = getWindow().getDecorView(); 23 | // Hide the status bar. 24 | int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 25 | decorView.setSystemUiVisibility(uiOptions); 26 | // Remember that you should never show the action bar if the 27 | // status bar is hidden, so hide that too if necessary. 28 | ActionBar actionBar = getActionBar(); 29 | actionBar.hide(); 30 | 31 | } 32 | 33 | public void startCardBoard(View view) { 34 | startActivity(new Intent(MyActivity.this, ArActivity.class)); 35 | } 36 | 37 | public void startHistory(View view) { 38 | startActivity(new Intent(MyActivity.this, HistoryActivity.class)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/OneItem.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.graphics.Bitmap; 4 | import android.widget.ImageView; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by Stefan on 11/1/2014. 10 | */ 11 | public class OneItem implements Comparable{ 12 | private Bitmap image; 13 | private String text; 14 | private DatePosted datePosted; 15 | 16 | public OneItem(Bitmap image, String text, DatePosted datePosted) { 17 | this.image = image; 18 | this.text = text; 19 | this.datePosted = datePosted; 20 | } 21 | 22 | public Bitmap getImage() { 23 | return image; 24 | } 25 | 26 | public String getText() { 27 | return text; 28 | } 29 | 30 | public DatePosted getDatePosted() { 31 | return datePosted; 32 | } 33 | 34 | @Override 35 | public int compareTo(OneItem oneItem) { 36 | return this.datePosted.compareTo(oneItem.datePosted); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/SpeechAuth.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | import android.os.Handler; 4 | 5 | import org.json.JSONObject; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.OutputStream; 11 | import java.net.HttpURLConnection; 12 | import java.net.URL; 13 | import java.util.Locale; 14 | 15 | /** 16 | * Created by Stefan on 11/1/2014. 17 | */ 18 | public class SpeechAuth { 19 | /** Supplies OAuth response back to client. **/ 20 | public interface Client { 21 | /** 22 | * Called on client's thread to return OAuth token on success, 23 | * or an Exception on failure. 24 | * @param token the OAuth token on success, 25 | * or null if authentication failed 26 | * @param error null on success, 27 | * or the exception if authentication failed 28 | **/ 29 | public void 30 | handleResponse(String token, Exception error); 31 | } 32 | /** 33 | * Sets up an OAuth client credentials authentication. 34 | * Follow this with a call to fetchTo() to actually load the data. 35 | * @param oauthService the URL of the OAuth client credentials service 36 | * @param apiKey the OAuth client ID 37 | * @param apiSecret the OAuth client secret 38 | * @throws IllegalArgumentException for bad URL, etc. 39 | **/ 40 | public static SpeechAuth 41 | forService(String oauthService, String oauthScope, 42 | String apiKey, String apiSecret) 43 | throws IllegalArgumentException 44 | { 45 | try { 46 | URL url = new URL(oauthService); 47 | HttpURLConnection request = (HttpURLConnection)url.openConnection(); 48 | String data = String.format(Locale.US, OAUTH_DATA, 49 | oauthScope, apiKey, apiSecret); 50 | byte[] bytes = data.getBytes("UTF8"); 51 | request.setConnectTimeout(CONNECT_TIMEOUT); 52 | request.setReadTimeout(READ_TIMEOUT); 53 | return new SpeechAuth(request, bytes); 54 | } 55 | catch (IOException e) { 56 | throw new IllegalArgumentException(e); 57 | } 58 | catch (ClassCastException e) { 59 | throw new IllegalArgumentException("URL must be HTTP: "+oauthService, e); 60 | } 61 | } 62 | private static final String OAUTH_DATA = 63 | "grant_type=client_credentials&scope=%s&client_id=%s&client_secret=%s"; 64 | /** The OAuth server is quite quick. The only timeouts will be for network failures. **/ 65 | private static final int CONNECT_TIMEOUT = 5*1000; // milliseconds 66 | private static final int READ_TIMEOUT = 5*1000; 67 | /** 68 | * Create a loader for a URLConnection that returns the response data to a client. 69 | **/ 70 | private 71 | SpeechAuth(HttpURLConnection request, byte[] postData) 72 | { 73 | this.connection = request; 74 | this.postData = postData; 75 | } 76 | private Client client; // becomes null after cancel() 77 | private HttpURLConnection connection; 78 | private byte[] postData; // becomes null after getResponseStream() 79 | /** 80 | * Begin fetching the credentials asynchronously. 81 | * This must be invoked on a thread with a Looper, 82 | * and the client will be called back on this thread. 83 | **/ 84 | public void 85 | fetchTo(Client client) 86 | { 87 | this.client = client; 88 | // TODO: prevent starting twice 89 | final Handler callingThread = new Handler(); 90 | Thread reader = new Thread(connection.getURL().toString()) { 91 | @Override public void run() { 92 | performFetch(callingThread); 93 | } 94 | }; 95 | reader.start(); 96 | } 97 | /** 98 | * Stop the loading. 99 | * This should only be called from the same thread that called start(). 100 | **/ 101 | public void 102 | cancel() 103 | { 104 | // TODO: figure out a way to implement cancel() 105 | client = null; 106 | //connection.disconnect(); 107 | } 108 | /** 109 | * Posts request data, gets bytes of response, and calls client when done. 110 | * Performs blocking I/O, so it must be called from its own thread. 111 | **/ 112 | private void 113 | performFetch(Handler callingThread) 114 | { 115 | try { 116 | // Post the credentials. 117 | connection.setDoOutput(true); 118 | OutputStream out = connection.getOutputStream(); 119 | out.write(postData); 120 | out.close(); 121 | // Wait for the response. 122 | // Note that getInputStream will throw exception for non-200 status. 123 | InputStream response = connection.getInputStream(); 124 | byte[] data = readAllBytes(response); 125 | // Extract the token from JSON. 126 | String body = new String(data, "UTF8"); 127 | JSONObject json = new JSONObject(body); 128 | final String token = json.getString("access_token"); 129 | // Give it back to the client. 130 | callingThread.post(new Runnable() { 131 | public void run() { 132 | if (client != null) 133 | client.handleResponse(token, null); 134 | } 135 | }); 136 | } 137 | catch (final Exception ex) { 138 | callingThread.post(new Runnable() { 139 | public void run() { 140 | if (client != null) 141 | client.handleResponse(null, ex); 142 | } 143 | }); 144 | } 145 | // XXX: Should we close the connection? 146 | // finally { connection.close(); } 147 | } 148 | private static final int BLOCK_SIZE = 16*1024; 149 | 150 | private static byte[] 151 | readAllBytes(InputStream input) 152 | throws IOException 153 | { 154 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(BLOCK_SIZE); 155 | byte[] block = new byte[BLOCK_SIZE]; 156 | int n; 157 | while ((n = input.read(block)) > 0) 158 | buffer.write(block, 0, n); 159 | return buffer.toByteArray(); 160 | } 161 | } 162 | 163 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/SpeechConfig.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | /** 4 | * Created by Stefan on 11/1/2014. 5 | */ 6 | public class SpeechConfig { 7 | private SpeechConfig() {} // can't instantiate 8 | /** The URL of AT&T Speech API. **/ 9 | static String serviceUrl() { 10 | return "https://api.att.com/speech/v3/speechToText"; 11 | } 12 | /** The URL of AT&T Speech API OAuth service. **/ 13 | static String oauthUrl() { 14 | return "https://api.att.com/oauth/token"; 15 | } 16 | /** The OAuth scope of AT&T Speech API. **/ 17 | static String oauthScope() { 18 | return "SPEECH"; 19 | } 20 | /** Unobfuscates the OAuth client_id credential for the application. **/ 21 | static String oauthKey() { 22 | // TODO: Replace this with code to unobfuscate your OAuth client_id. 23 | return "qdnraef5jxczfp1lqroxfxt9rlrjduif"; 24 | } 25 | /** Unobfuscates the OAuth client_secret credential for the application. **/ 26 | static String oauthSecret() { 27 | // TODO: Replace this with code to unobfuscate your OAuth client_secret. 28 | return "xjz6n3649zaogz03keqgkn2qgoxoe8ty"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/activity/User.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.activity; 2 | 3 | /** 4 | * Created by Stefan on 11/1/2014. 5 | */ 6 | public class User { 7 | private String phoneNumber = ""; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/ar/GLUtils.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.ar; 2 | 3 | import android.content.Context; 4 | import android.opengl.GLES20; 5 | 6 | import java.io.BufferedReader; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.InputStreamReader; 10 | 11 | import timber.log.Timber; 12 | 13 | public class GLUtils { 14 | /** 15 | * Checks if we've had an error inside of OpenGL ES, and if so what that error is. 16 | * @param func 17 | */ 18 | public static void checkGLError(String func) { 19 | int error; 20 | while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { 21 | Timber.e(func + ": glError " + error); 22 | throw new RuntimeException(func + ": glError " + error); 23 | } 24 | } 25 | 26 | public static int loadGLShader(Context ctx, int type, int resId) { 27 | String code = readRawTextFile(ctx, resId); 28 | int shader = GLES20.glCreateShader(type); 29 | GLES20.glShaderSource(shader, code); 30 | GLES20.glCompileShader(shader); 31 | 32 | // Get the compilation status. 33 | final int[] compileStatus = new int[1]; 34 | GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0); 35 | 36 | // If the compilation failed, delete the shader. 37 | if (compileStatus[0] == 0) { 38 | Timber.e("Error compiling shader: " + GLES20.glGetShaderInfoLog(shader)); 39 | GLES20.glDeleteShader(shader); 40 | shader = 0; 41 | } 42 | 43 | if (shader == 0) { 44 | throw new RuntimeException("Error creating shader."); 45 | } 46 | 47 | return shader; 48 | } 49 | 50 | public static String readRawTextFile(Context context, int resId) { 51 | InputStream inputStream = context.getResources().openRawResource(resId); 52 | try { 53 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); 54 | StringBuilder sb = new StringBuilder(); 55 | String line; 56 | while ((line = reader.readLine()) != null) { 57 | sb.append(line).append("\n"); 58 | } 59 | reader.close(); 60 | return sb.toString(); 61 | } catch (IOException e) { 62 | e.printStackTrace(); 63 | } 64 | return ""; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/ar/WorldLayoutData.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.ar; 2 | 3 | public final class WorldLayoutData { 4 | 5 | public static final float[] WALL_COORDS = new float[] { 6 | 83f, -60f, 0, 7 | -83f, -60f, 0, 8 | 83f, 60f, 0, 9 | -83f, 60f, 0 10 | }; 11 | 12 | public static final float[] WALL_NORMALS = new float[] { 13 | 0.0f, 0.0f, -1.0f, 14 | 0.0f, 0.0f, -1.0f, 15 | 0.0f, 0.0f, -1.0f, 16 | 0.0f, 0.0f, -1.0f, 17 | }; 18 | 19 | public static final float[] WALL_COLORS = new float[] { 20 | 0.3398f, 0.3398f, 0.9023f, 1.0f, 21 | 0.3398f, 0.3398f, 0.9023f, 1.0f, 22 | 0.3398f, 0.3398f, 0.9023f, 1.0f, 23 | 0.3398f, 0.3398f, 0.9023f, 1.0f, 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/dwai/yhack/captor/ui/widget/CardboardOverlayView.java: -------------------------------------------------------------------------------- 1 | package dwai.yhack.captor.ui.widget; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.Typeface; 6 | import android.util.AttributeSet; 7 | import android.util.TypedValue; 8 | import android.view.Gravity; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.view.animation.AlphaAnimation; 12 | import android.view.animation.Animation; 13 | import android.widget.ImageView; 14 | import android.widget.LinearLayout; 15 | import android.widget.TextView; 16 | 17 | public class CardboardOverlayView extends LinearLayout { 18 | private static final String TAG = CardboardOverlayView.class.getSimpleName(); 19 | private final CardboardOverlayEyeView mLeftView; 20 | private final CardboardOverlayEyeView mRightView; 21 | 22 | public CardboardOverlayEyeView getmLeftView() { 23 | return mLeftView; 24 | } 25 | 26 | private AlphaAnimation mTextFadeAnimation; 27 | 28 | public CardboardOverlayView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | setOrientation(HORIZONTAL); 31 | 32 | LayoutParams params = new LayoutParams( 33 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f); 34 | params.setMargins(0, 0, 0, 0); 35 | 36 | mLeftView = new CardboardOverlayEyeView(context, attrs); 37 | mLeftView.setLayoutParams(params); 38 | addView(mLeftView); 39 | 40 | mRightView = new CardboardOverlayEyeView(context, attrs); 41 | mRightView.setLayoutParams(params); 42 | addView(mRightView); 43 | 44 | // Set some reasonable defaults. 45 | setDepthOffset(0.016f); 46 | setColor(Color.rgb(150, 255, 180)); 47 | setVisibility(View.VISIBLE); 48 | 49 | mTextFadeAnimation = new AlphaAnimation(1.0f, 0.0f); 50 | mTextFadeAnimation.setDuration(5000); 51 | } 52 | 53 | public void show3DToast(String message) { 54 | setText(message); 55 | // setTextAlpha(1f); 56 | // mTextFadeAnimation.setAnimationListener(new EndAnimationListener() { 57 | // @Override 58 | // public void onAnimationEnd(Animation animation) { 59 | // setTextAlpha(0f); 60 | // } 61 | // }); 62 | // startAnimation(mTextFadeAnimation); 63 | } 64 | 65 | private abstract class EndAnimationListener implements Animation.AnimationListener { 66 | @Override public void onAnimationRepeat(Animation animation) {} 67 | @Override public void onAnimationStart(Animation animation) {} 68 | } 69 | 70 | private void setDepthOffset(float offset) { 71 | mLeftView.setOffset(offset); 72 | mRightView.setOffset(-offset); 73 | } 74 | 75 | private void setText(String text) { 76 | mLeftView.setText(text); 77 | mRightView.setText(text); 78 | } 79 | 80 | private void setTextAlpha(float alpha) { 81 | mLeftView.setTextViewAlpha(alpha); 82 | mRightView.setTextViewAlpha(alpha); 83 | } 84 | 85 | private void setColor(int color) { 86 | mLeftView.setColor(color); 87 | mRightView.setColor(color); 88 | } 89 | 90 | /** 91 | * A simple view group containing some horizontally centered text underneath a horizontally 92 | * centered image. 93 | * 94 | * This is a helper class for CardboardOverlayView. 95 | */ 96 | public class CardboardOverlayEyeView extends ViewGroup { 97 | private final ImageView imageView; 98 | private final TextView textView; 99 | 100 | public ImageView getImageView() { 101 | return imageView; 102 | } 103 | 104 | private float offset; 105 | 106 | public CardboardOverlayEyeView(Context context, AttributeSet attrs) { 107 | super(context, attrs); 108 | imageView = new ImageView(context, attrs); 109 | imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 110 | imageView.setAdjustViewBounds(true); // Preserve aspect ratio. 111 | addView(imageView); 112 | 113 | textView = new TextView(context, attrs); 114 | textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.0f); 115 | textView.setTypeface(textView.getTypeface(), Typeface.BOLD); 116 | textView.setGravity(Gravity.CENTER); 117 | textView.setShadowLayer(3.0f, 0.0f, 0.0f, Color.DKGRAY); 118 | addView(textView); 119 | } 120 | 121 | public void setColor(int color) { 122 | imageView.setColorFilter(color); 123 | textView.setTextColor(color); 124 | } 125 | 126 | public void setText(String text) { 127 | textView.setText(text); 128 | } 129 | 130 | public void setTextViewAlpha(float alpha) { 131 | textView.setAlpha(alpha); 132 | } 133 | 134 | public void setOffset(float offset) { 135 | this.offset = offset; 136 | } 137 | 138 | @Override 139 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 140 | // Width and height of this ViewGroup. 141 | final int width = right - left; 142 | final int height = bottom - top; 143 | 144 | // The size of the image, given as a fraction of the dimension as a ViewGroup. We multiply 145 | // both width and heading with this number to compute the image's bounding box. Inside the 146 | // box, the image is the horizontally and vertically centered. 147 | final float imageSize = 0.12f; 148 | 149 | // The fraction of this ViewGroup's height by which we shift the image off the ViewGroup's 150 | // center. Positive values shift downwards, negative values shift upwards. 151 | final float verticalImageOffset = -0.07f; 152 | 153 | // Vertical position of the text, specified in fractions of this ViewGroup's height. 154 | final float verticalTextPos = 0.52f; 155 | 156 | // Layout ImageView 157 | float imageMargin = (1.0f - imageSize) / 2.0f; 158 | float leftMargin = (int) (width * (imageMargin + offset)); 159 | float topMargin = (int) (height * (imageMargin + verticalImageOffset)); 160 | imageView.layout( 161 | (int) leftMargin, (int) topMargin, 162 | (int) (leftMargin + width * imageSize), (int) (topMargin + height * imageSize)); 163 | 164 | // Layout TextView 165 | leftMargin = offset * width; 166 | topMargin = height * verticalTextPos; 167 | textView.layout( 168 | (int) leftMargin, (int) topMargin, 169 | (int) (leftMargin + width), (int) (topMargin + height * (1.0f - verticalTextPos))); 170 | } 171 | } 172 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/asdfsadf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/asdfsadf.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/camera_b.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/camera_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/camera_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/camera_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/camera_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/cardboard_b.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/cardboard_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/cardboard_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/cardboard_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/cardboard_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/cardboard_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/cardboard_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/history_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/history_button.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_history_black_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/ic_history_black_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_search_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/ic_search_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/kitten.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/app/src/main/res/drawable-xxhdpi/kitten.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_history.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_my.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 20 | 21 | 30 | 31 | 40 | 41 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/subtitle_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 16 | 17 | 23 | 29 | 30 | 31 | 32 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/menu/history.xml: -------------------------------------------------------------------------------- 1 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/my.xml: -------------------------------------------------------------------------------- 1 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/menu/options_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/raw/grid_fragment.shader: -------------------------------------------------------------------------------- 1 | #extension GL_OES_EGL_image_external : require 2 | precision mediump float; 3 | uniform samplerExternalOES v_Texture; 4 | varying vec2 texCoord; 5 | 6 | varying vec4 v_Color; 7 | varying vec3 v_Grid; 8 | varying float v_isFloor; 9 | 10 | void main() { 11 | float depth = gl_FragCoord.z / gl_FragCoord.w; // calculate world-space distance 12 | 13 | if (v_isFloor > 0.5) { 14 | if ((mod(abs(v_Grid[0]), 10.0) < 0.1) || (mod(abs(v_Grid[2]), 10.0) < 0.1)) { 15 | gl_FragColor = max(0.0, (90.0-depth) / 90.0) * vec4(1.0, 1.0, 1.0, 1.0) 16 | + min(1.0, depth / 90.0) * v_Color; 17 | } else { 18 | gl_FragColor = v_Color; 19 | } 20 | } else if(v_isFloor > 0.2) { 21 | gl_FragColor = texture2D(v_Texture, texCoord); 22 | } else { 23 | gl_FragColor = v_Color; 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/res/raw/light_vertex.shader: -------------------------------------------------------------------------------- 1 | uniform mat4 u_MVP; 2 | uniform mat4 u_MVMatrix; 3 | uniform mat4 u_Model; 4 | uniform vec3 u_LightPos; 5 | uniform float u_IsFloor; 6 | attribute vec4 a_Position; 7 | attribute vec4 a_Color; 8 | attribute vec3 a_Normal; 9 | varying vec4 v_Color; 10 | varying vec3 v_Grid; 11 | varying float v_isFloor; 12 | 13 | attribute vec2 v_TextCoord; 14 | varying vec2 texCoord; 15 | 16 | void main() 17 | { 18 | vec3 modelVertex = vec3(u_Model * a_Position); 19 | v_Grid = modelVertex; 20 | 21 | vec3 modelViewVertex = vec3(u_MVMatrix * a_Position); 22 | vec3 modelViewNormal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); 23 | float distance = length(u_LightPos - modelViewVertex); 24 | vec3 lightVector = normalize(u_LightPos - modelViewVertex); 25 | float diffuse = max(dot(modelViewNormal, lightVector), 0.5 ); 26 | diffuse = diffuse * (1.0 / (1.0 + (0.00001 * distance * distance))); 27 | v_Color = a_Color * diffuse; 28 | gl_Position = u_MVP * a_Position; 29 | texCoord = v_TextCoord; 30 | v_isFloor = u_IsFloor; 31 | } -------------------------------------------------------------------------------- /app/src/main/res/values-v21/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Captor 5 | Hello world! 6 | Settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Captor 5 | Hello world! 6 | Settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.12.+' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColdSauce/Captor/c63a3d317dae9cc38a3e6d4ea217dfea8a96b1c6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------