<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Leo
*
* @author len
*/
class Leo {
//put your code here
public $word;
public $plural;
public $url;
public $artikel;
public $resultXml;
public $wordType;
function __construct() {
;
}
function findWord($word){
$this->url = "https://dict.leo.org/dictQuery/m-vocab/ende/query.xml?lang=de&search=$word&side=both&order=advanced§LenMax=16";
$this->resultXml = file_get_contents($this->url);
$pattern = '/lang="de" hitcount="(.*)"/';
preg_match($pattern, $this->resultXml, $matches);
$hitCount = $matches[1];
if($hitCount>0)
return true;
else
return false;
}
function getWordType(){
$pattern ='/sctName=\"([^"]*)\"/';
preg_match($pattern, $this->resultXml, $matches);
$this->wordType = trim($matches[1]);
return trim($matches[1]);
// return trim($this->url);
}
function isSubstantive(){
return strpos($this->wordType, "subst") >= 0;
}
function getWordArtikel(){
$pattern ='/lang="de"><repr xml:space="preserve">(.*?)<b>/';
preg_match($pattern, $this->resultXml, $matches);
// return str_replace("der ", "m", $matches[1]);
// return str_replace("die ", "f", $matches[1]);
// return str_replace("das ", "n", $matches[1]);
// return $matches[1];
// return $matches[1];
if($matches[1] == "die "){
return "f";
}
else if($matches[1] == "der "){
return "m";
}
else if ($matches[1] == "das "){
return "n";
}
else
return false;
// switch(strtolower(trim($matches[1]))){
// case "der":
// return "m";
// break;
// case "die":
// return "f";
// break;
// case "das":
// return "n";
// break;
// default:
// return false;
//
// }
}
function getVerbPerfekt(){
$pattern ='/<t n="forms_pl_form">Pl\.:<\/t><\/m><\/i> die[\s\S](.*?)<\/small>/';
preg_match($pattern, $this->resultXml, $matches);
$this->artikel = trim($matches[1]);
}
function getWordPlural(){
$pattern ='/<t n="forms_pl_form">Pl\.:<\/t><\/m><\/i> die[\s\S](.*?)<\/small>/';
preg_match($pattern, $this->resultXml, $matches);
return $this->plural = trim($matches[1]);
}
}