├── LICENSE ├── README.md ├── bin ├── textrazor-1.0.10.jar ├── textrazor-1.0.11.jar ├── textrazor-1.0.12.jar ├── textrazor-1.0.13.jar ├── textrazor-1.0.3.jar ├── textrazor-1.0.4.jar ├── textrazor-1.0.5.jar ├── textrazor-1.0.6.jar ├── textrazor-1.0.7.jar └── textrazor-1.0.9.jar ├── doc ├── allclasses-frame.html ├── allclasses-noframe.html ├── com │ └── textrazor │ │ ├── AnalysisException.html │ │ ├── NetworkException.html │ │ ├── TestTextRazor.html │ │ ├── TextRazor.html │ │ ├── annotations │ │ ├── AnalyzedText.html │ │ ├── Annotation.html │ │ ├── Custom.BoundVariable.LinkedAnnotation.html │ │ ├── Custom.BoundVariable.html │ │ ├── Custom.html │ │ ├── Entailment.EntailedTree.html │ │ ├── Entailment.html │ │ ├── Entity.html │ │ ├── NounPhrase.html │ │ ├── OuterResponse.html │ │ ├── Property.html │ │ ├── Relation.html │ │ ├── RelationParam.html │ │ ├── Response.html │ │ ├── Sentence.html │ │ ├── Topic.html │ │ ├── Word.Sense.html │ │ ├── Word.html │ │ ├── class-use │ │ │ ├── AnalyzedText.html │ │ │ ├── Annotation.html │ │ │ ├── Custom.BoundVariable.LinkedAnnotation.html │ │ │ ├── Custom.BoundVariable.html │ │ │ ├── Custom.html │ │ │ ├── Entailment.EntailedTree.html │ │ │ ├── Entailment.html │ │ │ ├── Entity.html │ │ │ ├── NounPhrase.html │ │ │ ├── OuterResponse.html │ │ │ ├── Property.html │ │ │ ├── Relation.html │ │ │ ├── RelationParam.html │ │ │ ├── Response.html │ │ │ ├── Sentence.html │ │ │ ├── Topic.html │ │ │ ├── Word.Sense.html │ │ │ └── Word.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── class-use │ │ ├── AnalysisException.html │ │ ├── NetworkException.html │ │ ├── TestTextRazor.html │ │ └── TextRazor.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html ├── constant-values.html ├── deprecated-list.html ├── help-doc.html ├── index-files │ ├── index-1.html │ ├── index-10.html │ ├── index-11.html │ ├── index-12.html │ ├── index-13.html │ ├── index-2.html │ ├── index-3.html │ ├── index-4.html │ ├── index-5.html │ ├── index-6.html │ ├── index-7.html │ ├── index-8.html │ └── index-9.html ├── index.html ├── overview-frame.html ├── overview-summary.html ├── overview-tree.html ├── package-list ├── resources │ └── inherit.gif ├── serialized-form.html └── stylesheet.css ├── pom.xml ├── src └── com │ └── textrazor │ ├── AnalysisException.java │ ├── NetworkException.java │ ├── TextRazor.java │ ├── account │ ├── AccountManager.java │ └── model │ │ ├── Account.java │ │ └── AccountResponse.java │ ├── annotations │ ├── AnalyzedText.java │ ├── Annotation.java │ ├── Custom.java │ ├── Entailment.java │ ├── Entity.java │ ├── NounPhrase.java │ ├── Property.java │ ├── Relation.java │ ├── RelationParam.java │ ├── Response.java │ ├── ScoredCategory.java │ ├── Sentence.java │ ├── Topic.java │ └── Word.java │ ├── classifier │ ├── ClassifierManager.java │ └── model │ │ ├── AllCategoriesResponse.java │ │ ├── Category.java │ │ ├── GetCategoryResponse.java │ │ └── PagedAllCategories.java │ ├── dictionary │ ├── DictionaryManager.java │ └── model │ │ ├── AllDictionariesResponse.java │ │ ├── AllEntriesResponse.java │ │ ├── Dictionary.java │ │ ├── DictionaryEntry.java │ │ ├── GetDictionaryEntryResponse.java │ │ ├── GetDictionaryResponse.java │ │ └── PagedAllEntries.java │ └── net │ ├── QueryBuilder.java │ ├── TextRazorConnection.java │ └── TextRazorResponse.java └── test └── com └── textrazor └── TestTextRazor.java /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Toby Crayston 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TextRazor Official Java SDK 2 | =========================== 3 | 4 | This is the official Java SDK for the TextRazor Text Analytics API. 5 | 6 | TextRazor offers state-of-the-art natural language processing tools through a simple API, allowing you to build semantic technology into your applications in minutes. 7 | 8 | Hundreds of applications across a range of verticals rely on TextRazor to extract meaning from unstructured text, with use cases including social media monitoring, enterprise search, recommendation systems and ad targetting. 9 | TextRazor offers automatic Named Entity Recognition, Disambiguation and Linking, Topic and Theme Extraction, Relation Extraction and much more. 10 | 11 | Visit https://www.textrazor.com to find out more. 12 | 13 | Getting Started 14 | =============== 15 | 16 | - Download the latest [TextRazor JAR](https://github.com/TextRazor/textrazor-java/blob/master/bin/textrazor-1.0.12.jar). 17 | 18 | TextRazor for Java depends on the Jackson JSON library, specifically jackson-core-2.9.8.jar, jackson-annotations-2.9.8.jar, jackson-databind-2.12.7.1.jar. Ensure that these are on your classpath when running your project. 19 | 20 | - Alternatively, if you use Maven you can add a dependency to TextRazor in your pom.xml: 21 | 22 | ``` 23 | 24 | com.textrazor 25 | textrazor 26 | 1.0.13 27 | 28 | ``` 29 | 30 | Usage 31 | ===== 32 | 33 | You'll need a [free API key](https://www.textrazor.com) to add to your requests, see [an example](https://github.com/crayston/textrazor-java/blob/master/test/com/textrazor/TestTextRazor.java) to get going. 34 | 35 | Full JavaDoc can be found as part of the package, or you can browse more comprehensive documentation [at the TextRazor site](https://www.textrazor.com/docs/java). 36 | 37 | If you have any questions please get in touch at support@textrazor.com 38 | -------------------------------------------------------------------------------- /bin/textrazor-1.0.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.10.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.11.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.12.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.13.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.3.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.4.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.5.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.6.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.7.jar -------------------------------------------------------------------------------- /bin/textrazor-1.0.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/bin/textrazor-1.0.9.jar -------------------------------------------------------------------------------- /doc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 65 | 66 |
AnalysisException 25 |
26 | AnalyzedText 27 |
28 | Annotation 29 |
30 | Custom 31 |
32 | Custom.BoundVariable 33 |
34 | Custom.BoundVariable.LinkedAnnotation 35 |
36 | Entailment 37 |
38 | Entailment.EntailedTree 39 |
40 | Entity 41 |
42 | NetworkException 43 |
44 | NounPhrase 45 |
46 | Property 47 |
48 | Relation 49 |
50 | RelationParam 51 |
52 | Response 53 |
54 | Sentence 55 |
56 | TextRazor 57 |
58 | Topic 59 |
60 | Word 61 |
62 | Word.Sense 63 |
64 |
67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 65 | 66 |
AnalysisException 25 |
26 | AnalyzedText 27 |
28 | Annotation 29 |
30 | Custom 31 |
32 | Custom.BoundVariable 33 |
34 | Custom.BoundVariable.LinkedAnnotation 35 |
36 | Entailment 37 |
38 | Entailment.EntailedTree 39 |
40 | Entity 41 |
42 | NetworkException 43 |
44 | NounPhrase 45 |
46 | Property 47 |
48 | Relation 49 |
50 | RelationParam 51 |
52 | Response 53 |
54 | Sentence 55 |
56 | TextRazor 57 |
58 | Topic 59 |
60 | Word 61 |
62 | Word.Sense 63 |
64 |
67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/com/textrazor/annotations/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.textrazor.annotations 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.textrazor.annotations 20 | 21 | 22 | 59 | 60 |
23 | Classes  24 | 25 |
26 | AnalyzedText 27 |
28 | Annotation 29 |
30 | Custom 31 |
32 | Custom.BoundVariable 33 |
34 | Custom.BoundVariable.LinkedAnnotation 35 |
36 | Entailment 37 |
38 | Entailment.EntailedTree 39 |
40 | Entity 41 |
42 | NounPhrase 43 |
44 | Property 45 |
46 | Relation 47 |
48 | RelationParam 49 |
50 | Response 51 |
52 | Sentence 53 |
54 | Topic 55 |
56 | Word 57 |
58 | Word.Sense
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /doc/com/textrazor/class-use/AnalysisException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.textrazor.AnalysisException 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.textrazor.AnalysisException

85 |
86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 95 | 96 |
90 | Packages that use AnalysisException
com.textrazor  
97 |   98 |

99 | 100 | 101 | 102 | 104 | 105 |
103 | Uses of AnalysisException in com.textrazor
106 |   107 |

108 | 109 | 110 | 111 | 112 | 113 | 114 | 116 | 120 | 121 |
Methods in com.textrazor that throw AnalysisException
115 |  AnalyzedTextTextRazor.analyze(java.lang.String text) 117 | 118 |
119 |           Makes a TextRazor request to analyze a string and returning TextRazor metadata.
122 |   123 |

124 |


125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 147 | 150 | 151 | 152 | 153 | 156 | 172 | 173 |
148 | 149 |
174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /doc/com/textrazor/class-use/NetworkException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.textrazor.NetworkException 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.textrazor.NetworkException

85 |
86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 95 | 96 |
90 | Packages that use NetworkException
com.textrazor  
97 |   98 |

99 | 100 | 101 | 102 | 104 | 105 |
103 | Uses of NetworkException in com.textrazor
106 |   107 |

108 | 109 | 110 | 111 | 112 | 113 | 114 | 116 | 120 | 121 |
Methods in com.textrazor that throw NetworkException
115 |  AnalyzedTextTextRazor.analyze(java.lang.String text) 117 | 118 |
119 |           Makes a TextRazor request to analyze a string and returning TextRazor metadata.
122 |   123 |

124 |


125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 147 | 150 | 151 | 152 | 153 | 156 | 172 | 173 |
148 | 149 |
174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /doc/com/textrazor/class-use/TestTextRazor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.textrazor.TestTextRazor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.textrazor.TestTextRazor

85 |
86 | No usage of com.textrazor.TestTextRazor 87 |

88 |


89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /doc/com/textrazor/class-use/TextRazor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.textrazor.TextRazor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.textrazor.TextRazor

85 |
86 | No usage of com.textrazor.TextRazor 87 |

88 |


89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /doc/com/textrazor/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.textrazor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.textrazor 20 | 21 | 22 | 27 | 28 |
23 | Classes  24 | 25 |
26 | TextRazor
29 | 30 | 31 | 32 | 33 | 40 | 41 |
34 | Exceptions  35 | 36 |
37 | AnalysisException 38 |
39 | NetworkException
42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /doc/com/textrazor/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.textrazor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |

83 | Package com.textrazor 84 |

85 | 86 | 87 | 88 | 90 | 91 | 92 | 93 | 94 | 95 |
89 | Class Summary
TextRazor 
96 |   97 | 98 |

99 | 100 | 101 | 102 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
103 | Exception Summary
AnalysisException 
NetworkException 
114 |   115 | 116 |

117 |

118 |
119 |
120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 142 | 145 | 146 | 147 | 148 | 151 | 167 | 168 |
143 | 144 |
169 | 170 | 171 | 172 |
173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /doc/com/textrazor/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.textrazor Class Hierarchy 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Hierarchy For Package com.textrazor 85 |

86 |
87 |
88 |
Package Hierarchies:
All Packages
89 |
90 |

91 | Class Hierarchy 92 |

93 | 104 |
105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 127 | 130 | 131 | 132 | 133 | 136 | 152 | 153 |
128 | 129 |
154 | 155 | 156 | 157 |
158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /doc/com/textrazor/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Package com.textrazor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Package
com.textrazor

85 |
86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 95 | 96 |
90 | Packages that use com.textrazor
com.textrazor  
97 |   98 |

99 | 100 | 101 | 102 | 104 | 105 | 106 | 110 | 111 | 112 | 116 | 117 |
103 | Classes in com.textrazor used by com.textrazor
AnalysisException 107 | 108 |
109 |            
NetworkException 113 | 114 |
115 |            
118 |   119 |

120 |


121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 143 | 146 | 147 | 148 | 149 | 152 | 168 | 169 |
144 | 145 |
170 | 171 | 172 | 173 |
174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /doc/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Constant Field Values

85 |
86 |
87 | Contents 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 |
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Deprecated API

85 |
86 |
87 | Contents 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 |
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /doc/index-files/index-10.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | T-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | T

84 |
85 |
TextRazor - Class in com.textrazor
 
TextRazor(String) - 86 | Constructor for class com.textrazor.TextRazor 87 |
Creates a new TextRazor client with the specified API Key. 88 |
Topic - Class in com.textrazor.annotations
 
Topic() - 89 | Constructor for class com.textrazor.annotations.Topic 90 |
  91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 115 | 118 | 119 | 120 | 121 | 124 | 140 | 141 |
116 | 117 |
142 | 143 | 144 | 145 | A C E G I N P R S T W
146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /doc/index-files/index-11.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | W-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | W

84 |
85 |
Word - Class in com.textrazor.annotations
 
Word() - 86 | Constructor for class com.textrazor.annotations.Word 87 |
  88 |
Word.Sense - Class in com.textrazor.annotations
 
Word.Sense() - 89 | Constructor for class com.textrazor.annotations.Word.Sense 90 |
  91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 115 | 118 | 119 | 120 | 121 | 124 | 140 | 141 |
116 | 117 |
142 | 143 | 144 | 145 | A C E G I N P R S T W
146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /doc/index-files/index-12.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | W-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I M N P R S T W
82 |

83 | W

84 |
85 |
Word - Class in com.textrazor.annotations
 
Word() - 86 | Constructor for class com.textrazor.annotations.Word 87 |
  88 |
Word.Sense - Class in com.textrazor.annotations
 
Word.Sense() - 89 | Constructor for class com.textrazor.annotations.Word.Sense 90 |
  91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 115 | 118 | 119 | 120 | 121 | 124 | 140 | 141 |
116 | 117 |
142 | 143 | 144 | 145 | A C E G I M N P R S T W
146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /doc/index-files/index-13.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | W-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I M N O P R S T W
82 |

83 | W

84 |
85 |
Word - Class in com.textrazor.annotations
 
Word() - 86 | Constructor for class com.textrazor.annotations.Word 87 |
  88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 112 | 115 | 116 | 117 | 118 | 121 | 137 | 138 |
113 | 114 |
139 | 140 | 141 | 142 | A C E G I M N O P R S T W
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /doc/index-files/index-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | E-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | E

84 |
85 |
Entailment - Class in com.textrazor.annotations
 
Entailment() - 86 | Constructor for class com.textrazor.annotations.Entailment 87 |
  88 |
Entailment.EntailedTree - Class in com.textrazor.annotations
 
Entailment.EntailedTree() - 89 | Constructor for class com.textrazor.annotations.Entailment.EntailedTree 90 |
  91 |
Entity - Class in com.textrazor.annotations
 
Entity() - 92 | Constructor for class com.textrazor.annotations.Entity 93 |
  94 |
95 |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 118 | 121 | 122 | 123 | 124 | 127 | 143 | 144 |
119 | 120 |
145 | 146 | 147 | 148 | A C E G I N P R S T W
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /doc/index-files/index-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | I-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | I

84 |
85 |
isCleanupHTML() - 86 | Method in class com.textrazor.TextRazor 87 |
  88 |
isDoCompression() - 89 | Method in class com.textrazor.TextRazor 90 |
  91 |
isDoEncryption() - 92 | Method in class com.textrazor.TextRazor 93 |
  94 |
isLanguageIsReliable() - 95 | Method in class com.textrazor.annotations.Response 96 |
  97 |
98 |
99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 121 | 124 | 125 | 126 | 127 | 130 | 146 | 147 |
122 | 123 |
148 | 149 | 150 | 151 | A C E G I N P R S T W
152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /doc/index-files/index-6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | N-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | N

84 |
85 |
NetworkException - Exception in com.textrazor
 
NetworkException(String, Throwable) - 86 | Constructor for exception com.textrazor.NetworkException 87 |
  88 |
NounPhrase - Class in com.textrazor.annotations
 
NounPhrase() - 89 | Constructor for class com.textrazor.annotations.NounPhrase 90 |
  91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 115 | 118 | 119 | 120 | 121 | 124 | 140 | 141 |
116 | 117 |
142 | 143 | 144 | 145 | A C E G I N P R S T W
146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /doc/index-files/index-7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | P-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | P

84 |
85 |
Property - Class in com.textrazor.annotations
 
Property() - 86 | Constructor for class com.textrazor.annotations.Property 87 |
  88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 112 | 115 | 116 | 117 | 118 | 121 | 137 | 138 |
113 | 114 |
139 | 140 | 141 | 142 | A C E G I N P R S T W
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /doc/index-files/index-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | R-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | A C E G I N P R S T W
82 |

83 | R

84 |
85 |
Relation - Class in com.textrazor.annotations
 
Relation() - 86 | Constructor for class com.textrazor.annotations.Relation 87 |
  88 |
RelationParam - Class in com.textrazor.annotations
 
RelationParam() - 89 | Constructor for class com.textrazor.annotations.RelationParam 90 |
  91 |
Response - Class in com.textrazor.annotations
 
Response() - 92 | Constructor for class com.textrazor.annotations.Response 93 |
  94 |
95 |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 118 | 121 | 122 | 123 | 124 | 127 | 143 | 144 |
119 | 120 |
145 | 146 | 147 | 148 | A C E G I N P R S T W
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | <H2> 65 | Frame Alert</H2> 66 | 67 | <P> 68 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 69 | <BR> 70 | Link to<A HREF="overview-summary.html">Non-frame version.</A> 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /doc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
22 |
25 | 26 | 27 | 28 | 38 | 39 |
All Classes 29 |

30 | 31 | Packages 32 |
33 | com.textrazor 34 |
35 | com.textrazor.annotations 36 |
37 |

40 | 41 |

42 |   43 | 44 | 45 | -------------------------------------------------------------------------------- /doc/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |


29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | TextRazor Java SDK 85 |

86 |
87 | 88 | 89 | 90 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |
91 | Packages
com.textrazor 
com.textrazor.annotations 
102 | 103 |

104 |  


105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 127 | 130 | 131 | 132 | 133 | 136 | 152 | 153 |
128 | 129 |
154 | 155 | 156 | 157 |
158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /doc/package-list: -------------------------------------------------------------------------------- 1 | com.textrazor 2 | com.textrazor.annotations 3 | -------------------------------------------------------------------------------- /doc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TextRazor/textrazor-java/ee80a6ae625b934b776f5d76a6d715fa48862b6e/doc/resources/inherit.gif -------------------------------------------------------------------------------- /doc/serialized-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serialized Form 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Serialized Form

85 |
86 |
87 | 88 | 89 | 90 | 92 | 93 |
91 | Package com.textrazor
94 | 95 |

96 | 97 | 98 | 99 | 101 | 102 |
100 | Class com.textrazor.AnalysisException extends java.lang.Exception implements Serializable
103 | 104 |

105 | serialVersionUID: 9063173251339905559L 106 | 107 |

108 | 109 | 110 | 111 | 113 | 114 |
112 | Serialized Fields
115 | 116 |

117 | responseCode

118 |
119 | int responseCode
120 |
121 |
122 |
123 |
124 |
125 |

126 | responseBody

127 |
128 | java.lang.String responseBody
129 |
130 |
131 |
132 |
133 | 134 |

135 | 136 | 137 | 138 | 140 | 141 |
139 | Class com.textrazor.NetworkException extends java.io.IOException implements Serializable
142 | 143 |

144 | serialVersionUID: -821976320048704953L 145 | 146 |

147 | 148 |

149 |


150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 172 | 175 | 176 | 177 | 178 | 181 | 197 | 198 |
173 | 174 |
199 | 200 | 201 | 202 |
203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /doc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.textrazor 4 | textrazor 5 | 1.0.15-SNAPSHOT 6 | jar 7 | 8 | textrazor 9 | https://textrazor.com 10 | 11 | 12 | 13 | MIT 14 | http://opensource.org/licenses/MIT 15 | repo 16 | 17 | 18 | 19 | 20 | https://github.com/TextRazor/textrazor-java 21 | scm:git:https://github.com/TextRazor/textrazor-java.git 22 | scm:git:https://github.com/TextRazor/textrazor-java.git 23 | textrazor-1.0.14 24 | 25 | 26 | 27 | 28 | crayston 29 | Toby Crayston 30 | toby@textrazor.com 31 | 32 | 33 | 34 | 35 | 36 | 37 | com.fasterxml.jackson.core 38 | jackson-core 39 | 2.9.8 40 | 41 | 42 | 43 | com.fasterxml.jackson.core 44 | jackson-annotations 45 | 2.9.8 46 | 47 | 48 | 49 | com.fasterxml.jackson.core 50 | jackson-databind 51 | 2.12.7.1 52 | 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-release-plugin 57 | 3.1.0 58 | maven-plugin 59 | 60 | 61 | 62 | 63 | 64 | org.sonatype.oss 65 | oss-parent 66 | 7 67 | 68 | 69 | 70 | 71 | src/ 72 | 73 | 74 | 75 | 76 | maven-release-plugin 77 | 3.1.0 78 | 79 | forked-path 80 | false 81 | -Psonatype-oss-release 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | org.apache.maven.plugins 90 | maven-compiler-plugin 91 | 2.5.1 92 | 93 | -Xlint 94 | -g:lines,source 95 | 1.8 96 | 1.8 97 | 98 | 99 | 100 | org.apache.maven.plugins 101 | maven-javadoc-plugin 102 | 2.7 103 | 104 | 105 | attach-javadoc 106 | 107 | jar 108 | 109 | 110 | 111 | 112 | 113 | org.apache.maven.plugins 114 | maven-source-plugin 115 | 2.1.2 116 | 117 | 118 | attach-source 119 | 120 | jar 121 | 122 | 123 | 124 | 125 | 126 | 127 | Official Java SDK for the TextRazor Text Analytics API 128 | 129 | TextRazor offers state-of-the-art natural language processing tools through a simple API, allowing you to build semantic technology into your applications in minutes. 130 | 131 | Hundreds of applications rely on TextRazor to understand unstructured text across a range of verticals, with use cases including social media monitoring, enterprise search, recommendation systems and ad targetting. 132 | 133 | -------------------------------------------------------------------------------- /src/com/textrazor/AnalysisException.java: -------------------------------------------------------------------------------- 1 | package com.textrazor; 2 | 3 | public class AnalysisException extends Exception { 4 | private static final long serialVersionUID = 9063173251339905559L; 5 | 6 | private int responseCode; 7 | private String responseBody; 8 | 9 | public AnalysisException(int responseCode, String responseBody) { 10 | this.responseBody = responseBody; 11 | this.responseCode = responseCode; 12 | } 13 | 14 | @Override 15 | public String getMessage() { 16 | return String.format("TextRazor returned HTTP Code %d with response: %s", responseCode, responseBody); 17 | } 18 | 19 | public String getResponseBody() { 20 | return responseBody; 21 | } 22 | 23 | public int getResponseCode() { 24 | return responseCode; 25 | } 26 | } -------------------------------------------------------------------------------- /src/com/textrazor/NetworkException.java: -------------------------------------------------------------------------------- 1 | package com.textrazor; 2 | 3 | import java.io.IOException; 4 | 5 | public class NetworkException extends IOException { 6 | 7 | private static final long serialVersionUID = -821976320048704953L; 8 | 9 | public NetworkException(String message, Throwable cause) { 10 | super(message); 11 | initCause(cause); 12 | } 13 | } -------------------------------------------------------------------------------- /src/com/textrazor/account/AccountManager.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.account; 2 | 3 | import com.textrazor.AnalysisException; 4 | import com.textrazor.NetworkException; 5 | import com.textrazor.account.model.Account; 6 | import com.textrazor.account.model.AccountResponse; 7 | import com.textrazor.net.TextRazorConnection; 8 | 9 | public class AccountManager extends TextRazorConnection { 10 | 11 | public AccountManager(String apiKey) { 12 | super(apiKey); 13 | } 14 | 15 | public Account getAccount() throws NetworkException, AnalysisException { 16 | AccountResponse response = sendRequest("account/", 17 | null, 18 | ContentType.JSON, 19 | "GET", 20 | AccountResponse.class); 21 | 22 | return response.getResponse(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/textrazor/account/model/Account.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.account.model; 2 | 3 | public class Account { 4 | 5 | private String plan; 6 | 7 | private int concurrentRequestLimit; 8 | 9 | private int concurrentRequestsUsed; 10 | 11 | private int planDailyRequestsIncluded; 12 | 13 | private int requestsUsedToday; 14 | 15 | /** 16 | * @return The ID of your current subscription plan. 17 | */ 18 | public String getPlan() { 19 | return plan; 20 | } 21 | 22 | /** 23 | * @return The maximum number of requests your account can make at the same time. 24 | */ 25 | public int getConcurrentRequestLimit() { 26 | return concurrentRequestLimit; 27 | } 28 | 29 | /** 30 | * @return The number of requests currently being processed by your account. 31 | */ 32 | public int getConcurrentRequestsUsed() { 33 | return concurrentRequestsUsed; 34 | } 35 | 36 | /** 37 | * @return The daily number of requests included with your subscription plan. 38 | */ 39 | public int getPlanDailyRequestsIncluded() { 40 | return planDailyRequestsIncluded; 41 | } 42 | 43 | /** 44 | * @return The total number of requests that have been made today. 45 | */ 46 | public int getRequestsUsedToday() { 47 | return requestsUsedToday; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/com/textrazor/account/model/AccountResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.account.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class AccountResponse extends TextRazorResponse { 6 | 7 | private Account response; 8 | 9 | public Account getResponse() { 10 | return response; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/AnalyzedText.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class AnalyzedText extends TextRazorResponse { 6 | 7 | private Response response; 8 | 9 | /** 10 | * @return The {@link Response} containing extracted TextRazor metadata. 11 | */ 12 | public Response getResponse() { 13 | return response; 14 | } 15 | 16 | public void createAnnotationLinks() { 17 | if (null != response) { 18 | response.createAnnotationLinks(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Annotation.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | public class Annotation { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Custom.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Custom { 7 | 8 | public static class BoundVariable { 9 | 10 | public static class LinkedAnnotation { 11 | 12 | private String annotationName; 13 | 14 | private int linkedId; 15 | 16 | public String getAnnotationName() { 17 | return annotationName; 18 | } 19 | 20 | public int getLinkedId() { 21 | return linkedId; 22 | } 23 | } 24 | 25 | private String key; 26 | 27 | private List intValue; 28 | 29 | private List floatValue; 30 | 31 | private List stringValue; 32 | 33 | private List byteValue; 34 | 35 | private List links; 36 | 37 | private List annotationValue = new ArrayList(); 38 | 39 | private List wordValue = new ArrayList(); 40 | private List sentenceValue = new ArrayList(); 41 | private List relationValue = new ArrayList(); 42 | private List entityValue = new ArrayList(); 43 | private List propertyValue = new ArrayList(); 44 | private List nounPhraseValue = new ArrayList(); 45 | private List entailmentValue = new ArrayList(); 46 | private List topicValue = new ArrayList(); 47 | private List coarseTopicValue = new ArrayList(); 48 | 49 | protected void addLinks(Response response) { 50 | if (null != links) { 51 | for (LinkedAnnotation link : links) { 52 | String annotationName = link.getAnnotationName(); 53 | int linkedId = link.getLinkedId(); 54 | 55 | if (annotationName.equals("word")) { 56 | Word word = response.getWords().get(linkedId); 57 | annotationValue.add(word); 58 | wordValue.add(word); 59 | } 60 | else if (annotationName.equals("sentence")) { 61 | Sentence sentence = response.getSentences().get(linkedId); 62 | annotationValue.add(sentence); 63 | sentenceValue.add(sentence); 64 | } 65 | else if (annotationName.equals("relation")) { 66 | Relation relation = response.getRelations().get(linkedId); 67 | annotationValue.add(relation); 68 | relationValue.add(relation); 69 | } 70 | else if (annotationName.equals("property")) { 71 | Property property = response.getProperties().get(linkedId); 72 | annotationValue.add(property); 73 | propertyValue.add(property); 74 | } 75 | else if (annotationName.equals("nounPhrase")) { 76 | NounPhrase nounPhrase = response.getNounPhrases().get(linkedId); 77 | annotationValue.add(nounPhrase); 78 | nounPhraseValue.add(nounPhrase); 79 | } 80 | else if (annotationName.equals("entailment")) { 81 | Entailment entailment = response.getEntailments().get(linkedId); 82 | annotationValue.add(entailment); 83 | entailmentValue.add(entailment); 84 | } 85 | else if (annotationName.equals("entity")) { 86 | Entity entity = response.getEntities().get(linkedId); 87 | annotationValue.add(entity); 88 | entityValue.add(entity); 89 | } 90 | else if (annotationName.equals("topic")) { 91 | Topic topic = response.getTopics().get(linkedId); 92 | annotationValue.add(topic); 93 | topicValue.add(topic); 94 | } 95 | else if (annotationName.equals("coarseTopic")) { 96 | Topic topic = response.getCoarseTopics().get(linkedId); 97 | annotationValue.add(topic); 98 | coarseTopicValue.add(topic); 99 | } 100 | } 101 | } 102 | } 103 | 104 | public String getKey() { 105 | return key; 106 | } 107 | 108 | public List getIntValue() { 109 | return intValue; 110 | } 111 | 112 | public List getFloatValue() { 113 | return floatValue; 114 | } 115 | 116 | public List getStringValue() { 117 | return stringValue; 118 | } 119 | 120 | public List getByteValue() { 121 | return byteValue; 122 | } 123 | 124 | public List getLinks() { 125 | return links; 126 | } 127 | 128 | public List getAnnotationValue() { 129 | return annotationValue; 130 | } 131 | 132 | public List getWordValue() { 133 | return wordValue; 134 | } 135 | 136 | public List getSentenceValue() { 137 | return sentenceValue; 138 | } 139 | 140 | public List getRelationValue() { 141 | return relationValue; 142 | } 143 | 144 | public List getPropertyValue() { 145 | return propertyValue; 146 | } 147 | 148 | public List getNounPhraseValue() { 149 | return nounPhraseValue; 150 | } 151 | 152 | public List getEntailmentValue() { 153 | return entailmentValue; 154 | } 155 | 156 | public List getTopicValue() { 157 | return topicValue; 158 | } 159 | 160 | public List getCoarseTopicValue() { 161 | return coarseTopicValue; 162 | } 163 | 164 | public List getEntityValue() { 165 | return entityValue; 166 | } 167 | } 168 | 169 | private String name; 170 | 171 | private List contents; 172 | 173 | protected void addLinks(Response response) { 174 | if (null != contents) { 175 | for (BoundVariable variable : contents) { 176 | variable.addLinks(response); 177 | } 178 | } 179 | } 180 | 181 | public String getName() { 182 | return name; 183 | } 184 | 185 | public List getContents() { 186 | return contents; 187 | } 188 | 189 | } 190 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Entailment.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Entailment extends Annotation { 7 | 8 | public static class EntailedTree { 9 | private String word; 10 | 11 | private int wordId; 12 | 13 | private int parentRelation; 14 | 15 | /** 16 | * @return the entailed word. 17 | */ 18 | public String getWord() { 19 | return word; 20 | } 21 | 22 | public int getWordId() { 23 | return wordId; 24 | } 25 | 26 | public int getParentRelation() { 27 | return parentRelation; 28 | } 29 | } 30 | 31 | private int id; 32 | 33 | private List wordPositions; 34 | 35 | private List matchedWords = new ArrayList(); 36 | 37 | private double priorScore; 38 | 39 | private double contextScore; 40 | 41 | private double score; 42 | 43 | private EntailedTree entailedTree; 44 | 45 | private List entailedWords; 46 | 47 | /** 48 | * @return a List of the {@link Word} objects that generated this entailment. 49 | */ 50 | public List getMatchedWords() { 51 | return matchedWords; 52 | } 53 | 54 | /** 55 | * @return the ID of this annotation. 56 | */ 57 | public int getId() { 58 | return id; 59 | } 60 | 61 | /** 62 | * @return the indexes of words that generated this entailment. 63 | */ 64 | public List getWordPositions() { 65 | return wordPositions; 66 | } 67 | 68 | /** 69 | * @return the score of this entailment independent of the context it is used in this sentence. 70 | */ 71 | public double getPriorScore() { 72 | return priorScore; 73 | } 74 | 75 | /** 76 | * @return the score of agreement between the source word's usage in this sentence and the entailed words usage in our knowledgebase. 77 | */ 78 | public double getContextScore() { 79 | return contextScore; 80 | } 81 | 82 | /** 83 | * @return the overall confidence that TextRazor is correct that this is a valid entailment, a combination of the prior and context score. 84 | */ 85 | public double getScore() { 86 | return score; 87 | } 88 | 89 | /** 90 | * @return the words that are entailed by the source word. 91 | */ 92 | public EntailedTree getEntailedTree() { 93 | return entailedTree; 94 | } 95 | 96 | /** 97 | * @return a list of String lemmas that make up words entailed by the source word 98 | */ 99 | public List getEntailedWords() { 100 | return entailedWords; 101 | } 102 | 103 | protected void addLinks(Response response) { 104 | if (null != wordPositions) { 105 | for (Integer wordPosition : wordPositions) { 106 | Word word = response.getWords().get(wordPosition); 107 | 108 | matchedWords.add(word); 109 | word.addEntailment(this); 110 | } 111 | } 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Entity.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class Entity extends Annotation { 9 | 10 | private int id; 11 | 12 | private String sourceId; 13 | 14 | private String entityId; 15 | 16 | private String entityEnglishId; 17 | 18 | private String freebaseId; 19 | 20 | private String customEntityId; 21 | 22 | private String wikiLink; 23 | 24 | private String wikidataId; 25 | 26 | private String matchedText; 27 | 28 | private int startingPos; 29 | 30 | private int endingPos; 31 | 32 | private List matchingTokens; 33 | 34 | private List matchingWords = new ArrayList(); 35 | 36 | private List freebaseTypes; 37 | 38 | private List type; 39 | 40 | private double relevanceScore; 41 | 42 | private double confidenceScore; 43 | 44 | private String crunchbaseId; 45 | 46 | private String figi; 47 | 48 | private String permid; 49 | 50 | private String lei; 51 | 52 | private Map> data = new HashMap>(); 53 | 54 | /** 55 | * @return List of the {@link Word} objects that make up this entity. 56 | */ 57 | public List getMatchingWords() { 58 | return matchingWords; 59 | } 60 | 61 | /** 62 | * @return The ID of this annotation. 63 | */ 64 | public int getId() { 65 | return id; 66 | } 67 | 68 | /** 69 | * @return the ID for this entity, or null if this entity could not be disambiguated. This ID is from the localized Wikipedia for this document's language. 70 | */ 71 | public String getEntityId() { 72 | return entityId; 73 | } 74 | 75 | /** 76 | * @return the disambiguated Freebase ID for this entity, or null if either this entity could not be disambiguated, or a Freebase link doesn't exist. 77 | */ 78 | public String getFreebaseId() { 79 | return freebaseId; 80 | } 81 | 82 | /** 83 | * @return The custom Dictionary ID that this entity was matched from, or null if it was a TextRazor entity. 84 | */ 85 | public String getSourceId() { 86 | return sourceId; 87 | } 88 | 89 | /** 90 | * @return The custom entity DictionaryEntry ID that matched this Entity, if this entity was matched in a custom dictionary. 91 | */ 92 | public String getCustomEntityId() { 93 | return customEntityId; 94 | } 95 | 96 | /** 97 | * @return the full canonical link to Wikipedia for this entity, or null if either this entity could not be disambiguated or a Wikipedia link doesn't exist. 98 | */ 99 | public String getWikiLink() { 100 | return wikiLink; 101 | } 102 | 103 | /** 104 | * @return the disambiguated Wikidata QID for this entity, or null if either this entity could not be disambiguated or a Wikidata link doesn't exist. 105 | */ 106 | public String getWikidataId() { 107 | return wikidataId; 108 | } 109 | 110 | /** 111 | * @return the source text string that matched this entity. 112 | */ 113 | public String getMatchedText() { 114 | return matchedText; 115 | } 116 | 117 | /** 118 | * @return The start offset in the input text for this entity. Note that TextRazor treats multi byte utf8 characters as a single position. 119 | */ 120 | public int getStartingPos() { 121 | return startingPos; 122 | } 123 | 124 | /** 125 | * @return The end offset in the input text for this entity. Note that TextRazor treats multi byte utf8 characters as a single position. 126 | */ 127 | public int getEndingPos() { 128 | return endingPos; 129 | } 130 | 131 | 132 | /** 133 | * @return List of Freebase types for this entity, or an empty list if there are none. 134 | */ 135 | public List getFreebaseTypes() { 136 | return freebaseTypes; 137 | } 138 | 139 | /** 140 | * @return List of DBPedia types for this entity, or an empty list if there are none. 141 | */ 142 | public List getDBPediaTypes() { 143 | return type; 144 | } 145 | 146 | /** 147 | * @return The relevance this entity has to the source text. This is a float on a scale of 0 to 1, with 1 being the most relevant. Relevance is determined by the contextual similarity between the entities context and facts in the TextRazor knowledgebase. 148 | */ 149 | public double getRelevanceScore() { 150 | return relevanceScore; 151 | } 152 | 153 | /** 154 | * @return The confidence that TextRazor is correct that this is a valid entity. TextRazor uses an ever increasing number of signals to help spot valid entities, all of which contribute to this score. These include the contextual agreement between the words in the source text and our knowledgebase, agreement between other entities in the text, agreement between the expected entity type and context, prior probabilities of having seen this entity across wikipedia and other web datasets. The score ranges from 0.5 to 10, with 10 representing the highest confidence that this is a valid entity. 155 | */ 156 | public double getConfidenceScore() { 157 | return confidenceScore; 158 | } 159 | 160 | /** 161 | * @return List of the word positions in the current sentence that make up this entity. 162 | */ 163 | public List getMatchingTokens() { 164 | return matchingTokens; 165 | } 166 | 167 | /** 168 | * @return List of DBPedia types for this entity, or an empty array if there are none. 169 | */ 170 | public List getType() { 171 | return type; 172 | } 173 | 174 | /** 175 | * @return The disambiguated entityId in the English Wikipedia, where a link between localized and English ID could be found. Null if either the entity could not be linked, or where a language link did not exist. 176 | */ 177 | public String getEntityEnglishId() { 178 | return entityEnglishId; 179 | } 180 | 181 | /** 182 | * @return The disambiguated Crunchbase ID for this entity. Null if either the entity could not be linked, or the entity was not a Company type. 183 | */ 184 | public String getCrunchbaseId() { 185 | return crunchbaseId; 186 | } 187 | 188 | /** 189 | * @return The disambiguated Open FIGI for this entity. Null if either the entity could not be linked, or the entity was not a Company type. 190 | */ 191 | public String getFIGI() { 192 | return figi; 193 | } 194 | 195 | /** 196 | * @return The disambiguated Thomson Reuters Open PermID for this entity. Null if either the entity could not be linked, or the entity was not a Company type. 197 | */ 198 | public String getPermid() { 199 | return permid; 200 | } 201 | 202 | /** 203 | * @return The disambiguated Legal Entity Identifier for this entity. Null if either the entity could not be linked, or the entity was not a Company type. 204 | */ 205 | public String getLEI() { 206 | return lei; 207 | } 208 | 209 | /** 210 | * @return A map of Query : List of result with data from enrichment queries that match this entity. 211 | */ 212 | public Map> getData() { 213 | return data; 214 | } 215 | 216 | protected void addLinks(Response response) { 217 | if (null != matchingTokens) { 218 | for (Integer position : matchingTokens) { 219 | Word word = response.getWords().get(position); 220 | 221 | matchingWords.add(word); 222 | word.addEntity(this); 223 | } 224 | } 225 | } 226 | 227 | } 228 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/NounPhrase.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class NounPhrase extends Annotation { 7 | 8 | int id; 9 | 10 | List wordPositions; 11 | 12 | List words = new ArrayList(); 13 | 14 | /** 15 | * @return A list of the {@link Word} objects in this phrase within their sentence. 16 | */ 17 | public List getWords() { 18 | return words; 19 | } 20 | 21 | protected void setWords(List words) { 22 | this.words = words; 23 | } 24 | 25 | public int getId() { 26 | return id; 27 | } 28 | 29 | /** 30 | * @return A list of the positions of the words in this phrase within their sentence. 31 | */ 32 | public List getWordPositions() { 33 | return wordPositions; 34 | } 35 | 36 | protected void addLinks(Response response) { 37 | if (null != wordPositions) { 38 | for (Integer wordPosition : wordPositions) { 39 | Word word = response.getWords().get(wordPosition); 40 | 41 | words.add(word); 42 | word.addNounPhrase(this); 43 | } 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Property.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Property extends Annotation { 7 | 8 | private int id; 9 | 10 | private List wordPositions; 11 | 12 | private List predicateWords = new ArrayList(); 13 | 14 | private List propertyPositions; 15 | 16 | private List propertyWords = new ArrayList(); 17 | 18 | /** 19 | * @return a list of the positions of the words in the predicate (or focus) of this property. 20 | */ 21 | public List getWordPositions() { 22 | return wordPositions; 23 | } 24 | 25 | /** 26 | * @return a list of the {@link Word} in the predicate (or focus) of this property. 27 | */ 28 | public List getPredicateWords() { 29 | return predicateWords; 30 | } 31 | 32 | /** 33 | * @return The ID of this annotation. 34 | */ 35 | public int getId() { 36 | return id; 37 | } 38 | 39 | /** 40 | * @return a list of the word positions that make up the modifier of the predicate of this property. 41 | */ 42 | public List getPropertyPositions() { 43 | return propertyPositions; 44 | } 45 | 46 | /** 47 | * @return a list of the {@link Word} objects that make up the modifier of the predicate of this property. 48 | */ 49 | public List getPropertyWords() { 50 | return propertyWords; 51 | } 52 | 53 | protected void addLinks(Response response) { 54 | if (null != wordPositions) { 55 | for (Integer position : wordPositions) { 56 | Word word = response.getWords().get(position); 57 | 58 | predicateWords.add(word); 59 | word.addPropertyPredicate(this); 60 | } 61 | } 62 | 63 | if (null != propertyPositions) { 64 | for (Integer position : propertyPositions) { 65 | Word word = response.getWords().get(position); 66 | 67 | propertyWords.add(word); 68 | word.addPropertyProperty(this); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Relation.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Relation extends Annotation { 7 | 8 | private int id; 9 | 10 | private List wordPositions; 11 | 12 | private List predicateWords = new ArrayList();; 13 | 14 | private List params; 15 | 16 | /** 17 | * @return The ID of this Annotation 18 | */ 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | /** 24 | * @return A list of the positions of the predicate words in this relation within their sentence. 25 | */ 26 | public List getWordPositions() { 27 | return wordPositions; 28 | } 29 | 30 | /** 31 | * @return A list of the {@link Word} objects in this relation within their sentence. 32 | */ 33 | public List getPredicateWords() { 34 | return predicateWords; 35 | } 36 | 37 | /** 38 | * @return A list of the {@link RelationParam} object that a paramaters to the predicate. 39 | */ 40 | public List getParams() { 41 | return params; 42 | } 43 | 44 | protected void addLinks(Response response) { 45 | if (null != wordPositions) { 46 | for (Integer position : wordPositions) { 47 | Word word = response.getWords().get(position); 48 | predicateWords.add(word); 49 | 50 | word.addRelation(this); 51 | } 52 | } 53 | 54 | if (null != params) { 55 | for (RelationParam param : params) { 56 | param.addLinks(response); 57 | } 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/RelationParam.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class RelationParam { 7 | 8 | private String relation; 9 | 10 | private List wordPositions; 11 | 12 | private List paramWords = new ArrayList(); 13 | 14 | public String getRelation() { 15 | return relation; 16 | } 17 | 18 | public List getWordPositions() { 19 | return wordPositions; 20 | } 21 | 22 | public List getParamWords() { 23 | return paramWords; 24 | } 25 | 26 | public void addLinks(Response response) { 27 | if (null != wordPositions) { 28 | for (Integer position : wordPositions) { 29 | Word word = response.getWords().get(position); 30 | 31 | paramWords.add(word); 32 | word.addRelationParam(this); 33 | } 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Response.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Response { 7 | 8 | private List sentences = new ArrayList(); 9 | 10 | private List words = new ArrayList(); 11 | 12 | private List relations; 13 | 14 | private List topics; 15 | 16 | private List coarseTopics; 17 | 18 | private List entities; 19 | 20 | private List entailments; 21 | 22 | private List nounPhrases; 23 | 24 | private List properties; 25 | 26 | private List customAnnotations; 27 | 28 | private List categories; 29 | 30 | private String customAnnotationOutput; 31 | 32 | private String language; 33 | 34 | private boolean languageIsReliable; 35 | 36 | private String cleanedText; 37 | 38 | private String rawText; 39 | 40 | /** 41 | * @return List of {@link Sentence} objects that were extracted from your text. 42 | */ 43 | public List getSentences() { 44 | return sentences; 45 | } 46 | 47 | /** 48 | * @return List of {@link Relation} objects that were extracted from your text. 49 | */ 50 | public List getRelations() { 51 | return relations; 52 | } 53 | 54 | /** 55 | * @return List of {@link Topic} objects that were extracted from your text. 56 | */ 57 | public List getTopics() { 58 | return topics; 59 | } 60 | 61 | /** 62 | * @return List of {@link ScoredCategory} objects that were extracted from your text. 63 | */ 64 | public List getCategories() { 65 | return categories; 66 | } 67 | 68 | /** 69 | * @return List of {@link Entity} objects that were extracted from your text. 70 | */ 71 | public List getEntities() { 72 | return entities; 73 | } 74 | 75 | /** 76 | * @return List of Coarse {@link Topic} objects that were extracted from your text. 77 | */ 78 | public List getCoarseTopics() { 79 | return coarseTopics; 80 | } 81 | 82 | /** 83 | * @return List of {@link Entailment} objects that were extracted from your text. 84 | */ 85 | public List getEntailments() { 86 | return entailments; 87 | } 88 | 89 | /** 90 | * @return List of {@link NounPhrase} objects that were extracted from your text. 91 | */ 92 | public List getNounPhrases() { 93 | return nounPhrases; 94 | } 95 | 96 | /** 97 | * @return List of {@link Property} objects that were extracted from your text. 98 | */ 99 | public List getProperties() { 100 | return properties; 101 | } 102 | 103 | /** 104 | * @return List of {@link Custom} objects, custom rule matches. 105 | */ 106 | public List getCustomAnnotations() { 107 | return customAnnotations; 108 | } 109 | 110 | /** 111 | * @return Any output generated as part of the custom annotation process. 112 | */ 113 | public String getCustomAnnotationOutput() { 114 | return customAnnotationOutput; 115 | } 116 | 117 | /** 118 | * @return The ISO-639-2 language used to analyze this document, either explicitly provided as the languageOverride, or as detected by the language detector. 119 | */ 120 | public String getLanguage() { 121 | return language; 122 | } 123 | 124 | /** 125 | * @return Boolean indicating whether the language detector was confident of its classification. This may be false for shorter or ambiguous content. 126 | */ 127 | public boolean isLanguageIsReliable() { 128 | return languageIsReliable; 129 | } 130 | 131 | /** 132 | * @return When the setCleanupReturnCleaned option is enabled, contains the input text after any cleanup/article extraction. 133 | */ 134 | public String getCleanedText() { 135 | return cleanedText; 136 | } 137 | 138 | /** 139 | * @return When the setCleanupReturnRaw option is enabled, contains the input text before any cleanup. 140 | */ 141 | public String getRawText() { 142 | return rawText; 143 | } 144 | 145 | protected void createAnnotationLinks() { 146 | // If the user has requested the "words" extractor we can link the various annotations together for 147 | // easy traversal. 148 | 149 | if (null != sentences && !sentences.isEmpty()) { 150 | for (Sentence sentence : sentences) { 151 | for (Word word : sentence.getWords()) { 152 | words.add(word); 153 | } 154 | } 155 | 156 | for (Word word : words) { 157 | word.addLinks(this); 158 | } 159 | 160 | if (null != nounPhrases) { 161 | for (NounPhrase nounPhrase : nounPhrases) { 162 | nounPhrase.addLinks(this); 163 | } 164 | } 165 | 166 | if (null != entities) { 167 | for (Entity entity : entities) { 168 | entity.addLinks(this); 169 | } 170 | } 171 | 172 | if (null != entailments) { 173 | for (Entailment entailment : entailments) { 174 | entailment.addLinks(this); 175 | } 176 | } 177 | 178 | if (null != properties) { 179 | for (Property property : properties) { 180 | property.addLinks(this); 181 | } 182 | } 183 | 184 | if (null != relations) { 185 | for (Relation relation : relations) { 186 | relation.addLinks(this); 187 | } 188 | } 189 | 190 | if (null != customAnnotations) { 191 | for (Custom custom : customAnnotations) { 192 | custom.addLinks(this); 193 | } 194 | } 195 | } 196 | } 197 | 198 | /** 199 | * @return List of {@link Word} objects that were extracted from your text. 200 | */ 201 | public List getWords() { 202 | return words; 203 | } 204 | 205 | 206 | } 207 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/ScoredCategory.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | public class ScoredCategory extends Annotation { 4 | 5 | private String categoryId; 6 | 7 | private String label; 8 | 9 | private String classifierId; 10 | 11 | private double score; 12 | 13 | /** 14 | * @return The unique ID for this category within its classifier 15 | */ 16 | public String getCategoryId() { 17 | return categoryId; 18 | } 19 | 20 | /** 21 | * @return The human readable label for this category. 22 | */ 23 | public String getLabel() { 24 | return label; 25 | } 26 | 27 | /** 28 | * @return The unique identifier for the classifier that matched this category. 29 | */ 30 | public String getClassifierId() { 31 | return classifierId; 32 | } 33 | 34 | /** 35 | * @return The score TextRazor has assigned to this category, between 0 and 1. A score closer to 1 indicates that this is a highly relevant category for our document. 36 | * 37 | * To avoid false positives you might want to ignore categories below a certain score - a good starting point would be 0.5. 38 | * The best way to find an appropriate threshold is to run a sample set of your documents through the system and manually inspect the results. 39 | */ 40 | public double getScore() { 41 | return score; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Sentence.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Sentence extends Annotation { 7 | 8 | private List words = new ArrayList(); 9 | 10 | private int position; 11 | 12 | /** 13 | * @return The position of this sentence in your text. 14 | */ 15 | public int getPosition() { 16 | return position; 17 | } 18 | 19 | /** 20 | * @return List of {@link Word} objects that are part of this sentence. 21 | */ 22 | public List getWords() { 23 | return words; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/com/textrazor/annotations/Topic.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.annotations; 2 | 3 | public class Topic extends Annotation { 4 | 5 | private int id; 6 | 7 | private String label; 8 | 9 | private String wikiLink; 10 | 11 | private String wikidataId; 12 | 13 | private double score; 14 | 15 | /** 16 | * @return The ID of this annotation 17 | */ 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | /** 23 | * @return The textual label for this topic. 24 | */ 25 | public String getLabel() { 26 | return label; 27 | } 28 | 29 | /** 30 | * @return Link to the Wikipedia page for this Topic, empty if there is no relevant link for this topic. 31 | */ 32 | public String getWikiLink() { 33 | return wikiLink; 34 | } 35 | 36 | /** 37 | * @return The disambiguated Wikidata QID for this topic, or None if either this topic could not be disambiguated, or a Wikidata link doesn’t exist. 38 | */ 39 | public String getWikidataId() { 40 | return wikidataId; 41 | } 42 | 43 | /** 44 | * @return The relevance of this topic to the processed document. This score ranges from 0 to 1, with 1 representing the highest relevance of the topic to the processed document. 45 | */ 46 | public double getScore() { 47 | return score; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/com/textrazor/classifier/ClassifierManager.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.classifier; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | import java.io.UnsupportedEncodingException; 7 | import java.util.List; 8 | 9 | import com.textrazor.AnalysisException; 10 | import com.textrazor.NetworkException; 11 | import com.textrazor.classifier.model.AllCategoriesResponse; 12 | import com.textrazor.classifier.model.Category; 13 | import com.textrazor.classifier.model.GetCategoryResponse; 14 | import com.textrazor.classifier.model.PagedAllCategories; 15 | import com.textrazor.net.QueryBuilder; 16 | import com.textrazor.net.TextRazorConnection; 17 | import com.textrazor.net.TextRazorResponse; 18 | 19 | public class ClassifierManager extends TextRazorConnection { 20 | public ClassifierManager(String apiKey) { 21 | super(apiKey); 22 | } 23 | 24 | public TextRazorResponse createClassifier(String classifierId, List categories) throws NetworkException, AnalysisException { 25 | String encodedId = encodeURLParam(classifierId); 26 | 27 | if (null == encodedId) { 28 | throw new RuntimeException("Invalid Classifier ID."); 29 | } 30 | 31 | return sendRequest("categories/" + encodedId, 32 | categories, 33 | ContentType.JSON, 34 | "PUT", 35 | TextRazorResponse.class); 36 | } 37 | 38 | public TextRazorResponse createClassifierWithCSV(String classifierId, String classifierFileName) throws IOException, NetworkException, AnalysisException { 39 | String encodedId = encodeURLParam(classifierId); 40 | 41 | if (null == encodedId) { 42 | throw new RuntimeException("Invalid Classifier ID."); 43 | } 44 | 45 | String csvContents; 46 | 47 | BufferedReader br = new BufferedReader(new FileReader(classifierFileName)); 48 | try { 49 | StringBuilder sb = new StringBuilder(); 50 | String line = br.readLine(); 51 | 52 | while (line != null) { 53 | sb.append(line); 54 | sb.append('\n'); 55 | line = br.readLine(); 56 | } 57 | 58 | csvContents = sb.toString(); 59 | } finally { 60 | br.close(); 61 | } 62 | 63 | return sendRequest("categories/" + encodedId, 64 | csvContents, 65 | ContentType.CSV, 66 | "PUT", 67 | TextRazorResponse.class); 68 | } 69 | 70 | public TextRazorResponse deleteClassifier(String classifierId) throws NetworkException, AnalysisException { 71 | String encodedId = encodeURLParam(classifierId); 72 | 73 | if (null == encodedId) { 74 | throw new RuntimeException("Invalid Classifier ID."); 75 | } 76 | 77 | return sendRequest("categories/" + encodedId, 78 | null, 79 | ContentType.JSON, 80 | "DELETE", 81 | TextRazorResponse.class); 82 | } 83 | 84 | public TextRazorResponse deleteCategory(String classifierId, String categoryId) throws NetworkException, AnalysisException { 85 | String encodedClassifierId = encodeURLParam(classifierId); 86 | if (null == encodedClassifierId) { 87 | throw new RuntimeException("Invalid Classifier ID."); 88 | } 89 | 90 | String encodedCategoryId = encodeURLParam(categoryId); 91 | if (null == encodedCategoryId) { 92 | throw new RuntimeException("Invalid Category ID."); 93 | } 94 | 95 | return sendRequest("categories/" + encodedClassifierId + "/" + encodedCategoryId, 96 | null, 97 | ContentType.JSON, 98 | "DELETE", 99 | TextRazorResponse.class); 100 | } 101 | 102 | public Category getCategory(String classifierId, String categoryId) throws NetworkException, AnalysisException { 103 | String encodedClassifierId = encodeURLParam(classifierId); 104 | if (null == encodedClassifierId) { 105 | throw new RuntimeException("Invalid Classifier ID."); 106 | } 107 | 108 | String encodedCategoryId = encodeURLParam(categoryId); 109 | if (null == encodedCategoryId) { 110 | throw new RuntimeException("Invalid Category ID."); 111 | } 112 | 113 | GetCategoryResponse response = sendRequest("categories/" + encodedClassifierId + "/" + encodedCategoryId, 114 | null, 115 | ContentType.JSON, 116 | "GET", 117 | GetCategoryResponse.class); 118 | 119 | return response.getResponse(); 120 | } 121 | 122 | public PagedAllCategories allCategories(String classifierId, int limit, int offset) throws NetworkException, AnalysisException { 123 | String encodedId = encodeURLParam(classifierId); 124 | 125 | if (null == encodedId) { 126 | throw new RuntimeException("Invalid Category ID."); 127 | } 128 | 129 | QueryBuilder paramBuilder = new QueryBuilder(); 130 | 131 | try { 132 | if (limit > 0) { 133 | paramBuilder.addParam("limit", Integer.toString(limit)); 134 | } 135 | 136 | if (offset > 0) { 137 | paramBuilder.addParam("offset", Integer.toString(offset)); 138 | } 139 | } 140 | catch (UnsupportedEncodingException e) { 141 | throw new RuntimeException("Unable to encode category paging paramaters."); 142 | } 143 | 144 | AllCategoriesResponse response = sendRequest("categories/" + encodedId + "/_all?" + paramBuilder.build(), 145 | null, 146 | ContentType.JSON, 147 | "GET", 148 | AllCategoriesResponse.class); 149 | 150 | return response.getResponse(); 151 | } 152 | 153 | public PagedAllCategories allCategories(String classifierId, int limit) throws NetworkException, AnalysisException { 154 | return allCategories(classifierId, limit, -1); 155 | } 156 | 157 | public PagedAllCategories allCategories(String classifierId) throws NetworkException, AnalysisException { 158 | return allCategories(classifierId, -1); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/com/textrazor/classifier/model/AllCategoriesResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.classifier.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class AllCategoriesResponse extends TextRazorResponse { 6 | 7 | private PagedAllCategories response; 8 | 9 | public PagedAllCategories getResponse() { 10 | return response; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/com/textrazor/classifier/model/Category.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.classifier.model; 2 | 3 | import com.textrazor.dictionary.model.DictionaryEntry.Builder; 4 | 5 | public class Category { 6 | 7 | public static class Builder { 8 | private String categoryId; 9 | 10 | private String label; 11 | 12 | private String query; 13 | 14 | public Builder setCategoryId(String categoryId) { 15 | this.categoryId = categoryId; 16 | return this; 17 | } 18 | 19 | public Builder setLabel(String label) { 20 | this.label = label; 21 | return this; 22 | } 23 | 24 | public Builder setQuery(String query) { 25 | this.query = query; 26 | return this; 27 | } 28 | 29 | public Category build() { 30 | return new Category(categoryId, label, query); 31 | } 32 | } 33 | 34 | private String categoryId; 35 | 36 | private String label; 37 | 38 | private String query; 39 | 40 | public Category() {} 41 | 42 | private Category(String categoryId, String label, String query) { 43 | this.categoryId = categoryId; 44 | this.label = label; 45 | this.query = query; 46 | } 47 | 48 | public static Builder builder() { 49 | return new Builder(); 50 | } 51 | 52 | /** 53 | * @return The unique ID for this category within its classifier 54 | */ 55 | public String getCategoryId() { 56 | return categoryId; 57 | } 58 | 59 | /** 60 | * @return The human readable label for this category. 61 | */ 62 | public String getLabel() { 63 | return label; 64 | } 65 | 66 | /** 67 | * @return The query used to define this category. 68 | */ 69 | public String getQuery() { 70 | return query; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/com/textrazor/classifier/model/GetCategoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.classifier.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class GetCategoryResponse extends TextRazorResponse { 6 | 7 | private Category response; 8 | 9 | public Category getResponse() { 10 | return response; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/textrazor/classifier/model/PagedAllCategories.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.classifier.model; 2 | 3 | import java.util.List; 4 | 5 | public class PagedAllCategories { 6 | 7 | String id; 8 | 9 | int total; 10 | 11 | int limit; 12 | 13 | int offset; 14 | 15 | List categories; 16 | 17 | public String getClassifierId() { 18 | return id; 19 | } 20 | 21 | public int getTotal() { 22 | return total; 23 | } 24 | 25 | public int getLimit() { 26 | return limit; 27 | } 28 | 29 | public int getOffset() { 30 | return offset; 31 | } 32 | 33 | public List getCategories() { 34 | return categories; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/DictionaryManager.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.List; 5 | 6 | import com.textrazor.AnalysisException; 7 | import com.textrazor.NetworkException; 8 | import com.textrazor.dictionary.model.AllDictionariesResponse; 9 | import com.textrazor.dictionary.model.AllEntriesResponse; 10 | import com.textrazor.dictionary.model.Dictionary; 11 | import com.textrazor.dictionary.model.DictionaryEntry; 12 | import com.textrazor.dictionary.model.GetDictionaryEntryResponse; 13 | import com.textrazor.dictionary.model.GetDictionaryResponse; 14 | import com.textrazor.dictionary.model.PagedAllEntries; 15 | import com.textrazor.net.QueryBuilder; 16 | import com.textrazor.net.TextRazorConnection; 17 | import com.textrazor.net.TextRazorResponse; 18 | 19 | public class DictionaryManager extends TextRazorConnection { 20 | 21 | public DictionaryManager(String apiKey) { 22 | super(apiKey); 23 | } 24 | 25 | public TextRazorResponse createDictionary(Dictionary dictionary) throws NetworkException, AnalysisException { 26 | String encodedId = encodeURLParam(dictionary.getId()); 27 | 28 | if (null == encodedId) { 29 | throw new RuntimeException("Invalid Dictionary ID."); 30 | } 31 | 32 | return sendRequest("entities/" + encodedId, 33 | dictionary, 34 | ContentType.JSON, 35 | "PUT", 36 | TextRazorResponse.class); 37 | } 38 | 39 | public TextRazorResponse deleteDictionary(String id) throws NetworkException, AnalysisException { 40 | String encodedId = encodeURLParam(id); 41 | 42 | if (null == encodedId) { 43 | throw new RuntimeException("Invalid Dictionary ID."); 44 | } 45 | 46 | return sendRequest("entities/" + encodedId, 47 | null, 48 | ContentType.JSON, 49 | "DELETE", 50 | TextRazorResponse.class); 51 | } 52 | 53 | public TextRazorResponse deleteDictionary(Dictionary dictionary) throws NetworkException, AnalysisException { 54 | return deleteDictionary(dictionary.getId()); 55 | } 56 | 57 | public List allDictionaries() throws NetworkException, AnalysisException { 58 | return sendRequest("entities/", 59 | null, 60 | ContentType.JSON, 61 | "GET", 62 | AllDictionariesResponse.class).getDictionaries(); 63 | } 64 | 65 | public Dictionary getDictionary(String id) throws NetworkException, AnalysisException { 66 | String encodedId = encodeURLParam(id); 67 | 68 | if (null == encodedId) { 69 | throw new RuntimeException("Invalid Dictionary ID."); 70 | } 71 | 72 | GetDictionaryResponse response = sendRequest("entities/" + encodedId, 73 | null, 74 | ContentType.JSON, 75 | "GET", 76 | GetDictionaryResponse.class); 77 | 78 | return response.getResponse(); 79 | } 80 | 81 | public PagedAllEntries allEntries(String id, int limit, int offset) throws NetworkException, AnalysisException { 82 | String encodedId = encodeURLParam(id); 83 | 84 | if (null == encodedId) { 85 | throw new RuntimeException("Invalid Dictionary ID."); 86 | } 87 | 88 | QueryBuilder paramBuilder = new QueryBuilder(); 89 | 90 | try { 91 | if (limit > 0) { 92 | paramBuilder.addParam("limit", Integer.toString(limit)); 93 | } 94 | 95 | if (offset > 0) { 96 | paramBuilder.addParam("offset", Integer.toString(offset)); 97 | } 98 | } 99 | catch (UnsupportedEncodingException e) { 100 | throw new RuntimeException("Unable to encode dictionary paging paramaters."); 101 | } 102 | 103 | AllEntriesResponse response = sendRequest("entities/" + encodedId + "/_all?" + paramBuilder.build(), 104 | null, 105 | ContentType.JSON, 106 | "GET", 107 | AllEntriesResponse.class); 108 | 109 | return response.getResponse(); 110 | } 111 | 112 | public PagedAllEntries allEntries(String id, int limit) throws NetworkException, AnalysisException { 113 | return allEntries(id, limit, -1); 114 | } 115 | 116 | public PagedAllEntries allEntries(String id) throws NetworkException, AnalysisException { 117 | return allEntries(id, -1); 118 | } 119 | 120 | public TextRazorResponse addEntries(String id, List entries) throws NetworkException, AnalysisException { 121 | String encodedId = encodeURLParam(id); 122 | 123 | if (null == encodedId) { 124 | throw new RuntimeException("Invalid Dictionary ID."); 125 | } 126 | 127 | return sendRequest("entities/" + encodedId + "/", 128 | entries, 129 | ContentType.JSON, 130 | "POST", 131 | TextRazorResponse.class); 132 | } 133 | 134 | public DictionaryEntry getEntry(String dictionaryId, String entryId) throws NetworkException, AnalysisException { 135 | String encodedDictionaryId = encodeURLParam(dictionaryId); 136 | String encodedEntryId = encodeURLParam(entryId); 137 | 138 | if (null == encodedDictionaryId) { 139 | throw new RuntimeException("Invalid Dictionary ID."); 140 | } 141 | 142 | if (null == encodedEntryId) { 143 | throw new RuntimeException("Invalid Entry ID."); 144 | } 145 | 146 | GetDictionaryEntryResponse response = sendRequest("entities/" + encodedDictionaryId + "/" + encodedEntryId, 147 | null, 148 | ContentType.JSON, 149 | "GET", 150 | GetDictionaryEntryResponse.class); 151 | 152 | return response.getResponse(); 153 | } 154 | 155 | public TextRazorResponse deleteEntry(String dictionaryId, String entryId) throws NetworkException, AnalysisException { 156 | String encodedDictionaryId = encodeURLParam(dictionaryId); 157 | String encodedEntryId = encodeURLParam(entryId); 158 | 159 | if (null == encodedDictionaryId) { 160 | throw new RuntimeException("Invalid Dictionary ID."); 161 | } 162 | 163 | if (null == encodedEntryId) { 164 | throw new RuntimeException("Invalid Entry ID."); 165 | } 166 | 167 | return sendRequest("entities/" + encodedDictionaryId + "/" + encodedEntryId, 168 | null, 169 | ContentType.JSON, 170 | "DELETE", 171 | TextRazorResponse.class); 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/AllDictionariesResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.textrazor.net.TextRazorResponse; 7 | 8 | public class AllDictionariesResponse extends TextRazorResponse { 9 | private List dictionaries = new ArrayList(); 10 | 11 | public List getDictionaries() { 12 | return dictionaries; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/AllEntriesResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class AllEntriesResponse extends TextRazorResponse { 6 | 7 | private PagedAllEntries response; 8 | 9 | public PagedAllEntries getResponse() { 10 | return response; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/Dictionary.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | public class Dictionary { 4 | public static class Builder { 5 | private String id; 6 | private String matchType = "token"; 7 | private Boolean caseInsensitive = false; 8 | private String language = "any"; 9 | 10 | public Builder setId(String id) { 11 | this.id = id; 12 | return this; 13 | } 14 | 15 | public Builder setMatchType(String matchType) { 16 | this.matchType = matchType; 17 | return this; 18 | } 19 | 20 | public Builder setCaseInsensitive(Boolean caseInsensitive) { 21 | this.caseInsensitive = caseInsensitive; 22 | return this; 23 | } 24 | 25 | public Builder setLanguage(String language) { 26 | this.language = language; 27 | return this; 28 | } 29 | 30 | public Dictionary build() { 31 | return new Dictionary(id, matchType, caseInsensitive, language); 32 | } 33 | } 34 | 35 | private String id; 36 | private String matchType; 37 | private Boolean caseInsensitive; 38 | private String language; 39 | 40 | public Dictionary() {} 41 | 42 | public Dictionary(String id, String matchType, Boolean caseInsensitive, String language) { 43 | this.id = id; 44 | this.matchType = matchType; 45 | this.caseInsensitive = caseInsensitive; 46 | this.language = language; 47 | } 48 | 49 | public static Builder builder() { 50 | return new Builder(); 51 | } 52 | 53 | public String getId() { 54 | return id; 55 | } 56 | 57 | public String getMatchType() { 58 | return matchType; 59 | } 60 | 61 | public Boolean getCaseInsensitive() { 62 | return caseInsensitive; 63 | } 64 | 65 | public String getLanguage() { 66 | return language; 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/DictionaryEntry.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class DictionaryEntry { 8 | 9 | public static class Builder { 10 | private String id; 11 | 12 | private String text; 13 | 14 | private Map> data = new HashMap>(); 15 | 16 | public Builder setId(String id) { 17 | this.id = id; 18 | return this; 19 | } 20 | 21 | public Builder setText(String text) { 22 | this.text = text; 23 | return this; 24 | } 25 | 26 | public Builder addData(String key, List value) { 27 | this.data.put(key, value); 28 | return this; 29 | } 30 | 31 | public DictionaryEntry build() { 32 | return new DictionaryEntry(id, text, data); 33 | } 34 | } 35 | 36 | private String id; 37 | 38 | private String text; 39 | 40 | private Map> data = new HashMap>(); 41 | 42 | public DictionaryEntry() {} 43 | 44 | private DictionaryEntry(String id, String text, Map> data) { 45 | this.id = id; 46 | this.text = text; 47 | this.data = data; 48 | } 49 | 50 | public static Builder builder() { 51 | return new Builder(); 52 | } 53 | 54 | public String getId() { 55 | return id; 56 | } 57 | 58 | public String getText() { 59 | return text; 60 | } 61 | 62 | public Map> getData() { 63 | return data; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/GetDictionaryEntryResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class GetDictionaryEntryResponse extends TextRazorResponse { 6 | 7 | private DictionaryEntry response; 8 | 9 | public DictionaryEntry getResponse() { 10 | return response; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/GetDictionaryResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import com.textrazor.net.TextRazorResponse; 4 | 5 | public class GetDictionaryResponse extends TextRazorResponse { 6 | 7 | private Dictionary response; 8 | 9 | public Dictionary getResponse() { 10 | return response; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/textrazor/dictionary/model/PagedAllEntries.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.dictionary.model; 2 | 3 | import java.util.List; 4 | 5 | public class PagedAllEntries { 6 | 7 | int total; 8 | 9 | int limit; 10 | 11 | int offset; 12 | 13 | List entries; 14 | 15 | public int getTotal() { 16 | return total; 17 | } 18 | 19 | public int getLimit() { 20 | return limit; 21 | } 22 | 23 | public int getOffset() { 24 | return offset; 25 | } 26 | 27 | public List getEntries() { 28 | return entries; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/com/textrazor/net/QueryBuilder.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.net; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.net.URLEncoder; 5 | import java.util.List; 6 | 7 | public class QueryBuilder { 8 | 9 | private StringBuilder path = new StringBuilder(); 10 | 11 | private boolean firstComponent = true; 12 | 13 | public QueryBuilder addParam(String name, String value) throws UnsupportedEncodingException { 14 | if (null == name || null == value || name.isEmpty() || value.isEmpty()) { 15 | return this; 16 | } 17 | 18 | if (firstComponent) { 19 | firstComponent = false; 20 | } 21 | else { 22 | path.append("&"); 23 | } 24 | 25 | path.append(URLEncoder.encode(name, "UTF-8")); 26 | path.append("="); 27 | path.append(URLEncoder.encode(value, "UTF-8")); 28 | 29 | return this; 30 | } 31 | 32 | public QueryBuilder addParam(String name, Boolean value) throws UnsupportedEncodingException { 33 | if (null != value) { 34 | return addParam(name, value ? "true" : "false"); 35 | } 36 | 37 | return this; 38 | } 39 | 40 | public QueryBuilder addParam(String name, List values) throws UnsupportedEncodingException { 41 | if (null != values) { 42 | for (String value : values) { 43 | addParam(name, value); 44 | } 45 | } 46 | 47 | return this; 48 | } 49 | 50 | public QueryBuilder addParam(String name, Integer value) throws UnsupportedEncodingException { 51 | if (null != value) { 52 | return addParam(name, value.toString()); 53 | } 54 | 55 | return this; 56 | } 57 | 58 | public String build() { 59 | return path.toString(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/com/textrazor/net/TextRazorResponse.java: -------------------------------------------------------------------------------- 1 | package com.textrazor.net; 2 | 3 | /** 4 | * Base class for all responses from the TextRazor API. 5 | */ 6 | public class TextRazorResponse { 7 | private double time; 8 | 9 | private boolean ok; 10 | 11 | private String error; 12 | 13 | private String message; 14 | 15 | /** 16 | * @return Total time in seconds TextRazor took to process this request. This does not include any time spent sending or receiving the request/response. 17 | */ 18 | public double getTime() { 19 | return time; 20 | } 21 | 22 | /** 23 | * @return True if TextRazor successfully analyzed your document, False if there was some error. 24 | */ 25 | public boolean isOk() { 26 | return ok; 27 | } 28 | 29 | /** 30 | * @return Descriptive error message of any problems that may have occurred during analysis, or null if there was no error. 31 | */ 32 | public String getError() { 33 | return error; 34 | } 35 | 36 | /** 37 | * @return Any warning or informational messages returned from the server, or an null if there was no message. 38 | */ 39 | public String getMessage() { 40 | return message; 41 | } 42 | } 43 | --------------------------------------------------------------------------------