public function test() { include_once dirname(__FILE__) . "/../Setup.php"; include_once dirname(__FILE__) . '/../ServiceInterface.php'; $service = new ServiceInterface(); $uri = "http://tagthe.net/api/"; $text = urlencode("In 1972, a crack commando unit was sent to prison by a military court for a crime they didn't commit. They promptly escaped from a maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune. If you have a problem, if no-one else can help, and if you can find them, maybe you can hire the A-Team."); $json = $service->InterafceWithService($uri, $text); $this->assertEquals(true, 0 != strpos($json, '"dimensions":{"topic":["unit","prison","crack","crime","maximum","stockade","court","commando","security","underground"],"location":["Los Angeles"],"language":["english"]}}]}')); }
public function test() { include_once dirname(__FILE__) . "/../../../Setup.php"; include_once dirname(__FILE__) . "/../../../Modules/SiLCCInterface/SiLCCPreProcessingStep.php"; $service = new ServiceInterface(); $uri = "http://opensilcc.com/api/tag"; $text = urlencode("In 1972, a crack commando unit was sent to prison by a military court for a crime they didn't commit. They promptly escaped from a maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune. If you have a problem, if no-one else can help, and if you can find them, maybe you can hire the A-Team."); $config = \Swiftriver\Core\Setup::COnfiguration(); $json = $service->InterafceWithService($uri, $text, $config); $this->assertEquals('["crack", "commando", "unit", "prison", "court", "crime", "commit", "maximum", "security", "stockade", "Los", "Angeles", "underground", "Today", "government", "soldier", "fortune", "problem", "A-Team"]', $json); }
/** * This method, converts the relevant bits of the Content * items to JSON, sends them to the SiCDS and using the * return JSON, only returns content that is unique. * * @param \Swiftriver\Core\ObjectModel\Content $contentItems * @return \Swiftriver\Core\ObjectModel\Content[] */ public function Process($contentItems) { //Get the JSON for the call $toJSONParser = new ContentToJSONParser(); $jsonToService = $toJSONParser->Parse($contentItems); //Make the webservice call $uri = $serviceUri; $interface = new ServiceInterface(); $jsonFromService = $interface->InterafceWithSiCDS($uri, $jsonToService); //Decode the JSON $fromJSONParser = new UniqueContentFromJSONParser(); $uniqueIds = $fromJSONParser->Parse($jsonFromService); //Filter out the none unique content $filter = new UniqueContentFilter(); $uniqueContent = $filter->Filter($uniqueIds, $contentItems); //return the unique content return $uniqueContent; }