|
| 1 | +/** |
| 2 | +* Copyright 2015 IBM Corp. All Rights Reserved. |
| 3 | +* |
| 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +* you may not use this file except in compliance with the License. |
| 6 | +* You may obtain a copy of the License at |
| 7 | +* |
| 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +* |
| 10 | +* Unless required by applicable law or agreed to in writing, software |
| 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +* See the License for the specific language governing permissions and |
| 14 | +* limitations under the License. |
| 15 | +* |
| 16 | +*/ |
| 17 | + |
| 18 | +using FullSerializer; |
| 19 | + |
| 20 | +namespace IBM.Watson.DeveloperCloud.Services.ToneAnalyzer.v1 |
| 21 | +{ |
| 22 | + |
| 23 | + |
| 24 | + [fsObject] |
| 25 | + public class ToneAnalyzerResponse |
| 26 | + { |
| 27 | + public DocumentTone document_tone { get; set;} |
| 28 | + public SentenceTone[] sentences_tone { get; set;} |
| 29 | + |
| 30 | + public override string ToString() |
| 31 | + { |
| 32 | + string sentenceTone = ( sentences_tone != null && sentences_tone.Length > 0 )? sentences_tone[0].ToString() : "No Sentence Tone"; |
| 33 | + return string.Format("[ToneAnalyzerResponse: document_tone={0}, sentenceTone={1}]", document_tone, sentenceTone); |
| 34 | + } |
| 35 | + }; |
| 36 | + |
| 37 | + [fsObject] |
| 38 | + public class DocumentTone |
| 39 | + { |
| 40 | + public ToneCategory[] tone_categories { get; set;} |
| 41 | + |
| 42 | + public override string ToString() |
| 43 | + { |
| 44 | + string toneCategoryString = ""; |
| 45 | + for (int i = 0; tone_categories != null && i < tone_categories.Length; i++) |
| 46 | + { |
| 47 | + toneCategoryString += tone_categories[i].ToString(); |
| 48 | + } |
| 49 | + |
| 50 | + return string.Format("[DocumentTone: tone_categories={0}]", toneCategoryString); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + [fsObject] |
| 55 | + public class ToneCategory |
| 56 | + { |
| 57 | + public string category_id { get; set;} |
| 58 | + public string category_name { get; set;} |
| 59 | + public Tone[] tones { get; set;} |
| 60 | + |
| 61 | + public override string ToString() |
| 62 | + { |
| 63 | + string tonesString = ""; |
| 64 | + for (int i = 0; tones != null && i < tones.Length; i++) |
| 65 | + { |
| 66 | + tonesString += tones[i].ToString(); |
| 67 | + } |
| 68 | + |
| 69 | + return string.Format("[ToneCategory: category_id={0}, category_name={1}, tones={2}]", category_id, category_name, tonesString); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + [fsObject] |
| 74 | + public class Tone |
| 75 | + { |
| 76 | + public double score { get; set;} |
| 77 | + public string tone_id { get; set;} |
| 78 | + public string tone_name { get; set;} |
| 79 | + |
| 80 | + public override string ToString() |
| 81 | + { |
| 82 | + return string.Format("[Tone: score={0}, tone_id={1}, tone_name={2}]", score, tone_id, tone_name); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + [fsObject] |
| 87 | + public class SentenceTone |
| 88 | + { |
| 89 | + public int sentence_id { get; set;} |
| 90 | + public int input_from { get; set;} |
| 91 | + public int input_to { get; set;} |
| 92 | + public string text { get; set;} |
| 93 | + public ToneCategory[] tone_categories { get; set;} |
| 94 | + |
| 95 | + private double m_HighestScore = -1; |
| 96 | + public double HighestScore |
| 97 | + { |
| 98 | + get |
| 99 | + { |
| 100 | + if(m_HighestScore < 0){ |
| 101 | + for (int i = 0; tone_categories != null && i < tone_categories.Length; i++) |
| 102 | + { |
| 103 | + for (int j = 0; tone_categories[i].tones != null && j < tone_categories[i].tones.Length; j++) { |
| 104 | + |
| 105 | + if (m_HighestScore < tone_categories[i].tones[j].score) |
| 106 | + { |
| 107 | + m_HighestScore = tone_categories[i].tones[j].score; |
| 108 | + m_HighestScoreToneName = tone_categories[i].tones[j].tone_name; |
| 109 | + m_HighestScoreToneCategoryName = tone_categories[i].category_name; |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + } |
| 114 | + } |
| 115 | + return m_HighestScore; |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + private string m_HighestScoreToneName = null; |
| 120 | + public string HighestScoreToneName |
| 121 | + { |
| 122 | + get |
| 123 | + { |
| 124 | + if (string.IsNullOrEmpty(m_HighestScoreToneName)) |
| 125 | + { |
| 126 | + double testScore = HighestScore; |
| 127 | + } |
| 128 | + |
| 129 | + return m_HighestScoreToneName; |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + private string m_HighestScoreToneCategoryName = null; |
| 134 | + public string HighestScoreToneCategoryName |
| 135 | + { |
| 136 | + get |
| 137 | + { |
| 138 | + if (string.IsNullOrEmpty(m_HighestScoreToneCategoryName)) |
| 139 | + { |
| 140 | + double testScore = HighestScore; |
| 141 | + } |
| 142 | + |
| 143 | + return m_HighestScoreToneCategoryName; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + public override string ToString() |
| 148 | + { |
| 149 | + string toneCategoryString = ""; |
| 150 | + for (int i = 0; tone_categories != null && i < tone_categories.Length; i++) |
| 151 | + { |
| 152 | + toneCategoryString += tone_categories[i].ToString(); |
| 153 | + } |
| 154 | + |
| 155 | + return string.Format("[SentenceTone: sentence_id={0}, input_from={1}, input_to={2}, text={3}, tone_categories={4}]", sentence_id, input_from, input_to, text, toneCategoryString); |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + |
| 160 | + /* |
| 161 | + { |
| 162 | + "document_tone": { |
| 163 | + "tone_categories": [ |
| 164 | + { |
| 165 | + "tones": [ |
| 166 | + { |
| 167 | + "score": 0.25482, |
| 168 | + "tone_id": "anger", |
| 169 | + "tone_name": "Anger" |
| 170 | + }, |
| 171 | + { |
| 172 | + "score": 0.345816, |
| 173 | + "tone_id": "disgust", |
| 174 | + "tone_name": "Disgust" |
| 175 | + }, |
| 176 | + { |
| 177 | + "score": 0.121116, |
| 178 | + "tone_id": "fear", |
| 179 | + "tone_name": "Fear" |
| 180 | + }, |
| 181 | + { |
| 182 | + "score": 0.078903, |
| 183 | + "tone_id": "joy", |
| 184 | + "tone_name": "Joy" |
| 185 | + }, |
| 186 | + { |
| 187 | + "score": 0.199345, |
| 188 | + "tone_id": "sadness", |
| 189 | + "tone_name": "Sadness" |
| 190 | + } |
| 191 | + ], |
| 192 | + "category_id": "emotion_tone", |
| 193 | + "category_name": "Emotion Tone" |
| 194 | + }, |
| 195 | + { |
| 196 | + "tones": [ |
| 197 | + { |
| 198 | + "score": 0.999, |
| 199 | + "tone_id": "analytical", |
| 200 | + "tone_name": "Analytical" |
| 201 | + }, |
| 202 | + { |
| 203 | + "score": 0.999, |
| 204 | + "tone_id": "confident", |
| 205 | + "tone_name": "Confident" |
| 206 | + }, |
| 207 | + { |
| 208 | + "score": 0.694, |
| 209 | + "tone_id": "tentative", |
| 210 | + "tone_name": "Tentative" |
| 211 | + } |
| 212 | + ], |
| 213 | + "category_id": "writing_tone", |
| 214 | + "category_name": "Writing Tone" |
| 215 | + }, |
| 216 | + { |
| 217 | + "tones": [ |
| 218 | + { |
| 219 | + "score": 0.271, |
| 220 | + "tone_id": "openness_big5", |
| 221 | + "tone_name": "Openness" |
| 222 | + }, |
| 223 | + { |
| 224 | + "score": 0.11, |
| 225 | + "tone_id": "conscientiousness_big5", |
| 226 | + "tone_name": "Conscientiousness" |
| 227 | + }, |
| 228 | + { |
| 229 | + "score": 0.844, |
| 230 | + "tone_id": "extraversion_big5", |
| 231 | + "tone_name": "Extraversion" |
| 232 | + }, |
| 233 | + { |
| 234 | + "score": 0.257, |
| 235 | + "tone_id": "agreeableness_big5", |
| 236 | + "tone_name": "Agreeableness" |
| 237 | + }, |
| 238 | + { |
| 239 | + "score": 0.497, |
| 240 | + "tone_id": "neuroticism_big5", |
| 241 | + "tone_name": "Emotional Range" |
| 242 | + } |
| 243 | + ], |
| 244 | + "category_id": "social_tone", |
| 245 | + "category_name": "Social Tone" |
| 246 | + } |
| 247 | + ] |
| 248 | + } |
| 249 | +
|
| 250 | + "sentences_tone": [ |
| 251 | + { |
| 252 | + "sentence_id": 0, |
| 253 | + "input_from": 0, |
| 254 | + "input_to": 0, |
| 255 | + "text": "string", |
| 256 | + "tone_categories": [ |
| 257 | + { |
| 258 | + "category_name": "string", |
| 259 | + "category_id": "string", |
| 260 | + "tones": [ |
| 261 | + { |
| 262 | + "tone_name": "string", |
| 263 | + "tone_id": "string", |
| 264 | + "tone_category_name": "string", |
| 265 | + "tone_category_id": "string", |
| 266 | + "score": 0 |
| 267 | + } |
| 268 | + ] |
| 269 | + } |
| 270 | + ] |
| 271 | + } |
| 272 | + */ |
| 273 | +} |
0 commit comments