From 040257eada65fb53d85d676922535b2a6d7e5536 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 15 Nov 2019 21:57:59 +1100 Subject: [PATCH 1/9] Fixed indentation in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe5daa0..937abca 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ To understand the models and their functions, see https://github.com/conversatio jitpack.io https://jitpack.io - + ``` From b3c9d26b5e652626b50f926b5b9bc45d765e44f0 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 15 Nov 2019 22:04:27 +1100 Subject: [PATCH 2/9] Create LICENSE --- LICENSE | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..627af24 --- /dev/null +++ b/LICENSE @@ -0,0 +1,190 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2019 Origma Pty Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 713b756454cdf89ffe4ca2bc40662709b80de1a7 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 15 Nov 2019 22:08:28 +1100 Subject: [PATCH 3/9] Updated licence header --- README.md | 1 + .../v1alpha1/PerspectiveAPI.java | 19 +++++++++++++++---- .../v1alpha1/UnirestPerspectiveAPI.java | 19 +++++++++++++++---- .../models/AnalyzeCommentRequest.java | 19 +++++++++++++++---- .../models/AnalyzeCommentResponse.java | 19 +++++++++++++++---- .../v1alpha1/models/AttributeScore.java | 19 +++++++++++++++---- .../v1alpha1/models/AttributeType.java | 19 +++++++++++++++---- .../v1alpha1/models/ContentType.java | 19 +++++++++++++++---- .../v1alpha1/models/Context.java | 19 +++++++++++++++---- .../perspectiveapi/v1alpha1/models/Entry.java | 19 +++++++++++++++---- .../v1alpha1/models/RequestedAttribute.java | 19 +++++++++++++++---- .../perspectiveapi/v1alpha1/models/Score.java | 19 +++++++++++++++---- .../v1alpha1/models/ScoreType.java | 19 +++++++++++++++---- .../v1alpha1/models/SpanScore.java | 19 +++++++++++++++---- 14 files changed, 196 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 937abca..10b1fd4 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ To understand the models and their functions, see https://github.com/conversatio ``` ... + ``` diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java b/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java index 6f810d6..f0a8d89 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java b/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java index 1c3f465..bffbbc4 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java index cd48cff..78c9629 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java index 02ab67d..f1cc101 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java index 74bd483..b6f0486 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java index d4744bf..fa73d04 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/ContentType.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/ContentType.java index b2d89cd..e3a3cd8 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/ContentType.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/ContentType.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/Context.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/Context.java index b785021..636eeac 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/Context.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/Context.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/Entry.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/Entry.java index 046d6a9..235822a 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/Entry.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/Entry.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java index 5eb92ee..1cce4d6 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java index 586d147..eda6a78 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/ScoreType.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/ScoreType.java index 25dfca1..5c54082 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/ScoreType.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/ScoreType.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java index 735bd01..7ac1cae 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java @@ -1,7 +1,18 @@ -/* - * Copyright (C) Origma Pty Ltd (ACN 629 381 184). All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited - * Proprietary and confidential +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; From bcb9b9a0e0af6eb665f64b353ea93d7fbb678544 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 15 Nov 2019 22:47:25 +1100 Subject: [PATCH 4/9] Implemented score suggestion --- .../v1alpha1/PerspectiveAPI.java | 14 ++ .../v1alpha1/UnirestPerspectiveAPI.java | 16 ++ .../v1alpha1/models/SuggestScoreRequest.java | 212 ++++++++++++++++++ .../v1alpha1/models/SuggestScoreResponse.java | 60 +++++ 4 files changed, 302 insertions(+) create mode 100644 src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreRequest.java create mode 100644 src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreResponse.java diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java b/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java index f0a8d89..f32020f 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java @@ -19,6 +19,8 @@ import au.com.origma.perspectiveapi.v1alpha1.models.AnalyzeCommentRequest; import au.com.origma.perspectiveapi.v1alpha1.models.AnalyzeCommentResponse; +import au.com.origma.perspectiveapi.v1alpha1.models.SuggestScoreRequest; +import au.com.origma.perspectiveapi.v1alpha1.models.SuggestScoreResponse; /** * Interact with Google's PerspectiveAPI to analyze comments and content.
@@ -34,6 +36,11 @@ public interface PerspectiveAPI { */ public static final String ANALYZE_ENDPOINT = "https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze"; + /** + * The endpoint to which suggestion requests are sent + */ + public static final String SUGGEST_ENDPOINT = "https://commentanalyzer.googleapis.com/v1alpha1/comments:suggestscore"; + /** * Analyze a comment * @param request The request @@ -48,6 +55,13 @@ public interface PerspectiveAPI { */ public AnalyzeCommentResponse analyze(String comment); + /** + * Suggest a score for a comment + * @param request The request + * @return The response + */ + public SuggestScoreResponse suggestScore(SuggestScoreRequest request); + /** * Instantiate the default implementation of the PerspectiveAPI * @param apiKey The Google API key diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java b/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java index bffbbc4..420f42a 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java @@ -22,6 +22,8 @@ import au.com.origma.perspectiveapi.v1alpha1.models.AttributeType; import au.com.origma.perspectiveapi.v1alpha1.models.ContentType; import au.com.origma.perspectiveapi.v1alpha1.models.Entry; +import au.com.origma.perspectiveapi.v1alpha1.models.SuggestScoreRequest; +import au.com.origma.perspectiveapi.v1alpha1.models.SuggestScoreResponse; import kong.unirest.HttpResponse; import kong.unirest.Unirest; @@ -69,6 +71,20 @@ public AnalyzeCommentResponse analyze(String comment) { .doNotStore(doNotStore) .build()); } + + @Override + public SuggestScoreResponse suggestScore(SuggestScoreRequest request) { + HttpResponse response = Unirest.post(SUGGEST_ENDPOINT) + .queryString("key", apiKey) + .body(request) + .asObject(SuggestScoreResponse.class); + + if(!response.isSuccess()){ + return null; + } + + return response.getBody(); + } /** * If the simple analysis will default to do not store diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreRequest.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreRequest.java new file mode 100644 index 0000000..58b7531 --- /dev/null +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreRequest.java @@ -0,0 +1,212 @@ +/* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Written by Ben McLean , November 2019 + */ +package au.com.origma.perspectiveapi.v1alpha1.models; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Send a suggested score for a request + * + * @author Ben McLean <ben@origma.com.au> + * + */ +public class SuggestScoreRequest { + + Entry comment; + Context context; + Map attributeScores; + List languages; + String communityId; + String clientToken; + + /** + * Same as AnalyzeComment request. + * + * @return the comment for which the score is being suggested + */ + public Entry getComment() { + return comment; + } + + /** + * Same as AnalyzeComment request. + * + * @return the context of the request + */ + public Context getContext() { + return context; + } + + /** + * Similar to AnalyzeComment response. This holds the attribute scores that the + * client believes the comment should have. It has the same format as the + * attributeScores field in the AnalyzeComment response, as it's what the client + * believes is the correct "answer" for what this comment should be scored as. + * The client can specify just summary scores, just span scores, or both. + * + * @return the attribute scores of the request + */ + public Map getAttributeScores() { + return attributeScores; + } + + /** + * Returns the languages of the request + * + * @return the languages of the request + */ + public List getLanguages() { + return languages; + } + + /** + * Opaque identifier associating this score suggestion with a particular + * community. If set, this field allows us to differentiate suggestions from + * different communities, as each community may have different norms. + * + * @return the community id + */ + public String getCommunityId() { + return communityId; + } + + /** + * An opaque token that is echoed back in the response. + * + * @return the client token + */ + public String getClientToken() { + return clientToken; + } + + /** + * Builds a SuggestScoreRequest + * + * @author Ben McLean <ben@origma.com.au> + * + */ + public static class Builder { + private Entry comment; + private Context context; + private Map attributeScores = new HashMap<>(); + private List languages = new ArrayList<>(); + private String communityId; + private String clientToken; + + /** + * Set the comment for a suggestion + * @param comment the comment + * @return The builder + */ + public Builder comment(Entry comment) { + this.comment = comment; + return this; + } + + /** + * Set the context for a suggestion + * @param context the context + * @return The builder + */ + public Builder context(Context context) { + this.context = context; + return this; + } + + /** + * Set the attribute scores for a suggestion + * @param attributeScores the attribute scores + * @return The builder + */ + public Builder attributeScores(Map attributeScores) { + this.attributeScores = attributeScores; + return this; + } + + /** + * Add an attribute score + * @param type The attribute type + * @param score The attribute score + * @return The builder + */ + public Builder addAttributeScore(AttributeType type, AttributeScore score) { + this.attributeScores.put(type, score); + return this; + } + + /** + * Set the languages for a suggestion + * @param languages the languages + * @return The builder + */ + public Builder languages(List languages) { + this.languages = languages; + return this; + } + + /** + * Add a language + * @param language the language + * @return The builder + */ + public Builder addLanugage(String language) { + this.languages.add(language); + return this; + } + + /** + * Set the community id + * @param communityId the community id + * @return The builder + */ + public Builder communityId(String communityId) { + this.communityId = communityId; + return this; + } + + /** + * Set the client token + * @param clientToken the client token + * @return The builder + */ + public Builder clientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + /** + * Build a new SuggestScoreRequest instance + * @return a new SuggestScoreRequest instance + */ + public SuggestScoreRequest build() { + return new SuggestScoreRequest(this); + } + } + + private SuggestScoreRequest(Builder builder) { + this.comment = builder.comment; + this.context = builder.context; + this.attributeScores = builder.attributeScores; + this.languages = builder.languages; + this.communityId = builder.communityId; + this.clientToken = builder.clientToken; + } +} diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreResponse.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreResponse.java new file mode 100644 index 0000000..bd1d5d0 --- /dev/null +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/SuggestScoreResponse.java @@ -0,0 +1,60 @@ +/* + /* + * Copyright 2019 Origma Pty Ltd (ACN 629 381 184) and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Written by Ben McLean , November 2019 + */ +package au.com.origma.perspectiveapi.v1alpha1.models; + +/** + * A SuggestScoreRequest response + * + * @author Ben McLean <ben@origma.com.au> + * + */ +public class SuggestScoreResponse { + + String clientToken; + + /** + * Create an empty instance + */ + public SuggestScoreResponse() {} + + /** + * Create an instance + */ + public SuggestScoreResponse(String clientToken) { + super(); + this.clientToken = clientToken; + } + + /** + * Mirrors the request's clientToken + * @return the client token + */ + public String getClientToken() { + return clientToken; + } + + /** + * Sets the client token + * @param clientToken the client token + */ + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + +} From e130a802217ddb138647df0aa8b0b01ef211f002 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 15 Nov 2019 22:49:19 +1100 Subject: [PATCH 5/9] Updated version code --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10b1fd4..fe55edb 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To understand the models and their functions, see https://github.com/conversatio com.github.origma Google-PerspectiveAPI-Java-Client - 0.0.3 + 0.0.5 ``` ... diff --git a/pom.xml b/pom.xml index 170f9b2..41ef59c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 au.com.origma PerspectiveAPI - 0.0.4 + 0.0.5 src From d145de19e2c5e1ec9a6ff57f2f73fd4d30ed447d Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Sat, 16 Nov 2019 02:45:49 +1100 Subject: [PATCH 6/9] Added JavaDoc to AttributeType --- .../v1alpha1/models/AttributeType.java | 108 ++++++++++++++++-- 1 file changed, 98 insertions(+), 10 deletions(-) diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java index fa73d04..26af6ca 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeType.java @@ -25,29 +25,117 @@ */ public enum AttributeType { - TOXICITY, - TOXICITY_EXPERIMENTAL, - SEVERE_TOXICITY, - SEVERE_TOXICITY_EXPERIMENTAL, - TOXICITY_FAST, - IDENTITY_ATTACK, + /** + * Rude, disrespectful, or unreasonable comment that is likely to make people + * leave a discussion. + */ + TOXICITY, + /** + * Rude, disrespectful, or unreasonable comment that is likely to make people + * leave a discussion. + */ + TOXICITY_EXPERIMENTAL, + /** + * A very hateful, aggressive, disrespectful comment or otherwise very likely to + * make a user leave a discussion or give up on sharing their perspective. This + * model is much less sensitive to comments that include positive uses of curse + * words, for example. A labelled dataset and details of the methodology can be + * found in the same toxicity dataset that is available for the toxicity model. + */ + SEVERE_TOXICITY, + /** + * A very hateful, aggressive, disrespectful comment or otherwise very likely to + * make a user leave a discussion or give up on sharing their perspective. This + * model is much less sensitive to comments that include positive uses of curse + * words, for example. A labelled dataset and details of the methodology can be + * found in the same toxicity dataset that is available for the toxicity model. + */ + SEVERE_TOXICITY_EXPERIMENTAL, + /** + * This model is similar to the TOXICITY model, but has lower latency and lower + * accuracy in its predictions. Unlike TOXICITY, this model returns summary + * scores as well as span scores. This model uses character-level n-grams fed + * into a logistic regression, a method that has been surprisingly effective at + * detecting abusive language. + */ + TOXICITY_FAST, + /** + * Negative or hateful comments targeting someone because of their identity. + */ + IDENTITY_ATTACK, + /** + * Negative or hateful comments targeting someone because of their identity. + */ IDENTITY_ATTACK_EXPERIMENTAL, + /** + * Insulting, inflammatory, or negative comment towards a person or a group of + * people. + */ INSULT, + /** + * Insulting, inflammatory, or negative comment towards a person or a group of + * people. + */ INSULT_EXPERIMENTAL, + /** + * Swear words, curse words, or other obscene or profane language. + */ PROFANITY, + /** + * Swear words, curse words, or other obscene or profane language. + */ PROFANITY_EXPERIMENTAL, + /** + * Describes an intention to inflict pain, injury, or violence against an + * individual or group. + */ THREAT, + /** + * Describes an intention to inflict pain, injury, or violence against an + * individual or group. + */ THREAT_EXPERIMENTAL, + /** + * Contains references to sexual acts, body parts, or other lewd content. + */ SEXUALLY_EXPLICIT, + /** + * Pickup lines, complimenting appearance, subtle sexual innuendos, etc. + */ FLIRTATION, /* New York Times models below */ + /** + * Attack on the author of an article or post. + */ ATTACK_ON_AUTHOR, + /** + * Attack on fellow commenter. + */ ATTACK_ON_COMMENTER, + /** + * Difficult to understand, nonsensical. + */ INCOHERENT, + /** + * Intending to provoke or inflame. + */ INFLAMMATORY, - LIKELY_TO_REJECT, - OBSCENE, - SPAM, + /** + * Overall measure of the likelihood for the comment to be rejected according to + * the NYT's moderation. + */ + LIKELY_TO_REJECT, + /** + * Obscene or vulgar language such as cursing. + */ + OBSCENE, + /** + * Irrelevant and unsolicited commercial content. + */ + SPAM, + /** + * Trivial or short comments. + */ UNSUBSTANTIAL; - + } From b69fdfefac3eba8a6cf7435995aca67cb1201f62 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Sat, 16 Nov 2019 02:52:23 +1100 Subject: [PATCH 7/9] Improved JavaDoc --- .../models/AnalyzeCommentRequest.java | 91 ++++++++++++++----- .../v1alpha1/models/RequestedAttribute.java | 36 +++++++- 2 files changed, 104 insertions(+), 23 deletions(-) diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java index 78c9629..fdc5022 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java @@ -24,10 +24,11 @@ /** * A request to analyze a string of text for attributes + * * @author Ben McLean <ben@origma.com.au> */ public class AnalyzeCommentRequest { - + Entry comment; Context context; Map requestedAttributes; @@ -36,17 +37,22 @@ public class AnalyzeCommentRequest { String clientToken; String sessionId; Double suggestCommentScore; - + /** - * Returns the comment to be analyzed by the request - * @return + * The text to score. This is assumed to be utf8 raw text of the text to be + * checked. Emoji and other non-ascii characters can be included (HTML will + * probably result in lower performance). + * + * @return the comment */ public Entry getComment() { return comment; } /** - * Returns the content of the request + * A list of objects providing the context for comment. Currently not supported + * by the API. + * * @return the content of the request */ public Context getContext() { @@ -54,7 +60,12 @@ public Context getContext() { } /** - * Returns the attributes that will be requested + * A map from model's attribute name to a configuration object. See the models + * section for a list of available model attribute names. If no configuration + * options are specified, defaults are used, so the empty object {} is a valid + * (and common) choice. You can specify multiple model names here to get scores + * from multiple models in a single request. + * * @return the attributes that will be requested */ public Map getRequestedAttributes() { @@ -62,15 +73,30 @@ public Map getRequestedAttributes() { } /** - * Returns the set languages for the request + * A list of ISO 631-1 two-letter language codes specifying the language(s) that + * comment is in (for example, "en", "es", "fr", "de", etc). If unspecified, the + * API will auto-detect the comment language. If language detection fails, the + * API returns an error. Note: Currently, all production models only support + * English, Spanish, and French. There is no simple way to use the API across + * languages with production support and languages with experimental support + * only. + * * @return the set languages for the request */ public List getLanguages() { return languages; } - + /** - * Returns whether the comment will be stored for analysis or not + * Whether the API is permitted to store comment and context from this request. + * Stored comments will be used for future research and community model building + * purposes to improve the API over time. We also plan to provide dashboards and + * automated analysis of the comments submitted, which will apply only to those + * stored. Defaults to false (request data may be stored). Warning: This should + * be set to true if data being submitted is private (i.e. not publicly + * accessible), or if the data submitted contains content written by someone + * under 13 years old. + * * @return whether the comment will be stored for analysis or not */ public Boolean getDoNotStore() { @@ -78,7 +104,8 @@ public Boolean getDoNotStore() { } /** - * Returns the client token of the request + * An opaque token that is echoed back in the response. + * * @return the client token of the request */ public String getClientToken() { @@ -86,7 +113,11 @@ public String getClientToken() { } /** - * Returns the session ID of the request + * An opaque session id. This should be set for authorship experiences by the + * client side so that groups of requests can be grouped together into a + * session. This should not be used for any user-specific id. This is intended + * for abuse protection and individual sessions of interaction. + * * @return the session ID of the request */ public String getSessionId() { @@ -94,7 +125,11 @@ public String getSessionId() { } /** - * Returns the comment score suggested to the analyzer + * Used to notify the Perspective API team of specific biases, in order to help + * us improve our model. Many kinds of toxic language are disproportionately + * represented in our dataset, which leads to some obviously incorrect scores, + * as well as unintended biases. Use this method to help us correct them. + * * @return the comment score suggested to the analyzer */ public Double getSuggestCommentScore() { @@ -119,6 +154,7 @@ public static class Builder { /** * Set the comment of the future AnalyzeCommentRequest + * * @param comment the comment of the future AnalyzeCommentRequest * @return The builder */ @@ -129,6 +165,7 @@ public Builder comment(Entry comment) { /** * Set the context of the future AnalyzeCommentRequest + * * @param context the context of the future AnalyzeCommentRequest * @return The builder */ @@ -139,24 +176,27 @@ public Builder context(Context context) { /** * Set the requested attributes of the future AnalyzeCommentRequest - * @param requestedAttributes the requested attributes of the future AnalyzeCommentRequest + * + * @param requestedAttributes the requested attributes of the future + * AnalyzeCommentRequest * @return The builder */ public Builder requestedAttributes(Map requestedAttributes) { this.requestedAttributes = requestedAttributes; return this; } - + /** * Add a requested attribute to the future AnalyzeCommentRequest - * @param type The type of the requested attribute + * + * @param type The type of the requested attribute * @param requestedAttribute The parameters of the requested attribute * @return The builder */ public Builder addRequestedAttribute(AttributeType type, RequestedAttribute requestedAttribute) { - if(requestedAttribute != null){ + if (requestedAttribute != null) { requestedAttributes.put(type, requestedAttribute); - }else{ + } else { requestedAttributes.put(type, new RequestedAttribute.Builder().build()); } return this; @@ -164,26 +204,30 @@ public Builder addRequestedAttribute(AttributeType type, RequestedAttribute requ /** * Set the languages of the future AnalyzeCommentRequest - * @param languages the languages of the future AnalyzeCommentRequest in ISO 639-1 + * + * @param languages the languages of the future AnalyzeCommentRequest in ISO + * 639-1 * @return The builder */ public Builder languages(List languages) { this.languages = languages; return this; } - + /** * Add a language to the future AnalyzeCommentRequest + * * @param language The language in ISO 639-1 * @return The builder */ - public Builder addLanguage(String language){ + public Builder addLanguage(String language) { languages.add(language); return this; } /** * Set the do not store of the future AnalyzeCommentRequest + * * @param doNotStore the do not store of the future AnalyzeCommentRequest * @return The builder */ @@ -194,6 +238,7 @@ public Builder doNotStore(Boolean doNotStore) { /** * Set the client token of the future AnalyzeCommentRequest + * * @param clientToken the clientToken of the future AnalyzeCommentRequest * @return The builder */ @@ -204,6 +249,7 @@ public Builder clientToken(String clientToken) { /** * Set the session ID of the future AnalyzeCommentRequest + * * @param sessionId the sessionId of the future AnalyzeCommentRequest * @return The builder */ @@ -214,7 +260,9 @@ public Builder sessionId(String sessionId) { /** * Set the suggested comment score of the future AnalyzeCommentRequest - * @param suggestCommentScore the suggested comment score of the future AnalyzeCommentRequest + * + * @param suggestCommentScore the suggested comment score of the future + * AnalyzeCommentRequest * @return The builder */ public Builder suggestCommentScore(Double suggestCommentScore) { @@ -224,6 +272,7 @@ public Builder suggestCommentScore(Double suggestCommentScore) { /** * Build and create a new instance of AnalyzeCommentRequest + * * @return The builder */ public AnalyzeCommentRequest build() { diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java index 1cce4d6..49c33ae 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java @@ -27,9 +27,12 @@ public class RequestedAttribute { ScoreType scoreType; Double scoreThreshold; + Boolean spanAnnotations; /** - * Returns the score type of the attribute + * The score type returned for this model attribute. Currently, only + * "PROBABILITY" is supported. Probability scores are in the range [0,1] + * * @return the score type of the attribute */ public ScoreType getScoreType() { @@ -37,13 +40,26 @@ public ScoreType getScoreType() { } /** - * Returns the score threshold of the attribute + * The API won't return scores that are below this threshold for this model + * attribute. By default, all scores are returned. + * * @return the score threshold of the attribute */ public Double getScoreThreshold() { return scoreThreshold; } + /** + * A boolean value that indicates if the request should return spans that + * describe the scores for each part of the text (currently done at per-sentence + * level). Defaults to false. + * + * @return the spanAnnotations + */ + public Boolean getSpanAnnotations() { + return spanAnnotations; + } + /** * Builds a RequestedAttribute * @@ -52,9 +68,11 @@ public Double getScoreThreshold() { public static class Builder { private ScoreType scoreType; private Double scoreThreshold; + private Boolean spanAnnotations; /** * Sets the score type of the attribute + * * @param scoreType the score type of the attribute * @return The builder */ @@ -65,6 +83,7 @@ public Builder scoreType(ScoreType scoreType) { /** * Sets the score threshold of the attribute + * * @param scoreThreshold the score threshold of the attribute * @return The builder */ @@ -72,9 +91,21 @@ public Builder scoreThreshold(Double scoreThreshold) { this.scoreThreshold = scoreThreshold; return this; } + + /** + * Sets the span annotations parameter. Defaults to true + * + * @param spanAnnotations if span annotations should be returned + * @return The builder + */ + public Builder spanAnnotations(Boolean spanAnnotations) { + this.spanAnnotations = spanAnnotations; + return this; + } /** * Builds a new instance of RequestedAttribute + * * @return a new instance of RequestedAttribute */ public RequestedAttribute build() { @@ -85,5 +116,6 @@ public RequestedAttribute build() { private RequestedAttribute(Builder builder) { this.scoreType = builder.scoreType; this.scoreThreshold = builder.scoreThreshold; + this.spanAnnotations = builder.spanAnnotations; } } From 71b8e529428c8aae0ea7e2323a03f79334a43ac4 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Sat, 16 Nov 2019 02:55:55 +1100 Subject: [PATCH 8/9] Improved JavaDoc further --- .../models/AnalyzeCommentResponse.java | 23 +++++++++++++------ .../v1alpha1/models/AttributeScore.java | 16 +++++++++---- .../perspectiveapi/v1alpha1/models/Score.java | 13 +++++++---- .../v1alpha1/models/SpanScore.java | 18 +++++++++++---- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java index f1cc101..6d5cfd3 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentResponse.java @@ -31,7 +31,7 @@ public class AnalyzeCommentResponse { Map attributeScores; List languages; String clientToken; - + /** * Create a new empty instance */ @@ -51,24 +51,28 @@ public AnalyzeCommentResponse(Map attributeScores } /** - * Returns the scores of the requested attributes + * A map from model attribute name to per-attribute score objects. The attribute + * names will mirror the request's requestedAttributes. + * * @return the scores of the requested attributes */ public Map getAttributeScores() { return attributeScores; } - + /** * Returns a specific attribute score + * * @param type The attribute for which a score should be returned * @return a specific attribute score */ - public AttributeScore getAttributeScore(AttributeType type){ + public AttributeScore getAttributeScore(AttributeType type) { return attributeScores.get(type); } /** * Sets the attribute scores + * * @param attributeScores the attribute scores */ public void setAttributeScores(Map attributeScores) { @@ -76,7 +80,9 @@ public void setAttributeScores(Map attributeScore } /** - * Gets the languages the request was in + * Mirrors the request's languages. If no languages were specified, the API + * returns the auto-detected language. + * * @return the languages the request was in */ public List getLanguages() { @@ -85,6 +91,7 @@ public List getLanguages() { /** * Sets the languages the request was in + * * @param languages the languages the request was in */ public void setLanguages(List languages) { @@ -92,7 +99,8 @@ public void setLanguages(List languages) { } /** - * Gets the client token + * Mirrors the request's clientToken. + * * @return the client token */ public String getClientToken() { @@ -101,10 +109,11 @@ public String getClientToken() { /** * Sets the client token + * * @param clientToken the client token */ public void setClientToken(String clientToken) { this.clientToken = clientToken; } - + } diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java index b6f0486..a857982 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AttributeScore.java @@ -29,7 +29,7 @@ public class AttributeScore { Score summaryScore; List spanScores; - + /** * Create an empty instance */ @@ -47,7 +47,10 @@ public AttributeScore(Score summaryScore, List spanScores) { } /** - * Returns the summary of all span scores + * The model attribute summary score for the entire comment. All attributes will + * return a summaryScore (unless the request specified a scoreThreshold for the + * attribute that the summaryScore did not exceed). + * * @return the summary of all span scores */ public Score getSummaryScore() { @@ -56,6 +59,7 @@ public Score getSummaryScore() { /** * Sets the summary of all span scores + * * @param summaryScore the summary of all span scores */ public void setSummaryScore(Score summaryScore) { @@ -63,7 +67,10 @@ public void setSummaryScore(Score summaryScore) { } /** - * Returns the scores of spans + * A list of per-span scores for this attribute. These scores apply to different + * parts of the request's comment.text. Note: Some attributes may not return + * spanScores at all. + * * @return the scores of spans */ public List getSpanScores() { @@ -72,10 +79,11 @@ public List getSpanScores() { /** * Sets the scores of spans + * * @param spanScores the scores of spans */ public void setSpanScores(List spanScores) { this.spanScores = spanScores; } - + } diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java index eda6a78..127ecfa 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java @@ -26,12 +26,13 @@ public class Score { float value; ScoreType type; - + /** * Create an empty instance */ - public Score(){} - + public Score() { + } + /** * Create an instance */ @@ -43,6 +44,7 @@ public Score(float value, ScoreType type) { /** * Returns the value of a score + * * @return the value of a score */ public float getValue() { @@ -51,6 +53,7 @@ public float getValue() { /** * Sets the value of a score + * * @param value the value of a score */ public void setValue(float value) { @@ -59,6 +62,7 @@ public void setValue(float value) { /** * Returns the type of a score + * * @return the type of a score */ public ScoreType getType() { @@ -67,10 +71,11 @@ public ScoreType getType() { /** * Sets the type of a score + * * @param type the type of a score */ public void setType(ScoreType type) { this.type = type; } - + } diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java index 7ac1cae..6527b18 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java @@ -16,6 +16,7 @@ * Written by Ben McLean , November 2019 */ package au.com.origma.perspectiveapi.v1alpha1.models; + /** * A score representing a span of the analyzed comment * @@ -27,11 +28,12 @@ public class SpanScore { int begin; int end; Score score; - + /** * Create an empty instance */ - public SpanScore(){} + public SpanScore() { + } /** * Create an instance @@ -44,7 +46,8 @@ public SpanScore(int begin, int end, Score score) { } /** - * Returns the beginning position of the span + * Beginning of the text span in the request comment. + * * @return the beginning position of the span */ public int getBegin() { @@ -53,6 +56,7 @@ public int getBegin() { /** * Sets the beginning position of the span + * * @param begin the beginning position of the span */ public void setBegin(int begin) { @@ -60,7 +64,8 @@ public void setBegin(int begin) { } /** - * Returns the ending position of the span + * End of the text span in the request comment. + * * @return the ending position of the span */ public int getEnd() { @@ -69,6 +74,7 @@ public int getEnd() { /** * Sets the ending position of the span + * * @param end the ending position of the span */ public void setEnd(int end) { @@ -77,6 +83,7 @@ public void setEnd(int end) { /** * Returns the score of the span + * * @return the score of the span */ public Score getScore() { @@ -85,10 +92,11 @@ public Score getScore() { /** * Sets the score of the span + * * @param score the score of the span */ public void setScore(Score score) { this.score = score; } - + } From 56ecf5ed6bc32a2e5ce41108bbff74d73218a3ed Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Sat, 16 Nov 2019 12:41:58 +1100 Subject: [PATCH 9/9] Fixed bug with empty RequestAttributes not being sent --- .../v1alpha1/models/AnalyzeCommentRequest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java index fdc5022..8e1259a 100644 --- a/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java +++ b/src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java @@ -289,5 +289,11 @@ private AnalyzeCommentRequest(Builder builder) { this.clientToken = builder.clientToken; this.sessionId = builder.sessionId; this.suggestCommentScore = builder.suggestCommentScore; + + for(Map.Entry e: requestedAttributes.entrySet()) { + if(e.getValue() == null) { + e.setValue(new RequestedAttribute.Builder().build()); + } + } } }