<?php

class WortschatzUniLeipzigApiWrapper{

	/**
	* @var string
	**/
	public $username;
	/**
	* @var string
	**/
	public $password;
	/**
	* @see http://php.net/manual/de/soapclient.soapclient.php
	* @var mixed[]
	**/
	public $options;
	
	/**
	* @param string $username [optional] - Default:"anonymous". The login name
	* @param string $password [optional] - Default:"anonymous". The login password
	* @param string[] $options [optional] - Default: [trace=>1, exceptions=>1]. Options array for SoapClient
	**/
	public function __construct($username = "anonymous", $password = "anonymous", $options = array("trace" => 1, "exceptions" => 1)){
		$this->username = $username;
		$this->password = $password;
		$this->options = $options;
	}
	
	/**
	* This service gives an automatically generated overview of all currently available other services, along with links to their download locations and a webstart link.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/ServiceOverview?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Name
	*
	* @return DataVector
	*/
	public function ServiceOverview($Name, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/ServiceOverview?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Name", $Name);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns statistically significant co-occurrences of the input word.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Cooccurrences?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Mindestsignifikanz
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Cooccurrences($Wort, $Mindestsignifikanz, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Cooccurrences?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Mindestsignifikanz", $Mindestsignifikanz);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns the lemmatized (base) form of the input word.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Baseform?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	*
	* @return DataVector
	*/
	public function Baseform($Wort, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Baseform?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns sample sentences containing the input word.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Sentences?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Sentences($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Sentences?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* For a given input word, returns statistically significant right neighbours. (words co-occurring immediately to the right of the input word)
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/RightNeighbours?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function RightNeighbours($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/RightNeighbours?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* For a given input word, returns statistically significant left neighbours. (words co-occurring immediately to the left of the input word)
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/LeftNeighbours?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function LeftNeighbours($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/LeftNeighbours?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns the frequency and frequency class of the input word. Frequency class is computed in relation to the most frequent word in the corpus. The higher the class, the rarer the word.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Frequencies?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	*
	* @return DataVector
	*/
	public function Frequencies($Wort, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Frequencies?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns synonyms of the input word. In other words, this is a thesaurus.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Synonyms?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Synonyms($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Synonyms?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* This is an experimental webservice for the MARS visualization project.
	*
	* Status: ACTIVE
	*
	* Authorization: INTERN
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/MARSService?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Word
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function MARSService($Word, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/MARSService?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Word", $Word);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns statistically significant co-occurrences of the input word. However, the accesses the unrestricted version of the co-occurrences table as in the Cooccurrences services, which means significantly longer wait times.
	*
	* Status: ACTIVE
	*
	* Authorization: INTERN
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/CooccurrencesAll?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Mindestsignifikanz
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function CooccurrencesAll($Wort, $Mindestsignifikanz, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/CooccurrencesAll?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Mindestsignifikanz", $Mindestsignifikanz);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Similarly the Synonyms services returns synonyms of the given input word. However, this first lemmatizes the input word and thus returns more synonyms.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Thesaurus?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Thesaurus($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Thesaurus?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* For a given word form returns all other word forms of the same lemma
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Wordforms?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Word
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Wordforms($Word, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Wordforms?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Word", $Word);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns automatically computed contextually similar words of the input word. Such similar words may be antonyms, hyperonyms, synonyms, cohyponyms or other. Note that due to the huge amount of data any query to this services may take a long time.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Similarity?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Similarity($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Similarity?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Attempts to find linguistic collocations that occur to the left of the given input word. The parameter Wortart accepts four values A,V,N,S which stand for adjective, verb, noun and stopword, respectively. The parameter restricts the type of words found.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/LeftCollocationFinder?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Wortart
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function LeftCollocationFinder($Wort, $Wortart, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/LeftCollocationFinder?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Wortart", $Wortart);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Attempts to find linguistic collocations that occur to the right of the given input word. The parameter Wortart accepts four values A,V,N,S which stand for adjective, verb, noun and stopword, respectively. The parameter restricts the type of words found.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/RightCollocationFinder?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Wortart
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function RightCollocationFinder($Wort, $Wortart, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/RightCollocationFinder?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Wortart", $Wortart);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* This service delivers an experimental synonyms request for internal tests.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/ExperimentalSynonyms?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function ExperimentalSynonyms($Wort, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/ExperimentalSynonyms?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns the intersection of the co-occurrences of the two given words. The result set is ordered according to the sum of the significances in descending order. Note that due to the join involved, this make take some time.
	*
	* Status: ACTIVE
	*
	* Authorization: INTERN
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Kookkurrenzschnitt?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort_1
	* @param mixed $Wort_2
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Kookkurrenzschnitt($Wort_1, $Wort_2, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Kookkurrenzschnitt?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort 1", $Wort_1);
		$params[] = array("Wort 2", $Wort_2);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Returns categories for a given input word.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Sachgebiet?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	*
	* @return DataVector
	*/
	public function Sachgebiet($Wort, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Sachgebiet?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* Given a pattern and a length, returns words that match these parameters.
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/Kreuzwortraetsel?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Wort
	* @param mixed $Wortlaenge
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function Kreuzwortraetsel($Wort, $Wortlaenge, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/Kreuzwortraetsel?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Wort", $Wort);
		$params[] = array("Wortlaenge", $Wortlaenge);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* This service returns reference sentences for a given pattern of word n-grams
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/NGramReferences?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Pattern
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function NGramReferences($Pattern, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/NGramReferences?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Pattern", $Pattern);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	* This service returns word n-grams for a specified pattern
	*
	* Status: ACTIVE
	*
	* Authorization: FREE
	*
	* WSDL-URL: @see http://wortschatz.uni-leipzig.de/axis/services/NGrams?wsdl
	*
	* Service overview: @see http://wortschatz.uni-leipzig.de/axis/servlet/ServiceOverviewServlet
	*
	* @param mixed $Pattern
	* @param mixed $Limit
	*
	* @return DataVector
	*/
	public function NGrams($Pattern, $Limit, $corpus = "de"){
		$url = "http://wortschatz.uni-leipzig.de/axis/services/NGrams?wsdl";
		$options = $this->GetOptions();
		$service = new SoapClient($url, $options);
		$params = array();
		$params[] = array("Pattern", $Pattern);
		$params[] = array("Limit", $Limit);
		return $this->CallMethod($service, $params, $corpus);
	}
	
	/**
	*
	* @return string[]
	*/
	private function GetOptions(){
		$options = $this->options;
		$options["login"] = $this->username;
		$options["password"] = $this->password;
		return $options;
	}
	
	/**
	*
	* @param SoapClient $service
	* @param array $params
	* @param string $corpus
	* @return DataVector
	*/
	private function CallMethod(SoapClient $service, array $params, $corpus = "de"){
		$dataVectors = array();
		foreach($params as $p){
			$dataVectors[] = array("dataRow" => $p);
		}
		$parameters = array("dataVectors" => $dataVectors);
		$request = array("objRequestParameters" => array("corpus" => $corpus, "parameters" => $parameters));
		$result = $service->execute($request);
		if(isset($result->executeReturn->result->dataVectors)){
			return $result->executeReturn->result->dataVectors;
		}
		return null;
	}
	
}
?>