|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace IBM\Watson\ToneAnalyzer\Model; |
|
4
|
|
|
|
|
5
|
|
|
use IBM\Watson\Common\Model\ApiResponseInterface; |
|
6
|
|
|
|
|
7
|
|
|
class ToneAnalysis implements ApiResponseInterface |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis |
|
11
|
|
|
*/ |
|
12
|
|
|
private $documentAnalysis; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis |
|
16
|
|
|
*/ |
|
17
|
|
|
private $sentenceAnalysis; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* ToneAnalysis constructor. |
|
21
|
|
|
* |
|
22
|
|
|
* @param \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis $documentAnalysis |
|
23
|
|
|
* @param \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis $sentenceAnalysis |
|
24
|
|
|
*/ |
|
25
|
6 |
|
public function __construct(DocumentAnalysis $documentAnalysis, SentenceAnalysis $sentenceAnalysis) |
|
26
|
|
|
{ |
|
27
|
6 |
|
$this->documentAnalysis = $documentAnalysis; |
|
28
|
6 |
|
$this->sentenceAnalysis = $sentenceAnalysis; |
|
29
|
6 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Create tone analysis |
|
33
|
|
|
* |
|
34
|
|
|
* @param array $data |
|
35
|
|
|
* |
|
36
|
|
|
* @return \IBM\Watson\ToneAnalyzer\Model\ToneAnalysis |
|
37
|
|
|
*/ |
|
38
|
6 |
|
public static function create(array $data) |
|
39
|
|
|
{ |
|
40
|
6 |
|
$documentAnalysis = DocumentAnalysis::create($data); |
|
41
|
6 |
|
$sentenceAnalysis = SentenceAnalysis::create($data); |
|
42
|
|
|
|
|
43
|
6 |
|
return new self($documentAnalysis, $sentenceAnalysis); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get document level analysis |
|
48
|
|
|
* |
|
49
|
|
|
* @return \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis |
|
50
|
|
|
*/ |
|
51
|
3 |
|
public function getDocumentAnalysis() |
|
52
|
|
|
{ |
|
53
|
3 |
|
return $this->documentAnalysis; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get sentence level analysis |
|
58
|
|
|
* |
|
59
|
|
|
* @return \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis |
|
60
|
|
|
*/ |
|
61
|
3 |
|
public function getSentenceAnalysis() |
|
62
|
|
|
{ |
|
63
|
3 |
|
return $this->sentenceAnalysis; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|