NlpPreprocessRequest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * TOP API: taobao.nlp.preprocess request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2016.01.12
  7. */
  8. class NlpPreprocessRequest
  9. {
  10. /**
  11. * 1)繁简字转换:func_type=1,对应type =1 繁转简 type=2 简转繁;2)拆分字转换:func_type =2,对应type=1 文字拆分 type=2 拆分字合并;3)文字转拼音:func_type =3,对应type=1 文字转拼音 type=2 拼音+声调;4)谐音同音字替换:func_type =4,对应type=1 谐音字替换 type=2 同音字替换;5)形似字替换:func_type =5,对应type=1 形似字替换;
  12. **/
  13. private $funcType;
  14. /**
  15. * 谐音字转换、形似字转换需提供关键词进行替换,关键词之间以#分隔。keyword示例:兼职#招聘#微信、天猫#日结#微信#招聘#加微
  16. **/
  17. private $keyword;
  18. /**
  19. * 文本内容
  20. **/
  21. private $text;
  22. private $apiParas = array();
  23. public function setFuncType($funcType)
  24. {
  25. $this->funcType = $funcType;
  26. $this->apiParas["func_type"] = $funcType;
  27. }
  28. public function getFuncType()
  29. {
  30. return $this->funcType;
  31. }
  32. public function setKeyword($keyword)
  33. {
  34. $this->keyword = $keyword;
  35. $this->apiParas["keyword"] = $keyword;
  36. }
  37. public function getKeyword()
  38. {
  39. return $this->keyword;
  40. }
  41. public function setText($text)
  42. {
  43. $this->text = $text;
  44. $this->apiParas["text"] = $text;
  45. }
  46. public function getText()
  47. {
  48. return $this->text;
  49. }
  50. public function getApiMethodName()
  51. {
  52. return "taobao.nlp.preprocess";
  53. }
  54. public function getApiParas()
  55. {
  56. return $this->apiParas;
  57. }
  58. public function check()
  59. {
  60. RequestCheckUtil::checkNotNull($this->funcType,"funcType");
  61. }
  62. public function putOtherTextParam($key, $value) {
  63. $this->apiParas[$key] = $value;
  64. $this->$key = $value;
  65. }
  66. }