/profiles/drupal_commons/modules/contrib/tagging/modules/tagging_alchemy_suggest/AlchemyAPIParams.php

https://github.com/schultetwin/commons · PHP · 630 lines · 484 code · 111 blank · 35 comment · 101 complexity · ba6632ce1eb9bb9f90398d148b749614 MD5 · raw file

  1. <?php
  2. /* Parameter class for functions URLGetRankedNamedEntities, HTMLGetRankedNamedEntities, TextGetRankedNamedEntities
  3. //
  4. // See http://www.alchemyapi.com/api/entity/proc.html for detailed parameter descriptions
  5. //
  6. */
  7. class AlchemyAPI_Params{
  8. private $url = null;
  9. private $html = null;
  10. private $text = null;
  11. private $outputMode = "xml";
  12. private $customParameters = null;
  13. private function outputMode_arr()
  14. {
  15. return array
  16. (
  17. 'xml',
  18. 'json'
  19. );
  20. }
  21. public function getUrl(){
  22. return $this->url;
  23. }
  24. public function setUrl($url){
  25. $this->url = $url;
  26. }
  27. public function getHtml(){
  28. return $this->html;
  29. }
  30. public function setHtml($html){
  31. $this->html = $html;
  32. }
  33. public function getText(){
  34. return $this->text;
  35. }
  36. public function setText($text){
  37. $this->text = $text;
  38. }
  39. public function getOutputMode(){
  40. return $this->outputMode;
  41. }
  42. public function setOutputMode($outputMode){
  43. $arr = $this->outputMode_arr();
  44. $isValid = false;
  45. for($i=0;$i<count($arr);$i++){
  46. if($arr[$i] == $outputMode){
  47. $this->outputMode = $outputMode;
  48. return;
  49. }
  50. }
  51. if (!$isValid)
  52. {
  53. throw new Exception("Invalid setting (".$outputMode.") for parameter outputMode");
  54. }
  55. }
  56. public function getCustomParameters(){
  57. return $this->customParameters;
  58. }
  59. public function setCustomParameters(){
  60. $this->customParameters = "";
  61. $numargs = func_num_args();
  62. for($i = 0; $i < $numargs; $i++)
  63. {
  64. $this->customParameters .= "&".func_get_arg($i);
  65. if ((++$i) < $numargs)
  66. $this->customParameters .= "=".rawurlencode(func_get_arg($i));
  67. }
  68. }
  69. public function getParameterString() {
  70. $retString = "";
  71. if(isset($this->url))
  72. $retString=$retString."&url=".rawurlencode($this->url);
  73. if(isset($this->html))
  74. $retString=$retString."&html=".rawurlencode($this->html);
  75. if(isset($this->text))
  76. $retString=$retString."&text=".rawurlencode($this->text);
  77. if(isset($this->customParameters))
  78. $retString=$retString.$this->customParameters;
  79. return $retString;
  80. }
  81. }
  82. class AlchemyAPI_NamedEntityParams extends AlchemyAPI_Params{
  83. private $disambiguate = null;
  84. private $linkedData = null;
  85. private $coreference = null;
  86. private $quotations = null;
  87. private $sourceText = null;
  88. private $showSourceText = null;
  89. private $maxRetrieve = null;
  90. private $baseUrl = null;
  91. private $cQuery = null;
  92. private $xPath = null;
  93. private function sourceText_arr()
  94. {
  95. return array
  96. (
  97. 'cleaned_or_raw',
  98. 'cleaned',
  99. 'raw',
  100. 'cquery',
  101. 'xpath'
  102. );
  103. }
  104. public function getDisambiguate(){
  105. return $this->disambiguate;
  106. }
  107. public function setDisambiguate($disambiguate){
  108. if ($disambiguate != 0 && $disambiguate != 1)
  109. {
  110. throw new Exception("Invalid setting (".$disambiguate.") for parameter disambiguate");
  111. }
  112. $this->disambiguate = $disambiguate;
  113. }
  114. public function getLinkedData(){
  115. return $this->linkedData;
  116. }
  117. public function setLinkedData($linkedData){
  118. if ($linkedData != 0 && $linkedData != 1)
  119. {
  120. throw new Exception("Invalid setting (".$linkedData.") for parameter linkedData");
  121. }
  122. $this->linkedData = $linkedData;
  123. }
  124. public function getCoreference(){
  125. return $this->coreference;
  126. }
  127. public function setCoreference($coreference){
  128. if ($coreference != 0 && $coreference != 1)
  129. {
  130. throw new Exception("Invalid setting (".$coreference.") for parameter coreference");
  131. }
  132. $this->coreference = $coreference;
  133. }
  134. public function getQuotations(){
  135. return $this->quotations;
  136. }
  137. public function setQuotations($quotations){
  138. if ($quotations != 0 && $quotations != 1)
  139. {
  140. throw new Exception("Invalid setting (".$quotations.") for parameter quotations");
  141. }
  142. $this->quotations = $quotations;
  143. }
  144. public function getSourceText(){
  145. return $this->sourceText;
  146. }
  147. public function setSourceText($sourceText){
  148. $arr = $this->sourceText_arr();
  149. $isValid = false;
  150. for($i=0;$i<count($arr);$i++){
  151. if($arr[$i] == $sourceText){
  152. $this->sourceText = $sourceText;
  153. return;
  154. }
  155. }
  156. if (!$isValid)
  157. {
  158. throw new Exception("Invalid setting (".$sourceText.") for parameter sourceText");
  159. }
  160. }
  161. public function getShowSourceText(){
  162. return $this->showSourceText;
  163. }
  164. public function setShowSourceText($showSourceText){
  165. if ($showSourceText != 0 && $showSourceText != 1)
  166. {
  167. throw new Exception("Invalid setting (".$showSourceText.") for parameter showSourceText");
  168. }
  169. $this->showSourceText = $showSourceText;
  170. }
  171. public function getMaxRetrieve(){
  172. return $this->maxRetrieve;
  173. }
  174. public function setMaxRetrieve($maxRetrieve){
  175. $this->maxRetrieve = $maxRetrieve;
  176. }
  177. public function getBaseUrl(){
  178. return $this->baseUrl;
  179. }
  180. public function setBaseUrl($baseUrl){
  181. $this->baseUrl = $baseUrl;
  182. }
  183. public function getCQuery(){
  184. return $this->cQuery;
  185. }
  186. public function setCQuery($cQuery){
  187. $this->cQuery = $cQuery;
  188. }
  189. public function getXPath(){
  190. return $this->xPath;
  191. }
  192. public function setXPath($xPath){
  193. $this->xPath = $xPath;
  194. }
  195. public function getParameterString() {
  196. $retString = parent::getParameterString();
  197. if(isset($this->disambiguate))
  198. $retString=$retString."&disambiguate=".rawurlencode($this->disambiguate);
  199. if(isset($this->linkedData))
  200. $retString=$retString."&linkedData=".rawurlencode($this->linkedData);
  201. if(isset($this->coreference))
  202. $retString=$retString."&coreference=".rawurlencode($this->coreference);
  203. if(isset($this->quotations))
  204. $retString=$retString."&quotations=".rawurlencode($this->quotations);
  205. if(isset($this->showSourceText))
  206. $retString=$retString."&showSourceText=".rawurlencode($this->showSourceText);
  207. if(isset($this->sourceText))
  208. $retString=$retString."&sourceText=".rawurlencode($this->sourceText);
  209. if(isset($this->maxRetrieve))
  210. $retString=$retString."&maxRetrieve=".rawurlencode($this->maxRetrieve);
  211. if(isset($this->baseUrl))
  212. $retString=$retString."&baseUrl=".rawurlencode($this->baseUrl);
  213. if(isset($this->cQuery))
  214. $retString=$retString."&cquery=".rawurlencode($this->cQuery);
  215. if(isset($this->xPath))
  216. $retString=$retString."&xpath=".rawurlencode($this->xPath);
  217. return $retString;
  218. }
  219. }
  220. /* Parameter class for functions URLGetCategory, HTMLGetCategory, TextGetCategory
  221. //
  222. // See http://www.alchemyapi.com/api/categ/proc.html for detailed parameter descriptions
  223. //
  224. */
  225. class AlchemyAPI_CategoryParams extends AlchemyAPI_Params{
  226. private $sourceText = null;
  227. private $cQuery = null;
  228. private $xPath = null;
  229. private $baseUrl = null;
  230. private function sourceText_arr()
  231. {
  232. return array
  233. (
  234. 'cleaned_or_raw',
  235. 'cquery',
  236. 'xpath'
  237. );
  238. }
  239. public function getSourceText(){
  240. return $this->sourceText;
  241. }
  242. public function setSourceText($sourceText){
  243. $arr = $this->sourceText_arr();
  244. $isValid = false;
  245. for($i=0;$i<count($arr);$i++){
  246. if($arr[$i] == $sourceText){
  247. $this->sourceText = $sourceText;
  248. return;
  249. }
  250. }
  251. if (!$isValid)
  252. {
  253. throw new Exception("Invalid setting (".$sourceText.") for parameter sourceText");
  254. }
  255. }
  256. public function getCQuery(){
  257. return $this->cQuery;
  258. }
  259. public function setCQuery($cQuery){
  260. $this->cQuery = $cQuery;
  261. }
  262. public function getXPath(){
  263. return $this->xPath;
  264. }
  265. public function setXPath($xPath){
  266. $this->xPath = $xPath;
  267. }
  268. public function getBaseUrl(){
  269. return $this->baseUrl;
  270. }
  271. public function setBaseUrl($baseUrl){
  272. $this->baseUrl = $baseUrl;
  273. }
  274. public function getParameterString() {
  275. $retString = parent::getParameterString();
  276. if(isset($this->sourceText))
  277. $retString=$retString."&sourceText=".rawurlencode($this->sourceText);
  278. if(isset($this->cQuery))
  279. $retString=$retString."&cquery=".rawurlencode($this->cQuery);
  280. if(isset($this->xPath))
  281. $retString=$retString."&xpath=".rawurlencode($this->xPath);
  282. if(isset($this->baseUrl))
  283. $retString=$retString."&baseUrl=".rawurlencode($this->baseUrl);
  284. return $retString;
  285. }
  286. }
  287. /* Parameter class for functions URLGetLanguage, HTMLGetLanguage, TextGetLanguage
  288. //
  289. // See http://www.alchemyapi.com/api/lang/proc.html for detailed parameter descriptions
  290. //
  291. */
  292. class AlchemyAPI_LanguageParams extends AlchemyAPI_Params{
  293. private $sourceText = null;
  294. private $cQuery = null;
  295. private $xPath = null;
  296. private function sourceText_arr()
  297. {
  298. return array
  299. (
  300. 'cleaned_or_raw',
  301. 'cleaned',
  302. 'raw',
  303. 'cquery',
  304. 'xpath'
  305. );
  306. }
  307. public function getSourceText(){
  308. return $this->sourceText;
  309. }
  310. public function setSourceText($sourceText){
  311. $arr = $this->sourceText_arr();
  312. $isValid = false;
  313. for($i=0;$i<count($arr);$i++){
  314. if($arr[$i] == $sourceText){
  315. $this->sourceText = $sourceText;
  316. return;
  317. }
  318. }
  319. if (!$isValid)
  320. {
  321. throw new Exception("Invalid setting (".$sourceText.") for parameter sourceText");
  322. }
  323. }
  324. public function getCQuery(){
  325. return $this->cQuery;
  326. }
  327. public function setCQuery($cQuery){
  328. $this->cQuery = $cQuery;
  329. }
  330. public function getXPath(){
  331. return $this->xPath;
  332. }
  333. public function setXPath($xPath){
  334. $this->xPath = $xPath;
  335. }
  336. public function getParameterString() {
  337. $retString = parent::getParameterString();
  338. if(isset($this->sourceText))
  339. $retString=$retString."&sourceText=".rawurlencode($this->sourceText);
  340. if(isset($this->cQuery))
  341. $retString=$retString."&cquery=".rawurlencode($this->cQuery);
  342. if(isset($this->xPath))
  343. $retString=$retString."&xpath=".rawurlencode($this->xPath);
  344. return $retString;
  345. }
  346. }
  347. /* Parameter class for functions URLGetRankedKeywords, HTMLGetRankedKeywords, TextGetRankedKeywords
  348. //
  349. // See http://www.alchemyapi.com/api/keyword/proc.html for detailed parameter descriptions
  350. //
  351. */
  352. class AlchemyAPI_KeywordParams extends AlchemyAPI_Params{
  353. private $maxRetrieve = null;
  354. private $sourceText = null;
  355. private $showSourceText = null;
  356. private $cQuery = null;
  357. private $xPath = null;
  358. private $baseUrl = null;
  359. private $keywordExtractMode = null;
  360. private function sourceText_arr()
  361. {
  362. return array
  363. (
  364. 'cleaned_or_raw',
  365. 'cleaned',
  366. 'raw',
  367. 'cquery',
  368. 'xpath'
  369. );
  370. }
  371. public function getMaxRetrieve(){
  372. return $this->maxRetrieve;
  373. }
  374. public function setMaxRetrieve($souceText){
  375. $this->maxRetrieve = $maxRetrieve;
  376. }
  377. public function getSourceText(){
  378. return $this->sourceText;
  379. }
  380. public function setSourceText($sourceText){
  381. $arr = $this->sourceText_arr();
  382. $isValid = false;
  383. for($i=0;$i<count($arr);$i++){
  384. if($arr[$i] == $sourceText){
  385. $this->sourceText = $sourceText;
  386. return;
  387. }
  388. }
  389. if (!$isValid)
  390. {
  391. throw new Exception("Invalid setting (".$sourceText.") for parameter sourceText");
  392. }
  393. }
  394. public function getShowSourceText(){
  395. return $this->showSourceText;
  396. }
  397. public function setShowSourceText($showSourceText){
  398. if ($showSourceText != 0 && $showSourceText != 1)
  399. {
  400. throw new Exception("Invalid setting (".$showSourceText.") for parameter showSourceText");
  401. }
  402. $this->showSourceText = $showSourceText;
  403. }
  404. public function getCQuery(){
  405. return $this->cQuery;
  406. }
  407. public function setCQuery($cQuery){
  408. $this->cQuery = $cQuery;
  409. }
  410. public function getXPath(){
  411. return $this->xPath;
  412. }
  413. public function setXpath($xPath){
  414. $this->xPath = $xPath;
  415. }
  416. public function getBaseUrl(){
  417. return $this->baseUrl;
  418. }
  419. public function setBaseUrl($baseUrl){
  420. $this->baseUrl = $baseUrl;
  421. }
  422. public function getKeywordExtractMode(){
  423. return $this->keywordExtractMode;
  424. }
  425. public function setKeywordExtractMode($keywordExtractMode){
  426. if ($keywordExtractMode != "strict")
  427. {
  428. throw new Exception("Invalid setting (".$keywordExtractMode.") for parameter keywordExtractMode");
  429. }
  430. $this->keywordExtractMode = $keywordExtractMode;
  431. }
  432. public function getParameterString() {
  433. $retString = parent::getParameterString();
  434. if(isset($this->maxRetrieve))
  435. $retString=$retString."&maxRetrieve=".rawurlencode($this->maxRetrieve);
  436. if(isset($this->sourceText))
  437. $retString=$retString."&sourceText=".rawurlencode($this->sourceText);
  438. if(isset($this->showSourceText))
  439. $retString=$retString."&showSourceText=".rawurlencode($this->showSourceText);
  440. if(isset($this->cQuery))
  441. $retString=$retString."&cquery=".rawurlencode($this->cQuery);
  442. if(isset($this->xPath))
  443. $retString=$retString."&xpath=".rawurlencode($this->xPath);
  444. if(isset($this->baseUrl))
  445. $retString=$retString."&baseUrl=".rawurlencode($this->baseUrl);
  446. if(isset($this->keywordExtractMode))
  447. $retString=$retString."&keywordExtractMode=".rawurlencode($this->keywordExtractMode);
  448. return $retString;
  449. }
  450. }
  451. /* Parameter class for functions URLGetText, HTMLGetText, URLGetRawText, HTMLGetRawText, URLGetTitle, HTMLGetTitle
  452. //
  453. // See http://www.alchemyapi.com/api/text/proc.html for detailed parameter descriptions
  454. //
  455. */
  456. class AlchemyAPI_TextParams extends AlchemyAPI_Params{
  457. private $useMetaData = null;
  458. private $extractLinks = null;
  459. public function getUseMetaData(){
  460. return $this->useMetaData;
  461. }
  462. public function setUseMetaData($useMetaData){
  463. if ($useMetaData != 0 && $useMetaData != 1)
  464. {
  465. throw new Exception("Invalid setting (".$useMetaData.") for parameter useMetaData");
  466. }
  467. $this->useMetaData = $useMetaData;
  468. }
  469. public function getExtractLinks(){
  470. return $this->extractLinks;
  471. }
  472. public function setExtractLinks($extractLinks){
  473. if ($extractLinks != 0 && $extractLinks != 1)
  474. {
  475. throw new Exception("Invalid setting (".$extractLinks.") for parameter extractLinks");
  476. }
  477. $this->extractLinks = $extractLinks;
  478. }
  479. public function getParameterString() {
  480. $retString = parent::getParameterString();
  481. if(isset($this->useMetaData))
  482. $retString=$retString."&useMetaData=".rawurlencode($this->useMetaData);
  483. if(isset($this->extractLinks))
  484. $retString=$retString."&extractLinks=".rawurlencode($this->extractLinks);
  485. return $retString;
  486. }
  487. }
  488. /* Parameter class for functions URLGetConstraintQuery, HTMLGetConstraintQuery, TextGetConstraintQuery
  489. //
  490. // See http://www.alchemyapi.com/api/scrape/proc.html for detailed parameter descriptions
  491. //
  492. */
  493. class AlchemyAPI_ConstraintQueryParams extends AlchemyAPI_Params{
  494. private $cQuery = null;
  495. public function getCQuery(){
  496. return $this->cQuery;
  497. }
  498. public function setCQuery($cQuery){
  499. $this->cQuery = $cQuery;
  500. }
  501. public function getParameterString() {
  502. $retString = parent::getParameterString();
  503. if(isset($this->cQuery))
  504. $retString=$retString."&cquery=".rawurlencode($this->cQuery);
  505. return $retString;
  506. }
  507. }
  508. /* Parameter class for functions URLGetMicroformats, HTMLGetMicroformats, TextGetMicroformats
  509. //
  510. // See http://www.alchemyapi.com/api/mformat/proc.html for detailed parameter descriptions
  511. //
  512. */
  513. class AlchemyAPI_MicroformatParams extends AlchemyAPI_Params{
  514. public function getParameterString() {
  515. $retString = parent::getParameterString();
  516. return $retString;
  517. }
  518. }
  519. ?>