Added the lexer component;
Added pt-BR human language; Added lexic.xml structure
Esse commit está contido em:
@@ -6,6 +6,9 @@
|
||||
*/
|
||||
class En {
|
||||
private $messages= Array();
|
||||
|
||||
public $name= 'en';
|
||||
|
||||
/**
|
||||
* This method returns the translated message
|
||||
* @method getMessage
|
||||
@@ -34,7 +37,11 @@ class En {
|
||||
$this->messages['invalidOption'] = Mind::message("Invalid option '%s'", '[Fail]', false);
|
||||
$this->messages['projectAlreadyExists'] = Mind::message("There is, already, another project with the same name", '[Fail]', false);
|
||||
$this->messages['projectCreated'] = Mind::message("Created project '%s'", '[Ok]', false);
|
||||
$this->messages['userCreated'] = Mind::message("Created user '%s'", '[Ok]', false);
|
||||
$this->messages['userCreated'] = Mind::message("Created user '%s'", '[Ok]', false);
|
||||
$this->messages['noProject'] = Mind::message("Project '%s' doesn't exist or you have no access", '[Fail]', false);
|
||||
$this->messages['projectOpened'] = Mind::message("Project '%s' opened", '[Ok]', false);
|
||||
$this->messages['currentProjectRequired'] = Mind::message("You must open a project first", '[Fail]', false);
|
||||
$this->messages['currentProjectRequiredTip']= "You can use the command\n use project <projectName>\n";
|
||||
|
||||
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
||||
Invalid HTTP requisition.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* This class represents the structure required to use L10N
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class ptBR {
|
||||
private $messages= Array();
|
||||
|
||||
public $name= 'pt-BR';
|
||||
|
||||
/**
|
||||
* This method returns the translated message
|
||||
* @method getMessage
|
||||
* @param String $msg
|
||||
* @return String Returns the string translated, or fals if the required message does not exist
|
||||
*/
|
||||
public function getMessage($msg)
|
||||
{
|
||||
if(isset($this->messages[$msg]))
|
||||
return $this->messages[$msg];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
header('Content-type: text/html; charset=iso-8859-1');
|
||||
$this->messages['programRequired'] = Mind::message("API: You must send the program name, to execute", '[Fail]', false);
|
||||
$this->messages['loginRequired'] = Mind::message("Auth: Both login and password are required", '[Fail]', false);
|
||||
$this->messages['passwordRequired'] = "I need a password for this user, please: ";
|
||||
$this->messages['autenticated'] = Mind::message("\nMain: %s autenticated", "[OK]", false);//"\n[OK] %s autenticated\n";
|
||||
$this->messages['not_allowed'] = Mind::message("\nMain: You have not autenticated your credentials yet", '[Fail]', false);
|
||||
$this->messages['not_allowed_tip'] = "Try calling the command\n auth < login >\nA password will be required.\n";
|
||||
$this->messages['no_such_file'] = Mind::message("\nMain: No such command '%s'", "[Fail]", false);
|
||||
$this->messages['auth_fail'] = Mind::message("\nAuth: Wrong user or password", "[Fail]", false);
|
||||
$this->messages['bye'] = "Logging out...\n";
|
||||
$this->messages['invalidCreateParams'] = Mind::message("Main: Invalid parameters", "[Fail]", false);
|
||||
$this->messages['invalidOption'] = Mind::message("Invalid option '%s'", '[Fail]', false);
|
||||
$this->messages['projectAlreadyExists'] = Mind::message("There is, already, another project with the same name", '[Fail]', false);
|
||||
$this->messages['projectCreated'] = Mind::message("Created project '%s'", '[Ok]', false);
|
||||
$this->messages['userCreated'] = Mind::message("Created user '%s'", '[Ok]', false);
|
||||
$this->messages['noProject'] = Mind::message("Project '%s' doesn't exist or you have no access", '[Fail]', false);
|
||||
$this->messages['projectOpened'] = Mind::message("Project '%s' opened", '[Ok]', false);
|
||||
$this->messages['currentProjectRequired'] = Mind::message("You must open a project first", '[Fail]', false);
|
||||
$this->messages['currentProjectRequiredTip']= "You can use the command\n use project <projectName>\n";
|
||||
|
||||
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
||||
Invalid HTTP requisition.
|
||||
You *must* send some POST data acoording your request, and also a variable "program" by post, with the name of the program you want to run.
|
||||
MESSAGE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -12,11 +12,14 @@
|
||||
public $about= null;
|
||||
public $defaults= null;
|
||||
public $conf= null;
|
||||
public static $currentProject= null;
|
||||
public static $projectsDir= '';
|
||||
public static $pluginList= Array();
|
||||
private static $l10n= null;
|
||||
public static $l10n= null;
|
||||
public static $triggers= Array();
|
||||
public static $modelsDir= "";
|
||||
public static $lexer;
|
||||
public static $langPath= "";
|
||||
|
||||
/**
|
||||
* This method returns or outputs messages using the L10N library
|
||||
@@ -86,8 +89,9 @@
|
||||
$this->about= parse_ini_file($path.'/mind3rd/env/about.ini');
|
||||
$this->defaults= parse_ini_file($path.'/mind3rd/env/defaults.ini');
|
||||
$this->conf= parse_ini_file($path.'/mind3rd/env/mind.ini');
|
||||
include($path.'/mind3rd/API/L10N/'.$this->defaults['defaul_human_language'].'.php');
|
||||
Mind::$l10n= new $this->defaults['defaul_human_language']();
|
||||
include($path.'/mind3rd/API/L10N/'.$this->defaults['default_human_language'].'.php');
|
||||
Mind::$l10n= new $this->defaults['default_human_language']();
|
||||
Mind::$langPath= $path.'/mind3rd/API/languages/';
|
||||
}
|
||||
/**
|
||||
* function taken from: http://www.dasprids.de/blog/2008/08/22/getting-a-password-hidden-from-stdin-with-php-cli
|
||||
@@ -221,4 +225,52 @@
|
||||
Mind::$pluginList[$plugin->trigger][$plugin->event][]= $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
static function hasProject($project)
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
$projectfile= Mind::$projectsDir.$project;
|
||||
$noAccess= true;
|
||||
|
||||
$db= new MindDB();
|
||||
$hasProject= "SELECT pk_project,
|
||||
project.name as name
|
||||
from project_user,
|
||||
project
|
||||
where fk_user= ".$_SESSION['pk_user']."
|
||||
and project.name = '".$project."'
|
||||
and fk_project = pk_project
|
||||
";
|
||||
$data= $db->query($hasProject);
|
||||
if(sizeof($data)>0)
|
||||
foreach($data as $row)
|
||||
{
|
||||
$noAccess= false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!file_exists($projectfile) || $noAccess)
|
||||
{
|
||||
Mind::write('noProject', true, $project);
|
||||
return false;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function openProject($p)
|
||||
{
|
||||
$_SESSION['currentProject']= $p['pk_project'];
|
||||
$_SESSION['currentProjectName']= $p['name'];
|
||||
$_SESSION['currentProjectDir']= Mind::$projectsDir.$p['name'];
|
||||
$p['path']= Mind::$projectsDir.$p['name'];
|
||||
$p['sources']= Mind::$projectsDir.$p['name'].'/sources';
|
||||
Mind::$currentProject= $p;
|
||||
if(isset($_SESSION['currentProject']))
|
||||
{
|
||||
if($_SESSION['currentProject'] == $p['pk_project'])
|
||||
return true;
|
||||
}
|
||||
Mind::write('projectOpened', true, $p['name']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Lexer
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class Lexer
|
||||
{
|
||||
private $validChars;
|
||||
private $replacements;
|
||||
public $lang= 'en';
|
||||
private $content= "";
|
||||
private $tokens= Array();
|
||||
|
||||
/**
|
||||
* Thanks to saeedco (no more information found about him!)
|
||||
* Source: http://br2.php.net/manual/en/function.str-split.php#83331
|
||||
* Idioms it is supposed to work properly
|
||||
* Chinese
|
||||
* Japanese
|
||||
* Arabic
|
||||
* Turkish
|
||||
* Urdu
|
||||
* Russian
|
||||
* Persian
|
||||
* Portuguese
|
||||
*
|
||||
* @param String $str
|
||||
* @return array
|
||||
*/
|
||||
private function str_split_utf8($str) {
|
||||
// place each character of the string into and array
|
||||
$split=1;
|
||||
$array = array();
|
||||
for ( $i=0; $i < strlen( $str ); ){
|
||||
$value = ord($str[$i]);
|
||||
if($value > 127){
|
||||
if($value >= 192 && $value <= 223)
|
||||
$split=2;
|
||||
elseif($value >= 224 && $value <= 239)
|
||||
$split=3;
|
||||
elseif($value >= 240 && $value <= 247)
|
||||
$split=4;
|
||||
}else{
|
||||
$split=1;
|
||||
}
|
||||
$key = NULL;
|
||||
for ( $j = 0; $j < $split; $j++, $i++ ) {
|
||||
$key .= $str[$i];
|
||||
}
|
||||
array_push( $array, $key );
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function isValidChar($letter)
|
||||
{
|
||||
$letter= ($letter);
|
||||
for($k=0; $k<strlen($this->validChars); $k++)
|
||||
{
|
||||
if($this->validChars[$k] == $letter
|
||||
||
|
||||
ord($this->validChars[$k]) == ord($letter)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sweep($content)
|
||||
{
|
||||
$this->content= trim(str_replace("\n", ' ', $content));
|
||||
$this->originalContent= $this->content;
|
||||
$this->content= $this->str_split_utf8($this->content);
|
||||
// untill here, it's all fine
|
||||
|
||||
// the fixed content;
|
||||
$fixed= "";
|
||||
// for each charactere on the content
|
||||
for($i=0, $j=sizeof($this->content); $i<$j; $i++)
|
||||
{
|
||||
$letter= $this->content[$i];
|
||||
if($this->isValidChar($letter))
|
||||
$fixed.= $letter;
|
||||
}
|
||||
|
||||
foreach($this->tokens as $char=>$token)
|
||||
{
|
||||
$fixed= str_replace($char, $token, $fixed);
|
||||
}
|
||||
$fixed= preg_replace("/\n/", $this->tokens[' '], $fixed);
|
||||
$fixed= explode($this->tokens[' '], $fixed);
|
||||
print_r($fixed);
|
||||
}
|
||||
|
||||
public function translateChars($str)
|
||||
{
|
||||
$from = $this->replacements[0];
|
||||
$to = $this->replacements[1];
|
||||
return strtr($str, $from, $to);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
$this->lang= Mind::$l10n->name;
|
||||
$xml= simplexml_load_file(Mind::$langPath.$this->lang.'/lexics.xml');
|
||||
$this->validChars= (string)$xml->validchars->lower;
|
||||
$this->validChars.= (string)$xml->validchars->upper;
|
||||
$this->validChars.= (string)$xml->validchars->special;
|
||||
$this->validChars.= (string)$xml->validchars->numbers;
|
||||
$this->validChars.= (string)$xml->validchars->symbols;
|
||||
$this->validChars.= " ";
|
||||
|
||||
$this->replacements= Array();
|
||||
$this->replacements[0]= (string)$xml->replacements->from;
|
||||
$this->replacements[1]= (string)$xml->replacements->to;
|
||||
|
||||
$this->tokens[' ']= chr('176');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(quiz)$/i' => "$1zes",
|
||||
'/^(ox)$/i' => "$1en",
|
||||
'/([m|l])ouse$/i' => "$1ice",
|
||||
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
||||
'/(x|ch|ss|sh)$/i' => "$1es",
|
||||
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
||||
'/(hive)$/i' => "$1s",
|
||||
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
||||
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
||||
'/sis$/i' => "ses",
|
||||
'/([ti])um$/i' => "$1a",
|
||||
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
||||
'/(bu)s$/i' => "$1ses",
|
||||
'/(alias)$/i' => "$1es",
|
||||
'/(octop)us$/i' => "$1i",
|
||||
'/(ax|test)is$/i' => "$1es",
|
||||
'/(us)$/i' => "$1es",
|
||||
'/s$/i' => "s"
|
||||
// '/$/' => "s"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(quiz)zes$/i' => "$1",
|
||||
'/(matr)ices$/i' => "$1ix",
|
||||
'/(vert|ind)ices$/i' => "$1ex",
|
||||
'/^(ox)en$/i' => "$1",
|
||||
'/(alias)es$/i' => "$1",
|
||||
'/(octop|vir)i$/i' => "$1us",
|
||||
'/(cris|ax|test)es$/i' => "$1is",
|
||||
'/(shoe)s$/i' => "$1",
|
||||
'/(o)es$/i' => "$1",
|
||||
'/(bus)es$/i' => "$1",
|
||||
'/([m|l])ice$/i' => "$1ouse",
|
||||
'/(x|ch|ss|sh)es$/i' => "$1",
|
||||
'/(m)ovies$/i' => "$1ovie",
|
||||
'/(s)eries$/i' => "$1eries",
|
||||
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
||||
'/([lr])ves$/i' => "$1f",
|
||||
'/(tive)s$/i' => "$1",
|
||||
'/(hive)s$/i' => "$1",
|
||||
'/(li|wi|kni)ves$/i' => "$1fe",
|
||||
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
||||
'/(^analy)ses$/i' => "$1sis",
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
||||
'/([ti])a$/i' => "$1um",
|
||||
'/(n)ews$/i' => "$1ews",
|
||||
'/(h|bl)ouses$/i' => "$1ouse",
|
||||
'/(corpse)s$/i' => "$1",
|
||||
'/(us)es$/i' => "$1",
|
||||
'/s$/i' => ""
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'foot' => 'feet',
|
||||
'goose' => 'geese',
|
||||
'sex' => 'sexes',
|
||||
'child' => 'children',
|
||||
'man' => 'men',
|
||||
'tooth' => 'teeth',
|
||||
'person' => 'people'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'sheep',
|
||||
'fish',
|
||||
'deer',
|
||||
'series',
|
||||
'species',
|
||||
'money',
|
||||
'rice',
|
||||
'information',
|
||||
'equipment'
|
||||
);
|
||||
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function pluralize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function singularize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function pluralize_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::pluralize($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(quiz)$/i' => "$1zes",
|
||||
'/^(ox)$/i' => "$1en",
|
||||
'/([m|l])ouse$/i' => "$1ice",
|
||||
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
||||
'/(x|ch|ss|sh)$/i' => "$1es",
|
||||
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
||||
'/(hive)$/i' => "$1s",
|
||||
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
||||
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
||||
'/sis$/i' => "ses",
|
||||
'/([ti])um$/i' => "$1a",
|
||||
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
||||
'/(bu)s$/i' => "$1ses",
|
||||
'/(alias)$/i' => "$1es",
|
||||
'/(octop)us$/i' => "$1i",
|
||||
'/(ax|test)is$/i' => "$1es",
|
||||
'/(us)$/i' => "$1es",
|
||||
'/s$/i' => "s"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(quiz)zes$/i' => "$1",
|
||||
'/(matr)ices$/i' => "$1ix",
|
||||
'/(vert|ind)ices$/i' => "$1ex",
|
||||
'/^(ox)en$/i' => "$1",
|
||||
'/(alias)es$/i' => "$1",
|
||||
'/(octop|vir)i$/i' => "$1us",
|
||||
'/(cris|ax|test)es$/i' => "$1is",
|
||||
'/(shoe)s$/i' => "$1",
|
||||
'/(o)es$/i' => "$1",
|
||||
'/(bus)es$/i' => "$1",
|
||||
'/([m|l])ice$/i' => "$1ouse",
|
||||
'/(x|ch|ss|sh)es$/i' => "$1",
|
||||
'/(m)ovies$/i' => "$1ovie",
|
||||
'/(s)eries$/i' => "$1eries",
|
||||
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
||||
'/([lr])ves$/i' => "$1f",
|
||||
'/(tive)s$/i' => "$1",
|
||||
'/(hive)s$/i' => "$1",
|
||||
'/(li|wi|kni)ves$/i' => "$1fe",
|
||||
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
||||
'/(^analy)ses$/i' => "$1sis",
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
||||
'/([ti])a$/i' => "$1um",
|
||||
'/(n)ews$/i' => "$1ews",
|
||||
'/(h|bl)ouses$/i' => "$1ouse",
|
||||
'/(corpse)s$/i' => "$1",
|
||||
'/(us)es$/i' => "$1",
|
||||
'/s$/i' => ""
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'foot' => 'feet',
|
||||
'goose' => 'geese',
|
||||
'sex' => 'sexes',
|
||||
'child' => 'children',
|
||||
'man' => 'men',
|
||||
'tooth' => 'teeth',
|
||||
'person' => 'people'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'sheep',
|
||||
'fish',
|
||||
'deer',
|
||||
'series',
|
||||
'species',
|
||||
'money',
|
||||
'rice',
|
||||
'information',
|
||||
'equipment'
|
||||
);
|
||||
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function pluralize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function singularize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function pluralize_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::pluralize($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(quiz)$/i' => "$1zes",
|
||||
'/^(ox)$/i' => "$1en",
|
||||
'/([m|l])ouse$/i' => "$1ice",
|
||||
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
||||
'/(x|ch|ss|sh)$/i' => "$1es",
|
||||
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
||||
'/(hive)$/i' => "$1s",
|
||||
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
||||
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
||||
'/sis$/i' => "ses",
|
||||
'/([ti])um$/i' => "$1a",
|
||||
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
||||
'/(bu)s$/i' => "$1ses",
|
||||
'/(alias)$/i' => "$1es",
|
||||
'/(octop)us$/i' => "$1i",
|
||||
'/(ax|test)is$/i' => "$1es",
|
||||
'/(us)$/i' => "$1es",
|
||||
'/s$/i' => "s"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(quiz)zes$/i' => "$1",
|
||||
'/(matr)ices$/i' => "$1ix",
|
||||
'/(vert|ind)ices$/i' => "$1ex",
|
||||
'/^(ox)en$/i' => "$1",
|
||||
'/(alias)es$/i' => "$1",
|
||||
'/(octop|vir)i$/i' => "$1us",
|
||||
'/(cris|ax|test)es$/i' => "$1is",
|
||||
'/(shoe)s$/i' => "$1",
|
||||
'/(o)es$/i' => "$1",
|
||||
'/(bus)es$/i' => "$1",
|
||||
'/([m|l])ice$/i' => "$1ouse",
|
||||
'/(x|ch|ss|sh)es$/i' => "$1",
|
||||
'/(m)ovies$/i' => "$1ovie",
|
||||
'/(s)eries$/i' => "$1eries",
|
||||
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
||||
'/([lr])ves$/i' => "$1f",
|
||||
'/(tive)s$/i' => "$1",
|
||||
'/(hive)s$/i' => "$1",
|
||||
'/(li|wi|kni)ves$/i' => "$1fe",
|
||||
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
||||
'/(^analy)ses$/i' => "$1sis",
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
||||
'/([ti])a$/i' => "$1um",
|
||||
'/(n)ews$/i' => "$1ews",
|
||||
'/(h|bl)ouses$/i' => "$1ouse",
|
||||
'/(corpse)s$/i' => "$1",
|
||||
'/(us)es$/i' => "$1",
|
||||
'/s$/i' => ""
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'foot' => 'feet',
|
||||
'goose' => 'geese',
|
||||
'sex' => 'sexes',
|
||||
'child' => 'children',
|
||||
'man' => 'men',
|
||||
'tooth' => 'teeth',
|
||||
'person' => 'people'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'sheep',
|
||||
'fish',
|
||||
'deer',
|
||||
'series',
|
||||
'species',
|
||||
'money',
|
||||
'rice',
|
||||
'information',
|
||||
'equipment'
|
||||
);
|
||||
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function pluralize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function singularize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function pluralize_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::pluralize($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
$lang= 'pt-BR';
|
||||
if($lang=='en')
|
||||
{
|
||||
include('en/Inflect.php');
|
||||
echo Inflect::toPlural("truck");
|
||||
echo "<br/>";
|
||||
echo Inflect::toPlural("lady");
|
||||
echo "<br/>";
|
||||
echo Inflect::toPlural("shit");
|
||||
echo "<br/>";
|
||||
echo Inflect::toPlural("program");
|
||||
echo "<br/>";
|
||||
echo (Inflect::is_singular("fish")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("rice")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("foot")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("feet")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("truck")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("trucks")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("house")? 1:0)."<br/>";
|
||||
echo (Inflect::is_singular("houses")? 1:0)."<br/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
include('pt-BR/Inflect.php');
|
||||
echo Inflect::toSingular('gatos').' -> '.Inflect::toPlural("gato")."<br/>";
|
||||
echo Inflect::toSingular('itens').' -> '.Inflect::toPlural("item")."<br/>";
|
||||
echo Inflect::toSingular('álbuns').' -> '.Inflect::toPlural("álbum")."<br/>";
|
||||
echo Inflect::toSingular('aldeões').' -> '.Inflect::toPlural("aldeão")."<br/>";
|
||||
echo Inflect::toSingular('alemães').' -> '.Inflect::toPlural("alemão")."<br/>";
|
||||
echo Inflect::toSingular('irmãos').' -> '.Inflect::toPlural("irmão")."<br/>";
|
||||
echo Inflect::toSingular('irmãs').' -> '.Inflect::toPlural("irmã")."<br/>";
|
||||
echo Inflect::toSingular('colheres').' -> '.Inflect::toPlural("colher")."<br/>";
|
||||
echo Inflect::toSingular('albatroses').' -> '.Inflect::toPlural("albatroz")."<br/>";
|
||||
echo Inflect::toSingular('fregueses').' -> '.Inflect::toPlural("fregues")."<br/>";
|
||||
echo Inflect::toSingular('freguesas').' -> '.Inflect::toPlural("freguesa")."<br/>";
|
||||
echo Inflect::toSingular('clímax').' -> '.Inflect::toPlural("clímax")."<br/>";
|
||||
echo Inflect::toSingular('varais').' -> '.Inflect::toPlural("varal")."<br/>";
|
||||
echo Inflect::toSingular('túneis').' -> '.Inflect::toPlural("túnel")."<br/>";
|
||||
echo Inflect::toSingular('barris').' -> '.Inflect::toPlural("barril")."<br/>";
|
||||
echo Inflect::toSingular('fásseis').' -> '.Inflect::toPlural("fóssil")."<br/>";
|
||||
echo Inflect::toSingular('projéteis').' -> '.Inflect::toPlural("projétil")."<br/>";
|
||||
echo Inflect::toSingular('bares').' -> '.Inflect::toPlural("bar")."<br/>";
|
||||
echo "<hr/>";
|
||||
echo Inflect::toFemale('gato').' -> '.Inflect::toMale("gata")."<br/>";
|
||||
echo Inflect::toFemale('leão').' -> '.Inflect::toMale("leoa")."<br/>";
|
||||
echo Inflect::toFemale('chorão').' -> '.Inflect::toMale("chorona")."<br/>";
|
||||
echo Inflect::toFemale('mijão').' -> '.Inflect::toMale("mijona")."<br/>";
|
||||
echo Inflect::toFemale('doutor').' -> '.Inflect::toMale("doutora")."<br/>";
|
||||
echo Inflect::toFemale('mestre').' -> '.Inflect::toMale("mestra")."<br/>";
|
||||
echo Inflect::toFemale('réu').' -> '.Inflect::toMale("ré")."<br/>";
|
||||
echo "<hr/>";
|
||||
echo 'irmão -> '.(Inflect::isFemale('irmão')?1:0)."<br/>";
|
||||
echo 'irmã -> '.(Inflect::isFemale('irmã')?1:0)."<br/>";
|
||||
echo 'ré -> '.(Inflect::isFemale('ré')?1:0)."<br/>";
|
||||
echo 'réu -> '.(Inflect::isFemale('réu')?1:0)."<br/>";
|
||||
echo 'carro -> '.(Inflect::isFemale('carro')?1:0)."<br/>";
|
||||
echo 'casa -> '.(Inflect::isFemale('casa')?1:0)."<br/>";
|
||||
echo 'mulher -> '.(Inflect::isFemale('mulher')?1:0)."<br/>";
|
||||
echo 'homem -> '.(Inflect::isFemale('homem')?1:0)."<br/>";
|
||||
echo 'carro -> '.(Inflect::isFemale('carro')?1:0)."<br/>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-toPlural (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
// translation to Brazilian portugues pt-BR
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(.+[aeiou])ão$/' => "$1ões",
|
||||
'/(.+[aeiou][a-z])ão$/' => "$1ães",
|
||||
'/(.+[rs])$/' => "$1es",
|
||||
'/(.+[aeou])l$/' => "$1is",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})il$/' => "$1eis",
|
||||
'/(.+i)l$/' => "$1s",
|
||||
'/(.+)z$/' => "$1ses",
|
||||
'/(.+)m$/' => "$1ns",
|
||||
'/([aeiou])$/' => "$1s",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(.+[aeiou])ões$/' => "$1ão",
|
||||
'/(.+[aeiou][a-z])ães$/' => "$1ão",
|
||||
'/(.+r)es$/' => "$1",
|
||||
'/(.+)ses$/' => "$1z",
|
||||
'/(.+s)es$/' => "$1",
|
||||
'/(.+[aeou])is$/' => "$1l",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})eis$/' => "$1il",
|
||||
'/(.+i)s$/' => "$1l",
|
||||
'/(.+)ns$/' => "$1m",
|
||||
'/([aeiouãõéíóúâôê])s$/' => "$1",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $female= Array(
|
||||
'/([aeiou][a-z]{1,2})ão$/' => "$1ona",
|
||||
'/([aeiou])ão$/' => "$1oa",
|
||||
'/o$/' => "a",
|
||||
'/e$/' => "a",
|
||||
'/or$/' => "ora",
|
||||
'/om$/' => "oa",
|
||||
'/m$/' => "m"
|
||||
);
|
||||
|
||||
static $male= Array(
|
||||
'/([aeiou][a-z]{1,2})ona$/' => "$1ão",
|
||||
'/([aeiou])oa$/' => "$1ão",
|
||||
'/ora$/' => "or",
|
||||
'/([aeiou][a-z]{1,2})a$/' => "$1o",
|
||||
'/a$/' => "e"
|
||||
);
|
||||
|
||||
static $genreSpecific= Array(
|
||||
'cônsul' => 'consulesa',
|
||||
'visconde' => 'viscondessa',
|
||||
'homem' => 'mulher',
|
||||
'poeta' => 'poetisa',
|
||||
'bode' => 'cabra',
|
||||
'boi' => 'vaca',
|
||||
'burro' => 'besta',
|
||||
'cão' => 'cadela',
|
||||
'carneiro' => 'ovelha',
|
||||
'cavaleiro' => 'amazona',
|
||||
'frade' => 'freira',
|
||||
'veado' => 'cerva',
|
||||
'zangão' => 'abelha',
|
||||
'ateu' => 'atéia',
|
||||
'ator' => 'atriz',
|
||||
'avô' => 'avó',
|
||||
'embaixador' => 'embaixatriz',
|
||||
'judeu' => 'judia',
|
||||
'maestro' => 'maestrina',
|
||||
'marajá' => 'marani',
|
||||
'réu' => 'ré',
|
||||
'sultão' => 'sultana'
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'freguês'=> 'fregueses'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'óculos',
|
||||
'oculos',
|
||||
'átlas',
|
||||
'atlas',
|
||||
'binoculos',
|
||||
'calças',
|
||||
'lápis',
|
||||
'lapis',
|
||||
'vírus',
|
||||
'virus'
|
||||
);
|
||||
|
||||
/**
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @method is_singular
|
||||
* @return boolean
|
||||
* @param String $string
|
||||
*/
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function toPlural( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toSingular( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toPlural_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::toPlural($string);
|
||||
}
|
||||
|
||||
public static function toFemale($string)
|
||||
{
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return self::$genreSpecific[$string];
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toMale($string)
|
||||
{
|
||||
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
foreach ( self::$genreSpecific as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
if(preg_match($pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$male as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function isFemale($string)
|
||||
{
|
||||
// it is a female from the specific list
|
||||
if(in_array($string, self::$genreSpecific))
|
||||
return true;
|
||||
// if it is a male kay, in the specific list
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return false;
|
||||
// ok, now let's see if it is a female by touching it!
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match($pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-toPlural (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
// translation to Brazilian portugues pt-BR
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(.+[aeiou])ão$/' => "$1ões",
|
||||
'/(.+[aeiou][a-z])ão$/' => "$1ães",
|
||||
'/(.+[rs])$/' => "$1es",
|
||||
'/(.+[aeou])l$/' => "$1is",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})il$/' => "$1eis",
|
||||
'/(.+i)l$/' => "$1s",
|
||||
'/(.+)z$/' => "$1ses",
|
||||
'/(.+)m$/' => "$1ns",
|
||||
'/([aeiou])$/' => "$1s",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(.+[aeiou])ões$/' => "$1ão",
|
||||
'/(.+[aeiou][a-z])ães$/' => "$1ão",
|
||||
'/(.+r)es$/' => "$1",
|
||||
'/(.+)ses$/' => "$1z",
|
||||
'/(.+s)es$/' => "$1",
|
||||
'/(.+[aeou])is$/' => "$1l",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})eis$/' => "$1il",
|
||||
'/(.+i)s$/' => "$1l",
|
||||
'/(.+)ns$/' => "$1m",
|
||||
'/([aeiouãõéíóúâôê])s$/' => "$1",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $female= Array(
|
||||
'/([aeiou][a-z]{1,2})ão$/' => "$1ona",
|
||||
'/([aeiou])ão$/' => "$1oa",
|
||||
'/o$/' => "a",
|
||||
'/e$/' => "a",
|
||||
'/or$/' => "ora",
|
||||
'/om$/' => "oa",
|
||||
'/m$/' => "m",
|
||||
);
|
||||
|
||||
static $male= Array(
|
||||
'/([aeiou][a-z]{1,2})ona$/' => "$1ão",
|
||||
'/([aeiou])oa$/' => "$1ão",
|
||||
'/ora$/' => "or",
|
||||
'/([aeiou][a-z]{1,2})a$/' => "$1o",
|
||||
'/a$/' => "e"
|
||||
);
|
||||
|
||||
static $genreSpecific= Array(
|
||||
'cônsul' => 'consulesa',
|
||||
'visconde' => 'viscondessa',
|
||||
'homem' => 'mulher'
|
||||
'poeta' => 'poetisa',
|
||||
'bode' => 'cabra',
|
||||
'boi' => 'vaca',
|
||||
'burro' => 'besta',
|
||||
'cão' => 'cadela',
|
||||
'carneiro' => 'ovelha',
|
||||
'cavaleiro' => 'amazona',
|
||||
'frade' => 'freira',
|
||||
'veado' => 'cerva',
|
||||
'zangão' => 'abelha',
|
||||
'ateu' => 'atéia',
|
||||
'ator' => 'atriz',
|
||||
'avô' => 'avó',
|
||||
'embaixador' => 'embaixatriz',
|
||||
'judeu' => 'judia',
|
||||
'maestro' => 'maestrina',
|
||||
'marajá' => 'marani',
|
||||
'réu' => 'ré',
|
||||
'sultão' => 'sultana'
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'freguês'=> 'fregueses'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'óculos',
|
||||
'oculos',
|
||||
'átlas',
|
||||
'atlas',
|
||||
'binoculos',
|
||||
'calças',
|
||||
'lápis',
|
||||
'lapis',
|
||||
'vírus',
|
||||
'virus'
|
||||
);
|
||||
|
||||
/**
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @method is_singular
|
||||
* @return boolean
|
||||
* @param String $string
|
||||
*/
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function toPlural( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toSingular( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toPlural_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::toPlural($string);
|
||||
}
|
||||
|
||||
public static function toFemale($string)
|
||||
{
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return self::$genreSpecific[$string];
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toMale($string)
|
||||
{
|
||||
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
foreach ( self::$genreSpecific as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
if(preg_match($pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$male as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function isFemale($string)
|
||||
{
|
||||
// it is a female from the specific list
|
||||
if(in_array($string, self::$genreSpecific))
|
||||
return true;
|
||||
// if it is a male kay, in the specific list
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return false;
|
||||
// ok, now let's see if it is a female by touching it!
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match($pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* the program you want to execute, and the parameters you want
|
||||
* to pass
|
||||
*/
|
||||
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
if(!isset($_REQ))
|
||||
{
|
||||
Mind::write("http_invalid_requisition");
|
||||
@@ -20,6 +22,14 @@
|
||||
$_REQ['data'][$k]= preg_replace("/['\"\\\.\/]/", '', $value);
|
||||
}
|
||||
|
||||
if(isset($_SESSION['currentProject']))
|
||||
{
|
||||
$p= Array();
|
||||
$p['pk_project']= $_SESSION['currentProject'];
|
||||
$p['name']= $_SESSION['currentProjectName'];
|
||||
Mind::openProject($p);
|
||||
}
|
||||
|
||||
if(isset($app))
|
||||
{
|
||||
if(!isset($_REQ['data']) || !isset($_REQ['data']['program']))
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(quiz)$/i' => "$1zes",
|
||||
'/^(ox)$/i' => "$1en",
|
||||
'/([m|l])ouse$/i' => "$1ice",
|
||||
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
||||
'/(x|ch|ss|sh)$/i' => "$1es",
|
||||
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
||||
'/(hive)$/i' => "$1s",
|
||||
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
||||
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
||||
'/sis$/i' => "ses",
|
||||
'/([ti])um$/i' => "$1a",
|
||||
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
||||
'/(bu)s$/i' => "$1ses",
|
||||
'/(alias)$/i' => "$1es",
|
||||
'/(octop)us$/i' => "$1i",
|
||||
'/(ax|test)is$/i' => "$1es",
|
||||
'/(us)$/i' => "$1es",
|
||||
'/s$/i' => "s"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(quiz)zes$/i' => "$1",
|
||||
'/(matr)ices$/i' => "$1ix",
|
||||
'/(vert|ind)ices$/i' => "$1ex",
|
||||
'/^(ox)en$/i' => "$1",
|
||||
'/(alias)es$/i' => "$1",
|
||||
'/(octop|vir)i$/i' => "$1us",
|
||||
'/(cris|ax|test)es$/i' => "$1is",
|
||||
'/(shoe)s$/i' => "$1",
|
||||
'/(o)es$/i' => "$1",
|
||||
'/(bus)es$/i' => "$1",
|
||||
'/([m|l])ice$/i' => "$1ouse",
|
||||
'/(x|ch|ss|sh)es$/i' => "$1",
|
||||
'/(m)ovies$/i' => "$1ovie",
|
||||
'/(s)eries$/i' => "$1eries",
|
||||
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
||||
'/([lr])ves$/i' => "$1f",
|
||||
'/(tive)s$/i' => "$1",
|
||||
'/(hive)s$/i' => "$1",
|
||||
'/(li|wi|kni)ves$/i' => "$1fe",
|
||||
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
||||
'/(^analy)ses$/i' => "$1sis",
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
||||
'/([ti])a$/i' => "$1um",
|
||||
'/(n)ews$/i' => "$1ews",
|
||||
'/(h|bl)ouses$/i' => "$1ouse",
|
||||
'/(corpse)s$/i' => "$1",
|
||||
'/(us)es$/i' => "$1",
|
||||
'/s$/i' => ""
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'foot' => 'feet',
|
||||
'goose' => 'geese',
|
||||
'sex' => 'sexes',
|
||||
'child' => 'children',
|
||||
'man' => 'men',
|
||||
'tooth' => 'teeth',
|
||||
'person' => 'people'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'sheep',
|
||||
'fish',
|
||||
'deer',
|
||||
'series',
|
||||
'species',
|
||||
'money',
|
||||
'rice',
|
||||
'information',
|
||||
'equipment'
|
||||
);
|
||||
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function pluralize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function singularize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function pluralize_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::pluralize($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(quiz)$/i' => "$1zes",
|
||||
'/^(ox)$/i' => "$1en",
|
||||
'/([m|l])ouse$/i' => "$1ice",
|
||||
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
||||
'/(x|ch|ss|sh)$/i' => "$1es",
|
||||
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
||||
'/(hive)$/i' => "$1s",
|
||||
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
||||
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
||||
'/sis$/i' => "ses",
|
||||
'/([ti])um$/i' => "$1a",
|
||||
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
||||
'/(bu)s$/i' => "$1ses",
|
||||
'/(alias)$/i' => "$1es",
|
||||
'/(octop)us$/i' => "$1i",
|
||||
'/(ax|test)is$/i' => "$1es",
|
||||
'/(us)$/i' => "$1es",
|
||||
'/s$/i' => "s"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(quiz)zes$/i' => "$1",
|
||||
'/(matr)ices$/i' => "$1ix",
|
||||
'/(vert|ind)ices$/i' => "$1ex",
|
||||
'/^(ox)en$/i' => "$1",
|
||||
'/(alias)es$/i' => "$1",
|
||||
'/(octop|vir)i$/i' => "$1us",
|
||||
'/(cris|ax|test)es$/i' => "$1is",
|
||||
'/(shoe)s$/i' => "$1",
|
||||
'/(o)es$/i' => "$1",
|
||||
'/(bus)es$/i' => "$1",
|
||||
'/([m|l])ice$/i' => "$1ouse",
|
||||
'/(x|ch|ss|sh)es$/i' => "$1",
|
||||
'/(m)ovies$/i' => "$1ovie",
|
||||
'/(s)eries$/i' => "$1eries",
|
||||
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
||||
'/([lr])ves$/i' => "$1f",
|
||||
'/(tive)s$/i' => "$1",
|
||||
'/(hive)s$/i' => "$1",
|
||||
'/(li|wi|kni)ves$/i' => "$1fe",
|
||||
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
||||
'/(^analy)ses$/i' => "$1sis",
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
||||
'/([ti])a$/i' => "$1um",
|
||||
'/(n)ews$/i' => "$1ews",
|
||||
'/(h|bl)ouses$/i' => "$1ouse",
|
||||
'/(corpse)s$/i' => "$1",
|
||||
'/(us)es$/i' => "$1",
|
||||
'/s$/i' => ""
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'foot' => 'feet',
|
||||
'goose' => 'geese',
|
||||
'sex' => 'sexes',
|
||||
'child' => 'children',
|
||||
'man' => 'men',
|
||||
'tooth' => 'teeth',
|
||||
'person' => 'people'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'sheep',
|
||||
'fish',
|
||||
'deer',
|
||||
'series',
|
||||
'species',
|
||||
'money',
|
||||
'rice',
|
||||
'information',
|
||||
'equipment'
|
||||
);
|
||||
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function pluralize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function singularize( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function pluralize_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::pluralize($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-toPlural (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
// translation to Brazilian portugues pt-BR
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(.+[aeiou])ão$/' => "$1ões",
|
||||
'/(.+[aeiou][a-z])ão$/' => "$1ães",
|
||||
'/(.+[rs])$/' => "$1es",
|
||||
'/(.+[aeou])l$/' => "$1is",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})il$/' => "$1eis",
|
||||
'/(.+i)l$/' => "$1s",
|
||||
'/(.+)z$/' => "$1ses",
|
||||
'/(.+)m$/' => "$1ns",
|
||||
'/([aeiou])$/' => "$1s",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(.+[aeiou])ões$/' => "$1ão",
|
||||
'/(.+[aeiou][a-z])ães$/' => "$1ão",
|
||||
'/(.+r)es$/' => "$1",
|
||||
'/(.+)ses$/' => "$1z",
|
||||
'/(.+s)es$/' => "$1",
|
||||
'/(.+[aeou])is$/' => "$1l",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})eis$/' => "$1il",
|
||||
'/(.+i)s$/' => "$1l",
|
||||
'/(.+)ns$/' => "$1m",
|
||||
'/([aeiouãõéíóúâôê])s$/' => "$1",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $female= Array(
|
||||
'/([aeiou][a-z]{1,2})ão$/' => "$1ona",
|
||||
'/([aeiou])ão$/' => "$1oa",
|
||||
'/o$/' => "a",
|
||||
'/e$/' => "a",
|
||||
'/or$/' => "ora",
|
||||
'/om$/' => "oa",
|
||||
'/m$/' => "m"
|
||||
);
|
||||
|
||||
static $male= Array(
|
||||
'/([aeiou][a-z]{1,2})ona$/' => "$1ão",
|
||||
'/([aeiou])oa$/' => "$1ão",
|
||||
'/ora$/' => "or",
|
||||
'/([aeiou][a-z]{1,2})a$/' => "$1o",
|
||||
'/a$/' => "e"
|
||||
);
|
||||
|
||||
static $genreSpecific= Array(
|
||||
'cônsul' => 'consulesa',
|
||||
'visconde' => 'viscondessa',
|
||||
'homem' => 'mulher',
|
||||
'poeta' => 'poetisa',
|
||||
'bode' => 'cabra',
|
||||
'boi' => 'vaca',
|
||||
'burro' => 'besta',
|
||||
'cão' => 'cadela',
|
||||
'carneiro' => 'ovelha',
|
||||
'cavaleiro' => 'amazona',
|
||||
'frade' => 'freira',
|
||||
'veado' => 'cerva',
|
||||
'zangão' => 'abelha',
|
||||
'ateu' => 'atéia',
|
||||
'ator' => 'atriz',
|
||||
'avô' => 'avó',
|
||||
'embaixador' => 'embaixatriz',
|
||||
'judeu' => 'judia',
|
||||
'maestro' => 'maestrina',
|
||||
'marajá' => 'marani',
|
||||
'réu' => 'ré',
|
||||
'sultão' => 'sultana'
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'freguês'=> 'fregueses'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'óculos',
|
||||
'oculos',
|
||||
'átlas',
|
||||
'atlas',
|
||||
'binoculos',
|
||||
'calças',
|
||||
'lápis',
|
||||
'lapis',
|
||||
'vírus',
|
||||
'virus'
|
||||
);
|
||||
|
||||
/**
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @method is_singular
|
||||
* @return boolean
|
||||
* @param String $string
|
||||
*/
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function toPlural( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toSingular( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toPlural_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::toPlural($string);
|
||||
}
|
||||
|
||||
public static function toFemale($string)
|
||||
{
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return self::$genreSpecific[$string];
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toMale($string)
|
||||
{
|
||||
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
foreach ( self::$genreSpecific as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
if(preg_match($pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$male as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function isFemale($string)
|
||||
{
|
||||
// it is a female from the specific list
|
||||
if(in_array($string, self::$genreSpecific))
|
||||
return true;
|
||||
// if it is a male kay, in the specific list
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return false;
|
||||
// ok, now let's see if it is a female by touching it!
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match($pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
// Thanks to http://www.eval.ca/articles/php-toPlural (MIT license)
|
||||
// http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
||||
// http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
||||
// http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
||||
//
|
||||
// Changes (12/17/07)
|
||||
// Major changes
|
||||
// --
|
||||
// Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
||||
// (this allows for things like fireman -> firemen
|
||||
// Fixed the order of the singular array, which was backwards.
|
||||
//
|
||||
// Minor changes
|
||||
// --
|
||||
// Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
||||
// Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
||||
// Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
||||
// Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
||||
// Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
||||
// Added excpetions for feet, geese and teeth
|
||||
// Added rule for deer -> deer
|
||||
//
|
||||
// Changed by Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
// added is_singular static method
|
||||
// translation to Brazilian portugues pt-BR
|
||||
//
|
||||
// Changes:
|
||||
// Removed rule for virus -> viri
|
||||
// Added rule for potato -> potatoes
|
||||
// Added rule for *us -> *uses
|
||||
|
||||
class Inflect
|
||||
{
|
||||
static $plural = array(
|
||||
'/(.+[aeiou])ão$/' => "$1ões",
|
||||
'/(.+[aeiou][a-z])ão$/' => "$1ães",
|
||||
'/(.+[rs])$/' => "$1es",
|
||||
'/(.+[aeou])l$/' => "$1is",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})il$/' => "$1eis",
|
||||
'/(.+i)l$/' => "$1s",
|
||||
'/(.+)z$/' => "$1ses",
|
||||
'/(.+)m$/' => "$1ns",
|
||||
'/([aeiou])$/' => "$1s",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $singular = array(
|
||||
'/(.+[aeiou])ões$/' => "$1ão",
|
||||
'/(.+[aeiou][a-z])ães$/' => "$1ão",
|
||||
'/(.+r)es$/' => "$1",
|
||||
'/(.+)ses$/' => "$1z",
|
||||
'/(.+s)es$/' => "$1",
|
||||
'/(.+[aeou])is$/' => "$1l",
|
||||
'/(.+[áéíóúâô][a-z]{1,2})eis$/' => "$1il",
|
||||
'/(.+i)s$/' => "$1l",
|
||||
'/(.+)ns$/' => "$1m",
|
||||
'/([aeiouãõéíóúâôê])s$/' => "$1",
|
||||
'/(.+x)$/' => "$1"
|
||||
);
|
||||
|
||||
static $female= Array(
|
||||
'/([aeiou][a-z]{1,2})ão$/' => "$1ona",
|
||||
'/([aeiou])ão$/' => "$1oa",
|
||||
'/o$/' => "a",
|
||||
'/e$/' => "a",
|
||||
'/or$/' => "ora",
|
||||
'/om$/' => "oa",
|
||||
'/m$/' => "m",
|
||||
);
|
||||
|
||||
static $male= Array(
|
||||
'/([aeiou][a-z]{1,2})ona$/' => "$1ão",
|
||||
'/([aeiou])oa$/' => "$1ão",
|
||||
'/ora$/' => "or",
|
||||
'/([aeiou][a-z]{1,2})a$/' => "$1o",
|
||||
'/a$/' => "e"
|
||||
);
|
||||
|
||||
static $genreSpecific= Array(
|
||||
'cônsul' => 'consulesa',
|
||||
'visconde' => 'viscondessa',
|
||||
'homem' => 'mulher'
|
||||
'poeta' => 'poetisa',
|
||||
'bode' => 'cabra',
|
||||
'boi' => 'vaca',
|
||||
'burro' => 'besta',
|
||||
'cão' => 'cadela',
|
||||
'carneiro' => 'ovelha',
|
||||
'cavaleiro' => 'amazona',
|
||||
'frade' => 'freira',
|
||||
'veado' => 'cerva',
|
||||
'zangão' => 'abelha',
|
||||
'ateu' => 'atéia',
|
||||
'ator' => 'atriz',
|
||||
'avô' => 'avó',
|
||||
'embaixador' => 'embaixatriz',
|
||||
'judeu' => 'judia',
|
||||
'maestro' => 'maestrina',
|
||||
'marajá' => 'marani',
|
||||
'réu' => 'ré',
|
||||
'sultão' => 'sultana'
|
||||
);
|
||||
|
||||
static $irregular = array(
|
||||
'move' => 'moves',
|
||||
'freguês'=> 'fregueses'
|
||||
);
|
||||
|
||||
static $uncountable = array(
|
||||
'óculos',
|
||||
'oculos',
|
||||
'átlas',
|
||||
'atlas',
|
||||
'binoculos',
|
||||
'calças',
|
||||
'lápis',
|
||||
'lapis',
|
||||
'vírus',
|
||||
'virus'
|
||||
);
|
||||
|
||||
/**
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @method is_singular
|
||||
* @return boolean
|
||||
* @param String $string
|
||||
*/
|
||||
public static function is_singular( $string )
|
||||
{
|
||||
// if it is uncountable, then, it may be treated as a singular
|
||||
if(in_array($string, Inflect::$uncountable))
|
||||
return true;
|
||||
// let's check for irregular forms
|
||||
if(in_array($string, array_keys(Inflect::$irregular)))
|
||||
return true;
|
||||
// now, let's see if the word isn't the plural from a irregular form
|
||||
// still faster than running all the plural forms, I bet
|
||||
elseif(in_array($string, Inflect::$irregular))
|
||||
return false;
|
||||
// ok, if the word reached here, it diserves some care
|
||||
// let's finally check if it matches with any plural rule
|
||||
foreach(self::$plural as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function toPlural( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular singular forms
|
||||
foreach ( self::$irregular as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$plural as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
return preg_replace('/$/', '$1s', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toSingular( $string )
|
||||
{
|
||||
// save some time in the case that singular and plural are the same
|
||||
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
||||
return $string;
|
||||
|
||||
// check for irregular plural forms
|
||||
foreach ( self::$irregular as $result => $pattern )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach ( self::$singular as $pattern => $result )
|
||||
{
|
||||
if ( preg_match( $pattern, $string ) )
|
||||
return preg_replace( $pattern, $result, $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toPlural_if($count, $string)
|
||||
{
|
||||
if ($count == 1)
|
||||
return "1 $string";
|
||||
else
|
||||
return $count . " " . self::toPlural($string);
|
||||
}
|
||||
|
||||
public static function toFemale($string)
|
||||
{
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return self::$genreSpecific[$string];
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toMale($string)
|
||||
{
|
||||
|
||||
// first, we gotta see if it is a word with specific genre change
|
||||
foreach ( self::$genreSpecific as $pattern => $result )
|
||||
{
|
||||
$pattern = '/' . $pattern . '$/i';
|
||||
if(preg_match($pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
// check for matches using regular expressions
|
||||
foreach(self::$male as $pattern => $result)
|
||||
{
|
||||
if(preg_match( $pattern, $string))
|
||||
return preg_replace($pattern, $result, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function isFemale($string)
|
||||
{
|
||||
// it is a female from the specific list
|
||||
if(in_array($string, self::$genreSpecific))
|
||||
return true;
|
||||
// if it is a male kay, in the specific list
|
||||
if(array_key_exists($string, self::$genreSpecific))
|
||||
return false;
|
||||
// ok, now let's see if it is a female by touching it!
|
||||
foreach(self::$female as $pattern => $result)
|
||||
{
|
||||
if(preg_match($pattern, $string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Document : lexics.xml
|
||||
Created on : November 6, 2010, 1:40 PM
|
||||
Author : felipe
|
||||
Description:
|
||||
Lists the valid characteres to be allowed, or to be translated
|
||||
-->
|
||||
<root>
|
||||
<validchars>
|
||||
<lower>abdefghijklmnopqrstuvxyzw</lower>
|
||||
<upper>ABCDEFGHIJKLMNOPQRSTUVXYZW</upper>
|
||||
<special>áéíóúÁÉÍÓÚ"."ÀàÂâêÊîÎôÔûÛãÃõÕẽẼüÜçÇ</special>
|
||||
<numbers>1234567890</numbers>
|
||||
<symbols>\/!@#$%*()_-+=,.'">&<</symbols>
|
||||
<!--<symbols>\/!@#$%&*()_-+=[]{},.'"</symbols>-->
|
||||
</validchars>
|
||||
<replacements>
|
||||
<from>áéíóúÁÉÍÓÚÀàÂâêÊîÎôÔûÛãÃõÕẽẼüÜçÇ</from>
|
||||
<to >aeiouAEIOUAaAaeEiIoOuUaAoOeEuUcC</to>
|
||||
</replacements>
|
||||
</root>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<verbs>
|
||||
<action>
|
||||
<!--
|
||||
These verbs are treated like:
|
||||
substantive action [ammount] substantive
|
||||
|
||||
-->
|
||||
</action>
|
||||
</verbs>
|
||||
@@ -13,6 +13,6 @@
|
||||
|
||||
public function __construct() {
|
||||
$this->setTrigger('test');
|
||||
$this->setEvent('before');
|
||||
$this->setEvent('after');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* This class represents the program auth, receiving the user and
|
||||
* may also receive the password. It will start your session
|
||||
* allowing you to run the restricted programs
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class Analyze extends MindCommand implements program
|
||||
{
|
||||
private $nameSpace= false;
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('analyze')
|
||||
->setDescription('Analyze the the code for your application')
|
||||
->setRestrict(true)
|
||||
->setDefinition(Array(
|
||||
new InputArgument('namespace', InputArgument::OPTIONAL, 'Analyze an specific namespace')
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
This program will analyze your code, typed on your application directory, on all the files .mnd starting for the main.mnd
|
||||
You may have as many files as you want, each of then will be treated as namespaces and will be analyzed too,
|
||||
unless you have sent an specific namespace to parse, as argument
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input,
|
||||
Console\Output\OutputInterface $output)
|
||||
{
|
||||
if(!parent::execute($input, $output))
|
||||
return false;
|
||||
$this->nameSpace= $input->getArgument('namespace');
|
||||
$this->runAction();
|
||||
}
|
||||
|
||||
public function HTTPExecute()
|
||||
{
|
||||
GLOBAL $_REQ;
|
||||
if(!parent::HTTPExecute())
|
||||
return false;
|
||||
if(isset($_REQ['data']['namespace']))
|
||||
$this->nameSpace= $_REQ['data']['namespace'];
|
||||
$this->runAction();
|
||||
}
|
||||
|
||||
private function action()
|
||||
{
|
||||
if(!isset($_SESSION['currentProject']))
|
||||
{
|
||||
Mind::write('currentProjectRequired');
|
||||
Mind::write('currentProjectRequiredTip');
|
||||
return false;
|
||||
}
|
||||
$srcs= Mind::$currentProject['sources'];
|
||||
$main= file_get_contents($srcs.'/main.mnd');
|
||||
|
||||
// search for special/unknown characters
|
||||
if(!Mind::$lexer->sweep($main))
|
||||
return false;
|
||||
// mark specific tokens
|
||||
//if(!Mind::tokenizer::sweep($main))
|
||||
return false;
|
||||
// keep substantives and verbs on their canonical form
|
||||
// on male singular, for example
|
||||
//if(!Mind::canonic::sweep($main))
|
||||
return false;
|
||||
// prepares te model to be used to process data
|
||||
// it transforms the original text into the mind code
|
||||
// itself
|
||||
//if(!Mind::sintaxer::sweep($main))
|
||||
return false;
|
||||
// removes the tokens, added before
|
||||
//if(!Mind::tokenizer::clear($main))
|
||||
return false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function runAction()
|
||||
{
|
||||
return $this->action();
|
||||
}
|
||||
}
|
||||
@@ -47,16 +47,20 @@ EOT
|
||||
return false;
|
||||
$this->what= $input->getArgument('what');
|
||||
$this->argName= $input->getArgument('name');
|
||||
$this->info= $input->getOption('info');
|
||||
echo "login: ";
|
||||
$this->login= trim(fgets(fopen("php://stdin", "r")));
|
||||
echo "pwd: ";
|
||||
$this->pwd= Mind::readPassword(true);
|
||||
echo "\n";
|
||||
while($this->userType!='N' && $this->userType!='A')
|
||||
|
||||
if($this->what == 'user')
|
||||
{
|
||||
echo "Type (use A for admin, or N for normal): ";
|
||||
$this->userType= strtoupper(trim(fgets(fopen("php://stdin", "r"))));
|
||||
$this->info= $input->getOption('info');
|
||||
echo "login: ";
|
||||
$this->login= trim(fgets(fopen("php://stdin", "r")));
|
||||
echo "pwd: ";
|
||||
$this->pwd= Mind::readPassword(true);
|
||||
echo "\n";
|
||||
while($this->userType!='N' && $this->userType!='A')
|
||||
{
|
||||
echo "Type (use A for admin, or N for normal): ";
|
||||
$this->userType= strtoupper(trim(fgets(fopen("php://stdin", "r"))));
|
||||
}
|
||||
}
|
||||
$this->runAction();
|
||||
}
|
||||
@@ -140,7 +144,12 @@ EOT
|
||||
)";
|
||||
$db->execute($qr_userProj);
|
||||
$db->execute("COMMIT");
|
||||
|
||||
Mind::write('projectCreated', true, $this->argName);
|
||||
|
||||
Mind::openProject(Array('pk_project'=>$key,
|
||||
'name'=>$this->argName));
|
||||
|
||||
echo "\n";
|
||||
break;
|
||||
case 'user':
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* This class represents the program auth, receiving the user and
|
||||
* may also receive the password. It will start your session
|
||||
* allowing you to run the restricted programs
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class SetUse extends MindCommand implements program
|
||||
{
|
||||
private $argName= false;
|
||||
private $what= false;
|
||||
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('use')
|
||||
->setDescription('Opens the project, or specifies any personal option')
|
||||
->setRestrict(true)
|
||||
->setFileName('SetUse')
|
||||
->setDefinition(Array(
|
||||
new InputArgument('what', InputArgument::REQUIRED, 'What to use, from now on'),
|
||||
new InputArgument('name', InputArgument::REQUIRED, 'specify what you want to use/open')
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
You can use this command to start using a different language or project, for example
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input,
|
||||
Console\Output\OutputInterface $output)
|
||||
{
|
||||
if(!parent::execute($input, $output))
|
||||
return false;
|
||||
$this->what= $input->getArgument('what');
|
||||
$this->argName= $input->getArgument('name');
|
||||
$this->runAction();
|
||||
}
|
||||
|
||||
public function HTTPExecute()
|
||||
{
|
||||
GLOBAL $_REQ;
|
||||
if(!parent::HTTPExecute())
|
||||
return false;
|
||||
if(isset($_REQ['data']['what']) && isset($_REQ['data']['name']))
|
||||
{
|
||||
$this->argName= $_REQ['data']['name'];
|
||||
$this->what= $_REQ['data']['what'];
|
||||
}
|
||||
$this->runAction();
|
||||
}
|
||||
|
||||
private function action()
|
||||
{
|
||||
switch($this->what)
|
||||
{
|
||||
case 'project':
|
||||
if(!$projectData= Mind::hasProject($this->argName))
|
||||
return false;
|
||||
Mind::openProject($projectData);
|
||||
break;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function runAction()
|
||||
{
|
||||
return $this->action();
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ EOT
|
||||
|
||||
public function HTTPExecute()
|
||||
{
|
||||
if(!parent::HTTPExecute($input, $output))
|
||||
if(!parent::HTTPExecute())
|
||||
return false;
|
||||
GLOBAL $_REQ;
|
||||
$this->whatToShow= $_REQ['data']['what'];
|
||||
|
||||
+11
-3
@@ -27,7 +27,11 @@
|
||||
_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Input/',
|
||||
_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Output/',
|
||||
_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Command/',
|
||||
_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Helper/'
|
||||
_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Helper/',
|
||||
_MINDSRC_.'/mind3rd/API/cortex/Lexer/',
|
||||
_MINDSRC_.'/mind3rd/API/cortex/tokenizer/',
|
||||
_MINDSRC_.'/mind3rd/API/cortex/canonic/',
|
||||
_MINDSRC_.'/mind3rd/API/cortex/sintaxer/'
|
||||
);
|
||||
for($i=0; $i<sizeof($dirs); $i++)
|
||||
{
|
||||
@@ -62,7 +66,9 @@
|
||||
new Clear(),
|
||||
new Info(),
|
||||
new Create(),
|
||||
new Show()
|
||||
new Show(),
|
||||
new Analyze(),
|
||||
new SetUse()
|
||||
));
|
||||
|
||||
$helperSet= false;
|
||||
@@ -93,8 +99,10 @@
|
||||
}
|
||||
$d->close();
|
||||
}
|
||||
|
||||
Mind::$lexer= new Lexer();
|
||||
|
||||
if($_REQ['env']=='shell')
|
||||
include('shell.php');
|
||||
else
|
||||
include('http.php');
|
||||
include('http.php');
|
||||
Arquivo binário não exibido.
externo
+1
-1
@@ -2,7 +2,7 @@
|
||||
; it should represent your preferences about how mind should behave
|
||||
;
|
||||
; the default idiom
|
||||
defaul_human_language=En ; not yet implemented
|
||||
default_human_language=ptBR
|
||||
; default timezone
|
||||
timezone=America/Sao_paulo
|
||||
; the default programming language
|
||||
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You can also set the title for your app
|
||||
title=Mind3rd Generated Application
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+25
@@ -0,0 +1,25 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You can also set the title for your app
|
||||
title=Mind3rd Generated Application
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+25
@@ -0,0 +1,25 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You can also set the title for your app
|
||||
title=Mind3rd Generated Application
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+25
@@ -0,0 +1,25 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+4
@@ -0,0 +1,4 @@
|
||||
AéH*§x
|
||||
Ç § =
|
||||
asd
|
||||
asdq
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You can also set the title for your app
|
||||
title=Mind3rd Generated Application
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+25
@@ -0,0 +1,25 @@
|
||||
; This file will be used by mind3rd due to generate
|
||||
; the structure or even code for it
|
||||
;
|
||||
; First, let's inform mind3rd about what you want
|
||||
; to use in your application
|
||||
;
|
||||
; The idiom is the human language you want to use
|
||||
idiom=pt-br
|
||||
; The technology you specify here, will be used as
|
||||
; the backend of your application
|
||||
; this will be the name of the model you want to apply
|
||||
; to your app, of course, it depends on the models
|
||||
; you've got installed
|
||||
technology=php-zf
|
||||
; You will need to configure your database
|
||||
; the module you choose will probably try to implement
|
||||
; some PDO drivers, so, put the one you want, here
|
||||
database_drive=pgsql
|
||||
; now, the ip address or host name
|
||||
database_addr=localhost
|
||||
; then, the port
|
||||
database_port=5432
|
||||
; and here, the user and password
|
||||
database_user=root
|
||||
dataase_pwd=root
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This is a model, created to ilustrate how and where
|
||||
* you can write your code
|
||||
* You may have as many files as you want, altough, the
|
||||
* main.mnd is required
|
||||
*/
|
||||
Referência em uma Nova Issue
Bloquear um usuário