starting works with verbs
Esse commit está contido em:
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/pt-BR/Conjugator.php';
|
||||
|
||||
/**
|
||||
* Test class for Conjugator.
|
||||
* Generated by PHPUnit on 2010-12-17 at 22:16:50.
|
||||
*/
|
||||
class ConjugatorTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @var Conjugator
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->object = new Conjugator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testIsVerb().
|
||||
*/
|
||||
public function testIsVerb() {
|
||||
$this->assertTrue(Conjugator::isVerb('correr'));
|
||||
}
|
||||
public function testIsVerb1() {
|
||||
$this->assertTrue(Conjugator::isVerb('nadar'));
|
||||
}
|
||||
public function testIsVerb2() {
|
||||
$this->assertTrue(Conjugator::isVerb('nadam'));
|
||||
}
|
||||
public function testIsVerb3() {
|
||||
$this->assertTrue(Conjugator::isVerb('ministrarão'));
|
||||
}
|
||||
public function testIsVerb4() {
|
||||
$this->assertTrue(Conjugator::isVerb('apresentar'));
|
||||
}
|
||||
public function testIsVerb5() {
|
||||
$this->assertTrue(Conjugator::isVerb('coloco'));
|
||||
}
|
||||
public function testIsVerb6() {
|
||||
$this->assertTrue(Conjugator::isVerb('lemos'));
|
||||
}
|
||||
public function testIsVerb7() {
|
||||
$this->assertTrue(Conjugator::isVerb('correremos'));
|
||||
}
|
||||
public function testIsVerb8() {
|
||||
$this->assertTrue(Conjugator::isVerb('ministrarão'));
|
||||
}
|
||||
public function testIsVerb9() {
|
||||
$this->assertTrue(Conjugator::isVerb('tomamos'));
|
||||
}
|
||||
public function testIsVerb10() {
|
||||
$this->assertTrue(Conjugator::isVerb('comemos'));
|
||||
}
|
||||
public function testIsVerb11() {
|
||||
$this->assertTrue(Conjugator::isVerb('beberemos'));
|
||||
}
|
||||
public function testIsVerb12() {
|
||||
$this->assertTrue(Conjugator::isVerb('tomo'));
|
||||
}
|
||||
public function testIsVerb13() {
|
||||
$this->assertTrue(Conjugator::isVerb('como'));
|
||||
}
|
||||
public function testIsVerb14() {
|
||||
$this->assertTrue(Conjugator::isVerb('toma'));
|
||||
}
|
||||
public function testIsVerb15() {
|
||||
$this->assertTrue(Conjugator::isVerb('coma'));
|
||||
}
|
||||
public function testIsVerb17() {
|
||||
$this->assertTrue(Conjugator::isVerb('levantaremos'));
|
||||
}
|
||||
|
||||
// testing the toInfinitive method
|
||||
// NOTICE that its goas is about the present/future words...
|
||||
// past is not supported
|
||||
public function testToInfinitive1() {
|
||||
$this->assertEquals('saber', Conjugator::toInfinitive('sei'));
|
||||
}
|
||||
public function testToInfinitive2() {
|
||||
$this->assertEquals('poderá', Conjugator::toInfinitive('poderá'));
|
||||
}
|
||||
public function testToInfinitive3() {
|
||||
$this->assertEquals('amar', Conjugator::toInfinitive('ama'));
|
||||
}
|
||||
public function testToInfinitive4() {
|
||||
$this->assertEquals('correr', Conjugator::toInfinitive('corre'));
|
||||
}
|
||||
public function testToInfinitive5() {
|
||||
$this->assertEquals('correr', Conjugator::toInfinitive('correm'));
|
||||
}
|
||||
public function testToInfinitive6() {
|
||||
$this->assertEquals('lavar', Conjugator::toInfinitive('lavam'));
|
||||
}
|
||||
public function testToInfinitive7() {
|
||||
$this->assertEquals('ministrar', Conjugator::toInfinitive('ministram'));
|
||||
}
|
||||
public function testToInfinitive8() {
|
||||
$this->assertEquals('ter', Conjugator::toInfinitive('terão'));
|
||||
}
|
||||
public function testToInfinitive9() {
|
||||
$this->assertEquals('alimentar', Conjugator::toInfinitive('alimentarão'));
|
||||
}
|
||||
public function testToInfinitive10() {
|
||||
$this->assertEquals('pôr', Conjugator::toInfinitive('põe'));
|
||||
}
|
||||
public function testToInfinitive11() {
|
||||
$this->assertEquals('colocar', Conjugator::toInfinitive('colocarão'));
|
||||
}
|
||||
public function testToInfinitive12() {
|
||||
$this->assertEquals('varrer', Conjugator::toInfinitive('varrer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testLoadVerbs().
|
||||
*/
|
||||
public function testLoadVerbs() {
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/interfaces/inflection.php';
|
||||
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/pt-BR/Inflect.php';
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,5 @@ class InflectTest extends PHPUnit_Framework_TestCase {
|
||||
public function testIsFemale9() {
|
||||
$this->assertTrue(Inflect::isFemale('pequenininha'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1 +0,0 @@
|
||||
Felipe ,felipe,laptop,16.11.2010 18:32,file:///home/felipe/.openoffice.org/3;
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* This class should identify verbs
|
||||
* NOTICE that its goas is about the present/future words...
|
||||
* past is not supported
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class Conjugator {
|
||||
public static $verbs= false;
|
||||
|
||||
static $possibilities= Array(
|
||||
'poder',
|
||||
'podem',
|
||||
'poderá',
|
||||
'poderão',
|
||||
'possivelmente',
|
||||
'provavelmente'
|
||||
);
|
||||
static $flections = array(
|
||||
'/õe$/' => 'ôr',
|
||||
'/rão$/' => 'r',
|
||||
'/a$/' => 'ar',
|
||||
'/e$/' => 'er',
|
||||
'/vo$/' => 'ver',
|
||||
'/i$/' => 'er',
|
||||
'/am$/' => 'ar',
|
||||
'/o$/' => 'ar',
|
||||
'/(.+)o$/' => '$1er',
|
||||
'/(.+)a$/' => '$1er',
|
||||
'/em$/' => 'er',
|
||||
'/remos$/' => 'r',
|
||||
'/emos$/' => 'er',
|
||||
'/mos$/' => 'r'
|
||||
);
|
||||
|
||||
static $exceptions= Array(
|
||||
'sei' => 'saber',
|
||||
'dei' => 'dar',
|
||||
'dou' => 'dar',
|
||||
'deu' => 'dar',
|
||||
'dão' => 'dar',
|
||||
'deram' => 'dar',
|
||||
'dará' => 'dar',
|
||||
'darão' => 'dar',
|
||||
'teem' => 'ter',
|
||||
'terem' => 'ter',
|
||||
'terão' => 'ter',
|
||||
'tiveram' => 'ter',
|
||||
|
||||
);
|
||||
|
||||
public static function isAPosibility($string)
|
||||
{
|
||||
return in_array($string, self::$possibilities);
|
||||
}
|
||||
|
||||
public static function isInfinitive($string)
|
||||
{
|
||||
foreach(self::$flections as $pattern=>$result)
|
||||
{
|
||||
if(preg_match('/'.$result.'$/i', $string))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function toInfinitive($string)
|
||||
{
|
||||
$string= strtolower($string);
|
||||
if(self::isInfinitive($string))
|
||||
return $string;
|
||||
if(isset(self::$exceptions[$string]))
|
||||
{
|
||||
return self::$exceptions[$string];
|
||||
}
|
||||
if(self::isAPosibility($string))
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
|
||||
foreach(self::$flections as $pattern=>$result)
|
||||
{
|
||||
$pattern= ''.$pattern.'i';
|
||||
if(preg_match($pattern, $string))
|
||||
{
|
||||
$tmpWord= preg_replace($pattern, $result, $string);
|
||||
if(self::isInVerbList($tmpWord))
|
||||
return $tmpWord;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isInVerbList($string)
|
||||
{
|
||||
if(!self::$verbs)
|
||||
self::loadVerbs();
|
||||
return isset(self::$verbs[$string]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the received word is a verb or not
|
||||
* @param string $word
|
||||
*/
|
||||
public static function isVerb($word)
|
||||
{
|
||||
$word= self::toInfinitive($word);
|
||||
if($word)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name loadVerbs
|
||||
*/
|
||||
public static function loadVerbs()
|
||||
{
|
||||
$fR= fopen('verbs.list', 'rb');
|
||||
Conjugator::$verbs= Array();
|
||||
while (!feof($fR)){
|
||||
$verb= preg_replace('/\s/', '', fgets($fR, 4096));
|
||||
Conjugator::$verbs[$verb]= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
* let me know :)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This class should inflect words for different idioms
|
||||
* changing its genre and number
|
||||
@@ -115,6 +114,7 @@ class Inflect implements inflection
|
||||
'óculos',
|
||||
'para',
|
||||
'do',
|
||||
'que',
|
||||
'de',
|
||||
'da',
|
||||
'oculos',
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<verbs>
|
||||
<action>
|
||||
<!--
|
||||
These verbs are treated like:
|
||||
substantive action [ammount] substantive
|
||||
|
||||
-->
|
||||
</action>
|
||||
</verbs>
|
||||
Referência em uma Nova Issue
Bloquear um usuário