Commit c6059a97 authored by arnaudbey's avatar arnaudbey
Browse files

misc.

parent 8b828169
/vendor/
......@@ -12,7 +12,7 @@ use JsonSerializable;
* @ORM\Table(name="lexicon.inflection", indexes={
* @Index(name="cleaned_content", columns={"cleaned_content"}),
* })
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\Lexicon\InflectionRepository")
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\InflectionRepository")
*/
class Inflection implements JsonSerializable
{
......
......@@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping\Index;
* @Index(columns={"start"}, flags={"fulltext"}),
* @Index(name="language_id", columns={"language"}),
* })
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\Lexicon\InflectionStartRepository")
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\InflectionStartRepository")
*/
class InflectionStart
{
......
......@@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
* Language.
*
* @ORM\Table(name="lexicon.language")
* @ORM\Entity(repositoryClass="Innova\Bundle\Repository\LanguageRepository")
* @ORM\Entity()
*/
class Language
{
......
......@@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
* Lemma.
*
* @ORM\Table(name="lexicon.lemma")
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\Lexicon\LemmaRepository")
* @ORM\Entity(repositoryClass="Innova\LexiconBundle\Repository\LemmaRepository")
*/
class Lemma
{
......@@ -29,7 +29,7 @@ class Lemma
/**
* @var string
*
* @ORM\Column(name="content", type="string", length=255)
* @ORM\Column(name="content2", type="string", length=255)
*/
private $content;
......
<?php
namespace Innova\LexiconBundle\Repository;
/**
* GameRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class InflectionRepository extends \Doctrine\ORM\EntityRepository
{
public function getExistingWords($words, $language)
{
$em = $this->_em;
$dql = 'SELECT i FROM Innova\LexiconBundle\Entity\Inflection i
WHERE i.language = :language
AND i.cleanedContent IN (:words)';
$query = $em->createQuery($dql);
$query->setParameter('language', $language);
$query->setParameter('words', $words);
return $query->getResult();
}
public function getByLanguageAndContentOrCleaned($language, $content)
{
$em = $this->_em;
$dql = 'SELECT i FROM Innova\LexiconBundle\Entity\Inflection i
WHERE i.language = :language
AND (i.content = :content OR i.cleanedContent = :content)';
$query = $em->createQuery($dql);
$query->setParameter('language', $language)
->setParameter('content', $content)
->setMaxResults(1);
return $query->getOneOrNullResult();
}
public function findByIdRange($range)
{
$em = $this->_em;
$dql = 'SELECT i FROM Innova\LexiconBundle\Entity\Inflection i WHERE i.id >= :lowlimit AND i.id <= :hightlimit';
$query = $em->createQuery($dql);
$query->setParameter('lowlimit', $range)
->setParameter('hightlimit', $range + 20000);
return $query->getResult();
}
public function getEnglishForms()
{
$sql = 'SELECT * FROM dico_en';
$em = $this->_em;
$stmt = $em->getConnection()->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
}
}
<?php
namespace Innova\LexiconBundle\Repository;
/**
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class InflectionStartRepository extends \Doctrine\ORM\EntityRepository
{
public function insert($start, $languageId)
{
$sql = 'INSERT INTO lexicon.inflection_start (start, language) VALUES ("'.$start.'", '.$languageId.')';
$em = $this->_em;
$stmt = $em->getConnection()->prepare($sql);
$stmt->execute();
return 1;
}
public function search($start, $languageId)
{
$sql = 'SELECT 1 FROM lexicon.inflection_start WHERE MATCH(start) AGAINST (\'"'.$start.'"\' IN NATURAL LANGUAGE MODE ) AND language = '.$languageId;
$em = $this->_em;
$stmt = $em->getConnection()->prepare($sql);
$stmt->execute();
if (!empty($stmt->fetchAll())) {
return true;
};
return false;
}
}
<?php
namespace Innova\LexiconBundle\Repository;
class LemmaRepository extends \Doctrine\ORM\EntityRepository
{
public function getByContentAndLanguage($findWord)
{
$em = $this->_em;
$dql = 'SELECT l FROM Innova\LexiconBundle\Entity\Lemma l
WHERE EXISTS(
SELECT i FROM Innova\LexiconBundle\Entity\Inflection i
WHERE i.lemma = l
AND i.cleanedContent = :cleanedContent
AND i.language = :language
)';
$query = $em->createQuery($dql);
$query->setParameter('cleanedContent', $findWord->getInflection());
$query->setParameter('language', $findWord->getConquer()->getLanguage());
return $query->getResult();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment