59 Commits

Autor SHA1 Mensagem Data
Felipe Nascimento de Moura 90987bbc28 changes on how to show data(temporarily) after analyzing 2011-03-09 16:34:57 -03:00
Felipe Nascimento de Moura 9e6d50becb reorganized the analyst class structure 2011-03-09 11:07:25 -03:00
Felipe Nascimento de Moura 156e6cbd7e Added(and fixed) some comments 2011-03-08 01:57:01 -03:00
Felipe Nascimento de Moura 73e5d8110b Added(and fixed) some comments 2011-03-08 01:55:08 -03:00
Felipe Nascimento de Moura a0d96e0824 added useful comments and removed the useless ones 2011-03-07 02:44:55 -03:00
Felipe Nascimento de Moura b2296a6f26 fixed problems with the n:n relations 2011-03-07 02:16:15 -03:00
Felipe Nascimento de Moura 058d3aa0f1 fixed irregularities with 1:1 relations 2011-03-05 02:53:25 -03:00
Felipe Nascimento de Moura c038113947 fixed problems with some unitTest classes 2011-03-04 16:49:38 -03:00
Felipe Nascimento de Moura 02ac4722b1 done: adding pk and fk properties to entities 2011-03-04 03:57:51 -03:00
Felipe Nascimento de Moura b66af6da77 done: n:n relations 2011-03-04 03:18:38 -03:00
Felipe Nascimento de Moura 6e9179a518 Done: relations 1:1 normalization 2011-03-03 15:46:30 -03:00
Felipe Nascimento de Moura a5f806b54a added a few comments, and changes to the README file 2011-03-03 02:18:06 -03:00
Felipe Nascimento de Moura c0514d2499 1:1 / 1:1 relations evolution 2011-03-03 02:06:12 -03:00
Felipe Nascimento de Moura 47523ca411 1:1 / 1:1 relations evolution 2011-03-03 00:37:04 -03:00
Felipe Nascimento de Moura 0a80cb904c 1:1 / 1:1 relations evolution 2011-03-03 00:08:19 -03:00
Felipe Nascimento de Moura 623eba95f1 added BRAKE qualifier to idioms 2011-02-25 12:33:19 -03:00
Felipe Nascimento de Moura 4618c35c79 fixed problems with some verbs and composed substantives, and added some unit tests more 2011-02-25 11:23:43 -03:00
Felipe Nascimento de Moura a7ff4fd99c added feature to deal with composed entities and properties description 2011-02-25 01:26:46 -03:00
Felipe Nascimento de Moura 2d94cc2e26 added feature to deal with composed entities and properties description 2011-02-25 01:23:59 -03:00
Felipe Nascimento de Moura 77cc6e4631 added UNIQUE property to MindProperty 2011-02-24 21:30:20 -03:00
Felipe Nascimento de Moura 8517abe185 treatment of composed substantives 2011-02-24 16:48:16 -03:00
Felipe Nascimento de Moura 5f04f28132 added comments 2011-02-24 12:37:49 -03:00
Felipe Nascimento de Moura 1f287d041a Changes to the analyst. Now, it has a better support for groups of instructions
E.g.: teacher, student and professor have parents and grandparents.
This will be interpreted just as it should.
The same is now working to specify a group of properties to a group of entities
2011-02-24 02:19:49 -03:00
Felipe Nascimento de Moura 54bb7d6201 removed PHPDocumentor generator files 2011-02-23 18:24:36 -03:00
Felipe Nascimento de Moura 5b37276a17 PHPDocumentor generated files, removed from git 2011-02-23 18:15:08 -03:00
Felipe Nascimento de Moura 3c09f88f4a added unit tests 2011-02-23 18:12:33 -03:00
Felipe Nascimento de Moura 38512ec204 changes to unit tests 2011-02-23 16:09:37 -03:00
Felipe Nascimento de Moura 9b8fbcd90b added more unit tests 2011-02-21 19:24:32 -03:00
Felipe Nascimento de Moura a012e0a41d Created unit tests for some of the core/cortex classes
Some of these unit tests brought to sight a few problems, which have been fixed
2011-02-21 16:53:41 -03:00
Felipe Nascimento de Moura 9b90b2c893 fixed regular expression to match default values 2011-02-18 18:55:22 -02:00
Felipe Nascimento de Moura a4ba5eb637 removing temporary files 2011-02-18 18:07:40 -02:00
Felipe Nascimento de Moura 010daccdca removing temporary files 2011-02-18 18:06:04 -02:00
Felipe Nascimento de Moura 950b116188 added feature of options on attributes 2011-02-17 17:26:26 -02:00
Felipe Nascimento de Moura bd1ca9b03a Adjusts to cortex classes
Added a few more comments
created the Normalizer class...next step is to normalize the contextualized data
2011-02-17 02:43:26 -02:00
Felipe Nascimento de Moura 2151886f39 fixed bug of repeated entities, when specified in the same line 2011-02-16 18:04:33 -02:00
Felipe Nascimento de Moura 6fe620e966 added a few comments 2011-02-16 15:37:53 -02:00
Felipe Nascimento de Moura 157a655cd4 fixed problem with SOME strange chars when trying to encode them 2011-02-16 15:36:15 -02:00
Felipe Nascimento de Moura 91b0281b00 fixed problem with non utf8 chars 2011-02-16 02:27:55 -02:00
Felipe Nascimento de Moura 2d213e1e4a works with the analyst 2011-02-14 19:30:05 -02:00
Felipe Nascimento de Moura 79fd5762f9 added static addresses to constants library
changes and TODO itens added to test program
2011-02-14 13:49:46 -02:00
Felipe Nascimento de Moura 9fb1495599 changes to README.md 2011-02-12 16:54:55 -02:00
Felipe Nascimento de Moura 3ba04ff3a8 changes to README.md 2011-02-12 16:54:25 -02:00
Felipe Nascimento de Moura 9fe39f37e0 changes to README.md 2011-02-12 16:52:44 -02:00
Felipe Nascimento de Moura 9d031fb770 changes to README.md 2011-02-12 16:48:34 -02:00
Felipe Nascimento de Moura b8761c793e changes to README.md 2011-02-12 16:47:09 -02:00
Felipe Nascimento de Moura 72876b0c74 changes to README.md 2011-02-12 16:46:08 -02:00
Felipe Nascimento de Moura 4932ed5b36 changes to README.md 2011-02-12 16:45:14 -02:00
Felipe Nascimento de Moura c3e77b00a4 changes to README.md 2011-02-12 16:38:32 -02:00
Felipe Nascimento de Moura af795101a7 changes to README.md 2011-02-12 16:36:25 -02:00
Felipe Nascimento de Moura a0ae63dbdb changes to README.md 2011-02-12 16:35:05 -02:00
Felipe Nascimento de Moura acf12cead3 changes to README.md 2011-02-12 16:31:23 -02:00
Felipe Nascimento de Moura 143b1a722f changes to README.md 2011-02-12 16:24:02 -02:00
Felipe Nascimento de Moura efc961f804 changes to README.md 2011-02-12 16:22:53 -02:00
Felipe Nascimento de Moura 62b85d379f 2011-02-12 10:20:24 -08:00
Felipe Nascimento de Moura 6de5b1f868 2011-02-12 10:20:00 -08:00
Felipe Nascimento de Moura 145b0a69de 2011-02-12 10:17:50 -08:00
Felipe Nascimento de Moura f938ae6a0a 2011-02-12 10:15:55 -08:00
Felipe Nascimento de Moura 67460c5e91 2011-02-12 10:13:50 -08:00
Felipe Nascimento de Moura 0ff1e64bfa changes to README.markdown 2011-02-12 16:11:12 -02:00
65 arquivos alterados com 2598 adições e 793 exclusões
+7 -1
Ver Arquivo
@@ -3,6 +3,12 @@
##
mind3rd/projects/*
##
## PHPDocs
##
docs/PHPDoc/*
docs/PHPDOCS/*
##
## SQLite
##
@@ -16,7 +22,7 @@ mind3rd/API/temp/*
##
## Development meta files
##
*~
*.*~
.project
.DS_Store
nbproject
-40
Ver Arquivo
@@ -1,40 +0,0 @@
Requires:
PHP 5.3+
PHP-cli
PHP-SQLite
Installation
**For now, only working on mac and Linux...sorry bill!**
Your HTTPServer's user must have permission to read and write on its folder
In your console, run the following command into this directory:
$sudo php mind install
Great! Now you're good to go
To perform some examples and tests, access in your browser
the IDE demo
http://[yourMindDir]/docs/ide
For graphics, diagrams, examples of code, help and documentation, see
the docs directory
[yourMindDir]/docs/
Your projects are stored at:
[yourMindDir]/projects/[projectName]
You can write your codes directly in sources/main.mnd in your
project's source directory
You can see the generated documentation and source code on 'docs' and
'app' directories, into the project's directory
Please, check/change the data and options as you need, on
[yourMindDir]/env/defaults.ini
Unit tests are on Tests directory, run it with PHPUnit
[yourMindDir]/Tests
Useful/interesting links:
http://thewebmind.org
http://docs.thewebmind.org
contact@thewebmind.org
http://twitter.com/thewebmind
http://twitter.com/felipenmoura
Arquivo executável
+51
Ver Arquivo
@@ -0,0 +1,51 @@
TheWebMind
===============================================
This is the source code for theWebMind project.
Requirements:
---------
* PHP 5.3+
* PHP-cli
* PHP-SQLite
Installation:
-------------
For now, only working on mac and Linux...sorry bill!
Your HTTPServer's user must have permission to read and write on its folder
In your console, run the following command into this directory:
$sudo php mind install
Great! Now you're good to go
* * *
Examples and tests:
-------------
To perform some examples and tests, access in your browser
the IDE demo
http://[yourMindDir]/docs/ide
For graphics, diagrams, examples of code, help and documentation, see
the docs directory
[yourMindDir]/docs/
Your projects are stored at:
[yourMindDir]/projects/[projectName]
You can write your codes directly in sources/main.mnd in your
project's source directory.
You can see the generated documentation and source code on 'docs' and
'app' directories, into the project's directory.
Please, check/change the data and options as you need, on
[yourMindDir]/env/defaults.ini
Unit tests are on Tests directory, run it with PHPUnit
[yourMindDir]/Tests
Useful/interesting links:
[Official website](http://thewebmind.org "theWebMind") |
[Licenses](https://github.com/felipenmoura/theWebMind/blob/master/licenses/mind3rd.license, "Licenses") |
[Documentation](http://docs.thewebmind.org "documentation") |
[Contact](mailto:contact@thewebmind.org "contact") |
[Twitter](http://twitter.com/thewebmind "twitter") |
[Contribute](http://thewebmind.org/contribute "Contribute")
+6
Ver Arquivo
@@ -0,0 +1,6 @@
mind3rd/API/languages/en/IgnoreFormsTest.php en\IgnoreFormsTest
mind3rd/API/languages/en/InflectTest.php en\InflectTest
mind3rd/API/languages/en/VerbalizerTest.php en\VerbalizerTest
mind3rd/API/languages/pt/IgnoreFormsTest.php pt\IgnoreFormsTest
mind3rd/API/languages/pt/InflectTest.php pt\InflectTest
mind3rd/API/languages/pt/VerbalizerTest.php pt\VerbalizerTest
+43
Ver Arquivo
@@ -0,0 +1,43 @@
<?php
require_once dirname(__FILE__) . '/../mind3rd/API/classes/Mind.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindSpeaker.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/Darwin/Darwin.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/Lexer/Lexer.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/canonic/Canonic.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/syntaxer/Syntaxer.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindEntity.php';
require_once dirname(__FILE__) . '/../mind3rd/API/utils/constants.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/VersionManager.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindProject.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindRelation.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindEntity.php';
require_once dirname(__FILE__) . '/../mind3rd/API/classes/MindProperty.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/analyst/Normal.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/analyst/Analysis.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/analyst/Normalizer.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/analyst/Analyst.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/tokenizer/Token.php';
require_once dirname(__FILE__) . '/../mind3rd/API/cortex/tokenizer/Tokenizer.php';
if(!class_exists('MindForUnitTest'))
{
class MindForUnitTest
{
public function __construct()
{
$this->defaults= Array(
'pk_prefix'=>'pk_',
'fk_prefix'=>'fk_'
);
}
}
$_MIND= new MindForUnitTest();
}
/*if(!defined('_MINDSRC_'))
define('_MINDSRC_', dirname(__FILE__).'/..');
if(!defined('_CONSOLE_LINE_LENGTH_'))
define('_CONSOLE_LINE_LENGTH_', 80);
$_MIND= new Mind();*/
@@ -0,0 +1,181 @@
<?php
require(dirname(__FILE__) . '/../../../../../Tests/config.php');
/**
* Test class for Analyst.
* Generated by PHPUnit on 2011-02-21 at 01:40:36.
*/
class AnalystPtTest extends PHPUnit_Framework_TestCase {
/**
* @var Analyst
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
// you gotta set the idiom simply to start some required variables
// once these tests wont use the idiom as a key subject
MindProject::loadIdiom('en');
Mind::$langPath= dirname(__FILE__) . '/../../../../../mind3rd/API/languages/en/';
Mind::$lexer= new Lexer();
$this->object = new Analyst;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called afhas a test is executed.
*/
protected function tearDown() {
}
/**
* the used words doesn't metter here, the main spine is the keys group,
* so, it doesn't metter what language is set
*/
public function testAnalize1() {
$this->assertEquals($this->object->analize(
Array
('teacher', '', 'has', '', '', '', 'student'),
'SQVNONS',
Array
(2, 128, 1, 8, 16, 32, 2)),
Array('min'=>1,
'max'=>'n',
'linkType'=>'possibility',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize2() {
$this->assertEquals($this->object->analize(
Array
('teacher', '', 'has', '', '', '', 'student'),
'SQVNONS',
Array
(2, 64, 1, 8, 16, 32, 2)),
Array('min'=>1,
'max'=>'n',
'linkType'=>'must',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize3() {
$this->assertEquals($this->object->analize(
Array
('teacher', '', 'have', '', '', '', 'student'),
'SQVNONS',
Array
(2, 128, 1, 4, 16, 8, 2)),
Array('min'=>0,
'max'=>1,
'linkType'=>'possibility',
'linkVerb'=>'have',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize4() {
$this->assertEquals($this->object->analize(
Array
('teacher', 'have', '', '', '', 'student'),
'SQVNONS',
Array
(2, 1, 4, 16, 8, 2)),
Array('min'=>0,
'max'=>1,
'linkType'=>'action',
'linkVerb'=>'have',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize5() {
$this->assertEquals($this->object->analize(
Array
('teacher', 'has', '', '', '', 'student'),
'SQVNONS',
Array
(2, 1, 8, 16, 32, 2)),
Array('min'=>1,
'max'=>'n',
'linkType'=>'action',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize6() {
$this->assertEquals($this->object->analize(
Array
('teachera', 'has', '', '', '', 'aluna'),
'SQVNONS',
Array
(2, 1, 4, 16, 32, 2)),
Array('min'=>0,
'max'=>'n',
'linkType'=>'action',
'linkVerb'=>'has',
'rel'=>'aluna',
'focus'=>'teachera'));
}
public function testAnalize7() {
$this->assertEquals($this->object->analize(
Array
('teacher', 'has', '', 'student'),
'SQVNONS',
Array
(2, 1, 32, 2)),
Array('min'=>0,
'max'=>'n',
'linkType'=>'action',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize8() {
$this->assertEquals($this->object->analize(
Array
('teacher', 'has', '', 'student'),
'SQVNONS',
Array
(2, 1, 8, 2)),
Array('min'=>0,
'max'=>1,
'linkType'=>'action',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize9() {
$this->assertEquals($this->object->analize(
Array
('teacher', '', 'has', '', 'student'),
'SQVNONS',
Array
(2, 64, 1, 8, 2)),
Array('min'=>1,
'max'=>1,
'linkType'=>'must',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
public function testAnalize10() {
$this->assertEquals($this->object->analize(
Array
('teacher', '', 'has', '', 'student'),
'SQVNONS',
Array
(2, 128, 1, 32, 2)),
Array('min'=>0,
'max'=>'n',
'linkType'=>'possibility',
'linkVerb'=>'has',
'rel'=>'student',
'focus'=>'teacher'));
}
}
@@ -0,0 +1,220 @@
<?php
require_once dirname(__FILE__) . '/../../../../../Tests/config.php';
/**
* Test class for Syntaxer.
* Generated by PHPUnit on 2011-02-25 at 09:21:58.
*/
class SyntaxerTest extends PHPUnit_Framework_TestCase {
/**
* @var Syntaxer
*/
public $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->setIdiom();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}
public function setIdiom($idiom='en')
{
Mind::$currentProject['idiom']= $idiom;
Mind::$langPath= dirname(__FILE__) . '/../../../../../mind3rd/API/languages/';
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/IgnoreForms.php';
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/Verbalizer.php';
Tokenizer::loadModifiers(dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/');
Mind::$tokenizer= new Tokenizer;
Mind::$lexer= new Lexer;
$this->object = new Syntaxer();
}
public function testSweepWords1() {
$this->setIdiom();
Mind::$tokenizer->sweep(Array('child', 'of', 'heart', 'has', 'parent', 'of', 'family'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child_heart',
'has',
'parent_family',
)
);
}
public function testSweepWords2() {
Mind::$tokenizer->sweep(Array('child',
'of',
'heart',
'and',
'friend',
'of',
'child',
'of',
'heart',
'has',
'parent',
'of',
'family'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child_heart',
',',
'friend_child_heart',
'has',
'parent_family'
)
);
}
public function testSweepWords3() {
Mind::$tokenizer->sweep(Array('child',
'of',
'heart',
',',
'friend',
'of',
'kid',
'of',
'heart',
'has',
'parent',
'of',
'family'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child_heart',
',',
'friend_kid_heart',
'has',
'parent_family'
)
);
}
public function testSweepWords4() {
Mind::$tokenizer->sweep(Array('child',
'of',
'heart',
',',
'friend',
'of',
'kid',
'of',
'heart',
'has',
'parent',
'of',
'family',
',',
'mother',
'of',
'parent'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child_heart',
',',
'friend_kid_heart',
'has',
'parent_family',
',',
'mother_parent'
)
);
}
public function testSweepWords5() {
Mind::$tokenizer->sweep(Array('child',
'has',
'parent'
));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child',
'has',
'parent'
)
);
}
public function testSweepWords6() {
Mind::$tokenizer->sweep(Array('child',
'of',
'heart',
',',
'friend',
'of',
'kid',
'of',
'heart',
'has',
'name of origin:varchar(250)',
',',
'age:int'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child_heart',
',',
'friend_kid_heart',
'has',
'name of origin:varchar(250)',
',',
'age:int'
)
);
}
public function testSweepWords7() {
Mind::$tokenizer->sweep(Array('child',
',',
'friend',
'has',
'name of origin:varchar(250)',
',',
'age:int'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child',
',',
'friend',
'has',
'name of origin:varchar(250)',
',',
'age:int'
)
);
}
public function testSweepWords8() {
Mind::$tokenizer->sweep(Array('child',
'has',
'name of origin:varchar(250)',
',',
'age:int'));
$this->object->sweep();
$this->assertEquals(Tokenizer::$words,
Array(
'child',
'has',
'name of origin:varchar(250)',
',',
'age:int'
)
);
}
}
@@ -0,0 +1,103 @@
<?php
require(dirname(__FILE__) . '/../../../../../Tests/config.php');
/**
* Test class for Tokenizer.
* Generated by PHPUnit on 2011-02-21 at 11:46:35.
*/
class TokenizerTest extends PHPUnit_Framework_TestCase {
/**
* @var Tokenizer
*/
protected $object;
protected $idiom= 'en';
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->setIdiom();
}
public function setIdiom($idiom='en')
{
Mind::$currentProject['idiom']= $idiom;
Mind::$langPath= dirname(__FILE__) . '/../../../../../mind3rd/API/languages/';
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/IgnoreForms.php';
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/Verbalizer.php';
Tokenizer::loadModifiers(dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/');
$this->object = new Tokenizer;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}
// these are the tests in Portuguese, that's why we're setting
// the idiom to PT in the first line on each test
public function testSweep1() {
$this->setIdiom('pt');
$ar= Array('cada','professor','dever', 'ter', 'um','ou','muitos','aluno','.');
$exp= Array(-4, 2, 64, 1, 8, 16, 32, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep2() {
$this->setIdiom('pt');
$ar= Array('professor', 'ter', 'um','aluno','.');
$exp= Array(2, 1, 8, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep3() {
$this->setIdiom('pt');
$ar= Array('professor', 'poder', 'ter', 'um','aluno','.');
$exp= Array(2, 128, 1, 8, 2, -2);
$this->assertEquals($exp, $this->object->sweep($ar));
}
public function testSweep4() {
$this->setIdiom('pt');
$ar= Array('professor', 'poder', 'ter', 'um', 'ou', 'muitos','aluno','.');
$exp= Array(2, Token::MT_QMAY, 1, 8, Token::MT_OR, Token::MT_MANY, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep5() {
$this->setIdiom('pt');
$ar= Array('cada','professor','dever', 'ter', 'muitos','aluno','.');
$exp= Array(-4, 2, 64, 1, 32, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
// here are the tests in english
public function testSweep6() {
$ar= Array('each','teacher','must', 'have', 'one','or','many','student','.');
$exp= Array(-4, 2, 64, 1, 8, 16, 32, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep7() {
$ar= Array('teacher', 'have', 'one','student','.');
$exp= Array(2, 1, 8, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep8() {
$ar= Array('teacher', 'may', 'have', 'one','student','.');
$exp= Array(2, Token::MT_QMAY, 1, 8, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep9() {
$ar= Array('teacher', 'must', 'have', 'one','student','.');
$exp= Array(2, Token::MT_QMUST, 1, 8, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
public function testSweep10() {
$ar= Array('each','teacher','may', 'have', 'one','or','many','student','.');
$exp= Array(-4, 2, Token::MT_QMAY, 1, 8, 16, 32, 2, -2);
$this->assertEquals($this->object->sweep($ar), $exp);
}
}
+3 -1
Ver Arquivo
@@ -5,4 +5,6 @@ which
whom
whose
well
too
too
another
also
@@ -0,0 +1,6 @@
SVS
SQVS
SVNONS
SVNS
SQVNONS
SQVNS
+24 -22
Ver Arquivo
@@ -30,6 +30,11 @@ class VerbalizerTest extends PHPUnit_Framework_TestCase {
}
/* NOTE: we wont be testing any first person verb flection
* because such rules are commented on the main class as
* mind3rd wont treat such sentences
*/
public function testIsVerb() {
$this->assertTrue(pt\Verbalizer::isVerb('correr'));
}
@@ -46,40 +51,40 @@ class VerbalizerTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(pt\Verbalizer::isVerb('apresentar'));
}
public function testIsVerb5() {
$this->assertTrue(pt\Verbalizer::isVerb('coloco'));
$this->assertTrue(pt\Verbalizer::isVerb('sobrescreve'));
}
public function testIsVerb6() {
$this->assertTrue(pt\Verbalizer::isVerb('lemos'));
$this->assertTrue(pt\Verbalizer::isVerb('lerão'));
}
public function testIsVerb7() {
$this->assertTrue(pt\Verbalizer::isVerb('correremos'));
$this->assertTrue(pt\Verbalizer::isVerb('correm'));
}
public function testIsVerb8() {
$this->assertTrue(pt\Verbalizer::isVerb('ministrarão'));
}
public function testIsVerb9() {
$this->assertTrue(pt\Verbalizer::isVerb('tomamos'));
$this->assertTrue(pt\Verbalizer::isVerb('tomarão'));
}
public function testIsVerb10() {
$this->assertTrue(pt\Verbalizer::isVerb('comemos'));
$this->assertTrue(pt\Verbalizer::isVerb('come'));
}
public function testIsVerb11() {
$this->assertTrue(pt\Verbalizer::isVerb('beberemos'));
$this->assertTrue(pt\Verbalizer::isVerb('bebe'));
}
public function testIsVerb12() {
$this->assertTrue(pt\Verbalizer::isVerb('tomo'));
}
public function testIsVerb13() {
$this->assertTrue(pt\Verbalizer::isVerb('como'));
}
public function testIsVerb14() {
$this->assertTrue(pt\Verbalizer::isVerb('toma'));
}
public function testIsVerb13() {
$this->assertTrue(pt\Verbalizer::isVerb('come'));
}
public function testIsVerb14() {
$this->assertTrue(pt\Verbalizer::isVerb('tomará'));
}
public function testIsVerb15() {
$this->assertTrue(pt\Verbalizer::isVerb('coma'));
$this->assertTrue(pt\Verbalizer::isVerb('comerá'));
}
public function testIsVerb17() {
$this->assertTrue(pt\Verbalizer::isVerb('levantaremos'));
$this->assertTrue(pt\Verbalizer::isVerb('levantar'));
}
public function testIsVerb18() {
$this->assertFalse(pt\Verbalizer::isVerb('abajur'));
@@ -94,22 +99,22 @@ class VerbalizerTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(pt\Verbalizer::isVerb('falhar'));
}
public function testIsVerb22() {
$this->assertTrue(pt\Verbalizer::isVerb('falhei'));
$this->assertTrue(pt\Verbalizer::isVerb('falharão'));
}
public function testIsVerb23() {
$this->assertTrue(pt\Verbalizer::isVerb('falharei'));
$this->assertTrue(pt\Verbalizer::isVerb('falhar'));
}
public function testIsVerb24() {
$this->assertTrue(pt\Verbalizer::isVerb('falhou'));
}
public function testIsVerb25() {
$this->assertTrue(pt\Verbalizer::isVerb('falhamos'));
$this->assertTrue(pt\Verbalizer::isVerb('comenta'));
}
public function testIsVerb26() {
$this->assertTrue(pt\Verbalizer::isVerb('falharei'));
$this->assertTrue(pt\Verbalizer::isVerb('comentará'));
}
public function testIsVerb27() {
$this->assertTrue(pt\Verbalizer::isVerb('falharemos'));
$this->assertTrue(pt\Verbalizer::isVerb('comentarão'));
}
public function testIsVerb28() {
$this->assertTrue(pt\Verbalizer::isVerb('correu'));
@@ -170,9 +175,6 @@ class VerbalizerTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('poder', pt\Verbalizer::toInfinitive('pode'));
}
public function testLoadVerbs() {
}
}
?>
+10 -3
Ver Arquivo
@@ -1,4 +1,11 @@
de
a
o
as
os
aos
que
da
do
bem
também
tanto
todo
cada
@@ -0,0 +1,6 @@
SVS
SQVS
SVNONS
SVNS
SQVNONS
SQVNS
+35
Ver Arquivo
@@ -0,0 +1,35 @@
{
define a mais e a menos relevantes()
ter maior relevancia, 3pt
pega demais pontuações(entidade)
pega demais pontuações(entidade)
se a entidade tiver poucos campos, 1pt
se a entidade tiver apenas campos pequenos, 1pt
se a menos da metade dos campos da entidade for not null, 1pt
retorna a pontuação adiquirida
vale a pena mesclar?()
pega demais pontuações(menos relevante)
vale a pena se tiver atingido 3 pontos
corrige entidades()
exclui relação entre menos relevante e mais relevante
adiciona chave da mais relevante na menos relevante como fk E pk para que sejam unicas
mescla entidades()
coloca todas as propriedades da entidade mais fraca, na mais forte
altera todas as relações entre a tabela mais fraca e demais tabelas, para que apontem para a mais forte
}
define a mais e a menos relevantes()
se for 1:1 / 1:1
mescla entidades()
se 0:1 / 0:1
se vale a pena mesclar
mescla entidades()
senao
corrige entidades()
Se 0:1 / 1:1
corrige entidades()
+3 -2
Ver Arquivo
@@ -1,6 +1,6 @@
<script src='scripts/jquery.js'></script>
<body>
<div id='result' style='white-space:pre;'></div>
<pre><div id='result' style='white-space:pre;'></div></pre>
<br/>
<input type='button' value='autenticate' onclick="autenticate()"/>
<input type='button' value='run test' onclick="runTest()"/>
@@ -32,7 +32,8 @@
type:'POST',
url:'http://localhost/mind/',
data:{
program:'test'
program:'test',
unit: true
},
success: function(ret){
document.getElementById('result').innerHTML= ret
+5 -1
Ver Arquivo
@@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2010 TheWebMind.org
Copyright (c) 2011 TheWebMind.org, Felipe Nascimento de Moura
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -22,3 +22,7 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Main contacts:
felipe@thewebmind.org // http://felipenmoura.org // twitter: @felipenmoura
jaydson@thewebmind.org // http://jaydson.org // twitter: @jaydson
+20 -20
Ver Arquivo
@@ -31,28 +31,28 @@ class pt {
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['programRequired'] = Mind::message("API: Você precisa passar o nome do programa a ser executado.", '[Fail]', false);
$this->messages['loginRequired'] = Mind::message("Auth: Tanto login quanto senha são obrigatórios.", '[Fail]', false);
$this->messages['passwordRequired'] = "Precisarei do password para este usuário, por favor: ";
$this->messages['autenticated'] = Mind::message("\nMain: %s autenticado", "[OK]", false);//"\n[OK] %s autenticated\n";
$this->messages['not_allowed'] = Mind::message("\nMain: Você ainda não autenticou suas credenciais.", '[Fail]', false);
$this->messages['not_allowed_tip'] = "Tente executar o comando\n auth < login >\nUma senha será solicitada.\n";
$this->messages['no_such_file'] = Mind::message("\nMain: Não conheço tal comando: '%s'", "[Fail]", false);
$this->messages['auth_fail'] = Mind::message("\nAuth: Usuário ou senha inválidos", "[Fail]", false);
$this->messages['bye'] = "Saindo, até logo...\n";
$this->messages['invalidCreateParams'] = Mind::message("Main: Parâmetros inválidos", "[Fail]", false);
$this->messages['invalidOption'] = Mind::message("Opção inválida '%s'", '[Fail]', false);
$this->messages['projectAlreadyExists'] = Mind::message("Lamento mas já existe um projeto de mesmo nome.", '[Fail]', false);
$this->messages['projectCreated'] = Mind::message("Projeto '%s' criado.", '[Ok]', false);
$this->messages['userCreated'] = Mind::message("Usuário '%s' criado", '[Ok]', false);
$this->messages['noProject'] = Mind::message("Projeto '%s' não existe ou você não tem acesso ao mesmo.", '[Fail]', false);
$this->messages['projectOpened'] = Mind::message("Acessando projeto '%s'", '[Ok]', false);
$this->messages['currentProjectRequired'] = Mind::message("Primeiro você precisará abrir um projeto.", '[Fail]', false);
$this->messages['currentProjectRequiredTip']= "Tente com o comando\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.
Requisição HTTP inválida.
Você *deve* enviar alguma informação via POST juntamente com o parâmetro "program" com o nome do programa que deseja rodar e seus parâmetros.
MESSAGE;
}
}
+23 -8
Ver Arquivo
@@ -13,6 +13,7 @@
public $defaults= null;
public $conf= null;
public static $autoloadPaths= Array();
public static $currentProject= null;
public static $ref= Array();
public static $projectsDir= '';
@@ -148,23 +149,37 @@
return MindProject::openProject($p);
}
/**
* Adds a directory to the autoload source paths list
* @param String $path
*/
public static function autoloadRegisterPath($path)
{
if(is_string($path) && !in_array($path, Mind::$autoloadPaths))
Mind::$autoloadPaths[]= $path;
else
foreach($path as $p)
if(!in_array($p, Mind::$autoloadPaths))
Mind::$autoloadPaths[]= $p;
}
/**
* Constructor
*/
public function Mind(){
$path= _MINDSRC_;
Mind::$projectsDir= $path.'/mind3rd/projects/';
Mind::$modelsDir= $path.'/mind3rd/API/models/';
$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['default_human_language'].'.php');
Mind::$projectsDir= $path.PROJECTS_DIR;
Mind::$modelsDir= $path.MODELS_DIR;
$this->about= parse_ini_file($path.ABOUT_INI);
$this->defaults= parse_ini_file($path.DEFAULTS_INI);
$this->conf= parse_ini_file($path.MIND_CONF);
require_once($path.L10N_DIR.$this->defaults['default_human_language'].'.php');
Mind::$curLang= $this->defaults['default_human_languageName'];
Mind::$l10n= new $this->defaults['default_human_language']();
Mind::$langPath= $path.'/mind3rd/API/languages/';
Mind::$langPath= $path.LANG_PATH;
Mind::$curLang= $this->defaults['default_human_language'];
$langPath= $path.'/mind3rd/API/languages/';//.$this->defaults['default_human_languageName'].'/';
$langPath= $path.LANG_PATH;
set_include_path(get_include_path() . PATH_SEPARATOR . $langPath);
}
}
+112 -4
Ver Arquivo
@@ -7,27 +7,135 @@
*/
class MindEntity {
public $name;
public $properties= Array();
public $relations= Array();
public $name;
public $pks= Array();
public $relevance= 0;
public $properties= Array();
public $relations= Array();
private $refTo= Array();
private $refBy= Array();
public function &getRefTo()
{
return $this->refTo;
}
/**
* Verifies if the definition describes an entity or not
*
* @param string $definition
* @return boolean
*/
public static function isEntity($definition)
{
return strpos($definition, ":")? false: true;
}
/**
* Adds a property to the current entity
*
* @global $_MIND
* @param MindProperty $property
* @return MindEntity
*/
public function addProperty(MindProperty $property)
{
GLOBAL $_MIND;
//if($property->key && $_MIND->defaults['add_pk_prefix_to_all_keys'])
// $property->setName($_MIND->defaults['pk_prefix'].$property->name);
$this->properties[$property->name]= $property;
if($property->key)
$this->pks[$property->name]= $property;
return $this;
}
/**
* Verifies if the current entity has a specified property
*
* @param string $propName
* @return boolean
*/
public function hasProperty($propName)
{
return isset($this->properties[$propName]);
}
/**
* Defines another entity pointed/refered by this entity
* @param MindEntity $ref
* @return MindEntity
*/
public function addRefTo(MindEntity &$ref)
{
$this->refTo[$ref->name]= &$ref;
return $this;
}
/**
* Removes a reference TO
* @param type $refName
* @return MindEntity
*/
public function removeRefTo($refName)
{
unset($this->refTo[$refName]);
return $this;
}
/**
* Specifies that another entity is pointing to this one
* @param MindEntity $ref
* @return MindEntity
*/
public function addRefBy(MindEntity &$ref)
{
$this->refBy[$ref->name]= &$ref;
return $this;
}
/**
* Removes a reference BY
* @param type $refName
* @return MindEntity
*/
public function removeRefBy($refName)
{
unset($this->refBy[$refName]);
return $this;
}
/**
* Adds a reference to the current entity
*
* @param MindRelation $rel
* @return MindEntity
*/
public function addRef(MindRelation &$rel)
{
$this->relations[]= &$rel;
$this->relations[$rel->name]= &$rel;
if($rel->focus->name == $this->name)
{
if($rel->max == QUANTIFIER_MAX_MAX)
{
$this->relevance++;
$this->addRefBy($rel->rel);
}else
$this->addRefTo($rel->rel);
}else{
if($rel->max == QUANTIFIER_MAX_MIN)
{
$this->relevance++;
$this->addRefBy($rel->focus);
}else
$this->addRefTo($rel->focus);
}
return $this;
}
/**
* Constructor. It receives the name of the new entity
* @param string $word
*/
public function MindEntity($word)
{
$this->name= (string)$word;
+2 -2
Ver Arquivo
@@ -4,7 +4,7 @@
*
* @author felipe
*/
class MindProject {
class MindProject extends VersionManager{
/**
* Returns true if the project already exists,
* false, otherwise
@@ -47,7 +47,7 @@ class MindProject {
public static function loadIdiom($idiom)
{
$idiom= str_replace('\\', DIRECTORY_SEPARATOR, $idiom);
$langPath= $path.'/mind3rd/API/languages/'.$idiom.'/';
$langPath= '/mind3rd/API/languages/'.$idiom.'/';
set_include_path(get_include_path() . PATH_SEPARATOR . $langPath);
}
+169 -27
Ver Arquivo
@@ -6,16 +6,130 @@
*/
class MindProperty {
public $definition= "";
public $name= false;
public $type= "text";
public $size= 0;
public $default= null;
public $required= false;
public $refTo= false;
public $refBy= Array();
public $key= false;
public $definition= "";
private $name = false;
private $type = "text";
private $size = 0;
private $options = Array();
private $default = null;
private $unique = false;
private $required = false;
public $refTo = false;
public $refBy = Array();
public $key = false;
public function setRefTo(MindEntity $entity)
{
$this->refTo= $entity;
}
/**
* Return all the properties
* @param string $what
* @return mixed
*/
public function __get($what)
{
if(isset($this->$what))
return $this->$what;
return false;
}
/**
* Set name
* @param string $val
* @return MindProperty
*/
public function setName($val)
{
$this->name= (string)$val;
return $this;
}
/**
* Set size
* @param int/float $val
* @return MindProperty
*/
public function setSize($val)
{
$this->size= $val;
return $this;
}
/**
* Set Options
* @param Array $val
* @return MindProperty
*/
public function setOptions($val)
{
$this->options= $val;
return $this;
}
/**
* Set type
* @param string $val
* @return MindProperty
*/
public function setType($val)
{
$this->type= (string)$val;
$tmpType= self::isKnown($this->type);
if(!$tmpType)
{
//TODO: Darwin::add($this->type);
Darwin::addDoubt($this->type, 'dataType');
echo "UNKNOWN TYPE ".$this->type."...for a while";
return false;
}
return $this;
}
/**
* Set Default value
* @param string $val
* @return MindProperty
*/
public function setDefault($val)
{
$this->default= (string)$val;
return $this;
}
/**
* Set as unique or not
* @param boolean $val
* @return MindProperty
*/
public function setUnique($val)
{
$this->unique= $val? true: false;
return $this;
}
/**
* Set wheter the property is required(not null) or not
* @param boolean $val
* @return MindProperty
*/
public function setRequired($val)
{
$this->required= $val? true: false;
return $this;
}
/**
* Set the property as a key
* @return MindProperty
*/
public function setAsKey()
{
$this->key= true;
return $this;
}
/**
* Checks if the string sent indicates that it is about a property
* @param String $definition
@@ -53,6 +167,19 @@
$rx= "/".implode('|', Tokenizer::$qualifiers['notnull'])."/i";
return (preg_match($rx, $expression))? true: false;
}
/**
* Verifies on the passed string if it indicates that the current
* property definition should be unique or not
*
* @param String $expression
* @return boolean
*/
public static function isUnique($expression)
{
$rx= "/".implode('|', Tokenizer::$qualifiers['unique'])."/i";
return (preg_match($rx, $expression))? true: false;
}
/**
* Returns true in case the passed expression represent a property
@@ -85,18 +212,10 @@
$typeEnd= strpos($str, '(');
$typeEnd= $typeEnd? $typeEnd- $typeStart: strLen($str);
$type= substr($str, $typeStart, $typeEnd);
$this->type= $type;
$tmpType= self::isKnown($this->type);
if(!$tmpType)
{
//TODO: Darwin::add($this->type);
echo "UNKNOWN TYPE...for a while";
return false;
}else
$type= $tmpType;
$this->setType($type);
// identifying the name
$this->name= substr($str, 0, $typeStart);
$this->setName(Mind::$lexer->fixWordChars(substr($str, 0, $typeStart-1)));
// identifying details
if(preg_match(PROP_DETAILS, $str, $details))
@@ -115,20 +234,41 @@
$default= preg_replace(PROP_DEFEXEC, "", $default);
}
$this->default= $default;
$this->setDefault($default);
}
// identifying if it is required
if(self::isRequired($details))
$this->required= true;
$this->setRequired(true);
// identifying if it is a forced key
if(self::isKey($details))
$this->key= true;
$this->setAsKey();
// identifying its size
if(preg_match(PROP_SIZE, $details, $size))
$this->size= $size[0];
$this->setSize($size[0]);
// identifying the options
if(preg_match(PROP_OPTIONS, $details, $options))
{
$options= explode('|',
preg_replace(PROP_OPTIONS_CLEAR,
'',
$options[0])
);
foreach($options as &$opt)
{
$opt= explode('=', $opt, 2);
}
$this->setOptions($options);
}
// checking if it is unique
if(self::isUnique($details))
{
$this->setUnique(true);
}
}
return true;
}
@@ -140,10 +280,12 @@
*
* @param String $definition
*/
public function MindProperty($definition)
public function MindProperty($definition=false)
{
$this->definition= $definition;
$this->parse();
//echo json_encode($this)."\n";
if($definition)
{
$this->definition= $definition;
$this->parse();
}
}
}
+94 -5
Ver Arquivo
@@ -6,7 +6,7 @@
*/
class MindRelation {
public $name;
public $name;
private $linkTypes = Array('possibility', 'must', 'action');
private $linkType = 'action';
private $quantifiers = Array(0, 1, 'n');
@@ -15,7 +15,67 @@
private $verb = '';
private $focus = null;
private $rel = null;
public $opposite = null;
public $uniqueRef = false;
public $treated = false; //to be used by Normalizer
/**
* Renames a relation, replacing it into the Analyst relations list
*
* @param string $newName
* @return MindRelation
*/
public function rename($newName)
{
Analyst::$relations[$newName]= Analyst::$relations[$this->name];
Analyst::$relations[$this->name]= false;
$this->name= (string)$newName;
return $this;
}
/**
* Specifies the relative entity
*
* @param MindEntity $rel
* @return MindRelation
*/
public function setRel(MindEntity &$rel)
{
$this->rel= &$rel;
return $this;
}
/**
* Specifies the focused entity
*
* @param MindEntity $focus
* @return MindRelation
*/
public function setFocus(MindEntity &$focus)
{
$this->focus= &$focus;
return $this;
}
/**
* Return properties from the current relation
* These properties were set to private due to set limitations
* but they may be open for get operations
*
* @param String $what
* @return Mixed
*/
public function __get($what)
{
if(isset($this->$what))
return $this->$what;
}
/**
* Sets the type of link(possibility, action or must)
* @param string $linkType
* @return MindRelation
*/
public function setLinkType($linkType)
{
if(in_array($linkType, $this->linkTypes))
@@ -26,32 +86,57 @@
return false;
}
/**
* Sets the minimun value of the relation(0 or 1)
* @param Mixed $min
* @return MindRelation
*/
public function setMin($min)
{
if(in_array($min, $this->quantifiers))
if($min === 0 || $min === 1)
{
$this->min= $min;
return $this;
}
throw new Exception("Invalid minimum quantifier: ".$min, 0);
return false;
}
/**
* Sets the maximun value for the relation(1 or n)
* @param mixed $max
* @return MindRelation
*/
public function setMax($max)
{
if(in_array($max, $this->quantifiers))
if($max == 1 || $max == 'n')
{
$this->max= $max;
return $this;
}
throw new Exception("Invalid maximum quantifier: ".$max, 0);
return false;
}
/**
* Defines which verb was used to define the current instruction
*
* @param string $verb
* @return MindRelation
*/
public function setUsedVerb($verb)
{
$this->verb= (string)$verb;
return $this;
}
/**
* Specifies which entities are envolved in this relation
*
* @param MindEntity $focus
* @param MindEntity $rel
* @return MindRelation
*/
public function setEntities(MindEntity &$focus, MindEntity &$rel)
{
$this->focus= &$focus;
@@ -59,6 +144,10 @@
return $this;
}
/**
* The constructor, receiving the name of the relation
* @param string $relName
*/
public function MindRelation($relName)
{
$this->name= (string)$relName;
+14
Ver Arquivo
@@ -0,0 +1,14 @@
<?php
/**
* This class takes care of the version control methods
*
* @author felipe
*/
class VersionManager {
public static function commit()
{
// TODO: commiting a project should save the current
// situation of the current project
echo "COMMITING";
}
}
+12
Ver Arquivo
@@ -0,0 +1,12 @@
<?php
/**
* Description of Darwin
*
* @author felipe
*/
class Darwin {
public static function addDoubt($context, $type)
{
echo "DUVIDAAAA";
}
}
+75 -14
Ver Arquivo
@@ -1,9 +1,21 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Lexer, within the Cortex/Lexer packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* This class sweeps the passed words and validates if
* its content matches with the valid chars
*
* @author felipe
* @package Cortex
* @subpackage Lexer
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
class Lexer
{
@@ -16,7 +28,10 @@ class Lexer
private $glue= '';
/**
* Thanks to saeedco (no more information found about him!)
* Splits a string using utf8 format.
*
* Thanks to saeedco (no more information found about him!) I had to
* change only a few things on this method.
* Source: http://br2.php.net/manual/en/function.str-split.php#83331
* Idioms it is supposed to work properly
* English
@@ -28,14 +43,25 @@ class Lexer
* Russian
* Persian
* Portuguese
*
* Of course, if you find any problem, report it to us :)
*
* @param String $str
* @param String $str The string to be splitted.
* @return array
*/
private function str_split_utf8($str) {
// place each character of the string into and array
$split=1;
$array = array();
/*
* SOMEONE HERE, PLEASE! Explain that for me!
* ONLY the 'ó' char isnt working when treated...even 'Ó' is!
* ALL the other characteres are working just fine!
* Someone who could fix it in a better way, please
*/
$str= str_replace('ó', 'o', $str);
for ( $i=0; $i < strlen( $str ); ){
$value = ord($str[$i]);
if($value > 127){
@@ -58,7 +84,11 @@ class Lexer
}
/**
* Validates the sent char
* Validates the sent char.
*
* Verifies wether the passed char is a valid char for
* that idiom or not.
*
* @param char $letter
* @return boolean
*/
@@ -79,6 +109,46 @@ class Lexer
}
/**
* Prepares names for their use.
*
* Parses the string encoding and returns a valid name
* to be used on databases or restricted names
*
* @param String $word
* @return String
*/
public function fixWordChars($word)
{
$word= preg_replace(FIX_PROP_NAME, '', strtolower($word));
$word= $this->str_split_utf8($word);
$str= "";
for($i=0, $j=sizeof($word); $i<$j; $i++)
{
$str.= $this->translateChars($word[$i]);
}
return strtolower($str);
}
/**
* Fixes the passed string replacing special chars.
*
* This method takes each special char and replaces it with
* the respective char specified in the choosen idiom.
*
* @param string $str
* @return string
*/
public function translateChars($str)
{
$from = $this->replacements[0];
$to = $this->replacements[1];
return strtr(utf8_decode($str), utf8_decode($from), $to);
}
/**
* Sweeps through the content and apply the lexer rules.
*
* Performs a sweep over the sent content and replace any
* special char, also removing any invalid char.
* @param string $content
@@ -157,17 +227,8 @@ class Lexer
}
/**
* Returns the fixed char to the sent char
* @param string $char
* @return string
* The constructor
*/
public function translateChars($str)
{
$from = $this->replacements[0];
$to = $this->replacements[1];
return strtr($str, $from, $to);
}
public function __construct()
{
GLOBAL $_MIND;
+257
Ver Arquivo
@@ -0,0 +1,257 @@
<?php
/**
* This file is part of theWebMind 3rd generation.
*
* Analyst components, within the Cortex/Analyst packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
* @filesource
*/
/**
* This is an abstract class to be used to analyze the project.
*
* @package Cortex
* @subpackage Analyst
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
abstract class Analysis {
public static $entities = Array();
public static $relations= Array();
public static $focused = Array();
/**
* Returns an array with the names of all entities.
*
* Gets an Array of the names of all the focused entities on
* the current expression.
* @return Array
*/
public static function getFocusedNames()
{
$focused= Array();
foreach(self::$focused as $focus)
$focused[]= $focus->name;
return $focused;
}
/**
* Clears the current focused entities.
*/
public static function clearFocused()
{
self::$focused = false;
self::$focused = Array();
}
/**
* Adds an entity to the focused entities list.
* @param MindEntity &$entity The entity to be added to focus
*/
public static function addToFocus(MindEntity &$entity)
{
self::$focused[]= $entity;
}
/**
* Adds a relation to the focused list.
*
* Adds a relation between all the focused entities specified in the
* current expression and the passed $rel entity
*
* @param MindEntity &$rel The entity to be added
* @param String $linkType The type of like(action, possibility or must)
* @param String $linkVerb The verb used to identify the relation
* @param Mixed $min The minimun quantifier
* @param Mixed $max The maximun quantifier
* @param boolean [$uniqueRef] If it should be an unique referation
* @return MindRelationCollection An array of all the created relations
*/
public static function &addRelationToFocused(MindEntity &$rel, $linkType,
$linkVerb, $min, $max,
$uniqueRef=false)
{
$arRet= Array();
// for each focused entity
foreach(self::$focused as &$focus)
{
/*
* we will use this relationName as index on an
* indexed array to speed up the search for
* relations in the future
*/
$relationName= $focus->name."_".$rel->name;
// let's create the relation itself
$curRelation= new MindRelation($relationName);
$curRelation->setLinkType($linkType)
->setMin($min)
->setMax($max)
->setUsedVerb($linkVerb)
->setEntities(
self::$entities[$focus->name],
self::$entities[$rel->name]);
// now, both entities will POINT to the same relation
$focus->addRef($curRelation);
$rel->addRef($curRelation);
$curRelation->uniqueRef= $uniqueRef;
// and let's use the relation name as index, as said before
self::$relations[$relationName]= $curRelation;
$arRet[]= &$curRelation;
}
return $arRet;
}
/**
* Adds the passed property to all the focused entities.
*
* @param MindProperty &$prop The property to be added to the focused entities.
*/
public static function addPropertyToFocused(MindProperty &$prop)
{
// for each focused entity
foreach(self::$focused as $focus)
$focus->addProperty($prop);
}
/**
* Analyzes the project.
*
* This method receives each expression and analizes
* the best way to act and to store the understood
* structure
*
* @param String $expression
* @param String $structure
* @param Array $structureKeys
* @return Boolean True if everything went ok, false when any error occurred
*/
public static function analize($expression, $structure, Array $structureKeys){
// I'm gonna try to put it in stepByStep style, to
// get it easier for me and for you to understand
// and follow the thoughts
// setting up
self::clearFocused();
$tmpProperties= Array();
$i = 0;
$linkVerb = null;
$min = null;
$max = null;
$linkType = 'action';
$relation = false;
$posVerb = false;
// foreach token
foreach($structureKeys as $token)
{
$word= $expression[$i];
$i++;
// storing the current used verb
if($token==Tokenizer::MT_VERB)
{
$linkVerb= $word;
$posVerb= true;
continue;
}
// setting quantifiers
if($token == Tokenizer::MT_NONE)
{
$min= 0;
continue;
}
if($token == Tokenizer::MT_ONE || $token == Tokenizer::MT_MANY)
{
if(!is_null($max))
$min= $max;
$max= ($token == Tokenizer::MT_ONE)? 1: 'n';
}
// verifying the way the entities will be linked
if($token==Tokenizer::MT_QMAY)
{
$linkType= 'possibility';
continue;
}
if($token==Tokenizer::MT_QMUST)
{
$linkType= 'must';
continue;
}
// if it is a substantive
if($token==Tokenizer::MT_SUBST)
{
// if it is an entity
if(MindEntity::isEntity($word))
{
// fixing any special char
$word= Mind::$lexer->fixWordChars($word);
// yeah, I know it looks crazy, but try to follow my thoughts
// let's instantiate a new Entity in case it has not been
// instantiated before
if(!isset(self::$entities[$word]))
self::$entities[$word]= new MindEntity($word);
// each instruction *should* have one focused entity
// we will use the first entity on each expression as focus
if(!$posVerb)
{
self::addToFocus(self::$entities[$word]);
}else{
$relation= true;
// if min or max quantifier have not been set
if(is_null($min))
$min= ($linkType == 'must')? 1: 0;
if(is_null($max))
$max= 'n';
/*
* here, if it is an entity and the focused
* entities have already been selected(post verb),
* it means it is the second entity on the
* instruction, so, it is a relation between entities
*/
self::addRelationToFocused(self::$entities[$word],
$linkType,
$linkVerb,
$min,
$max);
}
}else{
// ok, after that, this is just easy :)
// let's store all the properties to a temporary array
$tmpProperties[]= new MindProperty($word);
}
}
}
// adding the properties to the focused entity
// we're doing it now, because according to the selected idiom
// the sequence of focused entity and properties may vary
if(sizeof($tmpProperties)>0 && $posVerb)
{
foreach($tmpProperties as $prop)
self::addPropertyToFocused($prop);
}
// if there was a relation, we will return some details about it
if($relation && isset(self::$entities[$word]))
return Array('min' =>$min,
'max' =>$max,
'linkVerb' =>$linkVerb,
'linkType' =>$linkType,
'focus' =>implode(', ', self::getFocusedNames()),
'rel' =>self::$entities[$word]->name);
// otherwise, we return the focused entities
return self::$focused;
}
}
+169 -141
Ver Arquivo
@@ -1,31 +1,77 @@
<?php
/**
* This class is responsable to the analisys of the system
* This file is part of theWebMind 3rd generation.
*
* Analyst components, within the Cortex/Analyst packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
* @filesource
*/
/**
* This class is responsible for the analysis of the system
* preparing the relations and apply the first rules
*
* foreach token
* if isSubst & MindProp.isProperty
* if !prop
* if !evidencedEntity
* setEvidencedEntity
* else
* MindEntity.addRelation
* else
* if !mindProp.isValid
* echo ERROR
* if !mindProp.isKnown
* MindDarwin.addToDoubts
* return
* MindEntity.addProp
* return
*
* @author felipe
* @package Cortex
* @subpackage Analyst
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
class Analyst {
public static $entities= Array();
public static $relations= Array();
class Analyst extends Analysis {
/**
* Returns true if the entity is worth mergin with another, or not.
* It takes the relevance as parameter to determine wheter the entity
* should be merged(stop existing) or not.
*
* @param MindEntity $en The entity to be analyzed
* @return boolean
*/
public static function isItWorthMerging(MindEntity $en)
{
GLOBAL $_MIND;
if(Normalizer::relevanceAmount($en) < $_MIND->conf['merging_amount_pts'])
return true;
return false;
}
/**
* Removes an entity from the entities list.
* @param type $entity The entity to be removed
*/
public static function removeEntity($entity)
{
unset(self::$entities[$entity]);
unset($entity);
}
/**
* Removes a relation between two entities.
* But it will NOT remove the refBy or refTo properties of each entity.
* It is most often, useful to be used for relations that may have
* been represented twice, as the same idea.
* It also decreases the relevance of the focused entity.
*
* @param MindRelation &$rel The relation which will be droped
*/
public static function unsetRelation(MindRelation &$rel)
{
if($rel->focus)
{
$rel->focus->relations[$rel->name]= false;
$rel->focus->relevance--;
}
if($rel->rel)
$rel->rel->relations[$rel->name]= false;
unset(self::$relations[$rel->name]);
}
/**
* Gets the whole interpreted context, with all the
* analyzed information
* @return Array An array with both entities and relations
*/
public static function getUniverse()
{
return Array(
@@ -35,133 +81,115 @@ class Analyst {
}
/**
* This method receives each expression and analizes
* the best way to act and to store the understood
* structure
*
* @param String $expression
* @param String $structure
* @param Array $structureKeys
* @return Boolean True if everything went ok, false when any error occurred
* Prints out the analyzed content
* @param boolean $detailed Pass true if it should show detailed
* information about the entities and properties.
*/
public static function analize($expression, $structure, $structureKeys){
// setting up
$tmpProperties= Array();
$i= 0;
$focus= null;
$linkVerb= null;
$min= null;
$max= 'n';
$linkType= 'action';
// foreach token
foreach($structureKeys as $token)
public static function printWhatYouGet($detailed=true)
{
$props= 0;
echo "ENTITIES: ".sizeof(self::$entities)."\n";
foreach(self::$entities as $k=>$entity)
{
$word= $expression[$i];
$i++;
// storing the current used verb
if($token==Tokenizer::MT_VERB)
if($detailed)
{
$linkVerb= $word;
continue;
echo " ".$entity->name.
"\n";
//echo "[".$k."]\n";
}
if(
$min == null &&
(
$token == Tokenizer::MT_NONE ||
$token == Tokenizer::MT_ONE
)
)
foreach($entity->properties as $prop)
{
$min= ($token == Tokenizer::MT_ONE)? 1: 0;
continue;
}
if(
$min != null &&
(
$token == Tokenizer::MT_MANY ||
$token == Tokenizer::MT_ONE
)
)
{
$max= ($token == Tokenizer::MT_ONE)? 1: 'n';
}
// verifying the way the entities will be linked
if($token==Tokenizer::MT_QMAY)
{
$linkType= 'possibility';
continue;
}
if($token==Tokenizer::MT_QMUST)
{
$linkType= 'must';
continue;
}
// if it is a substantive
if($token==Tokenizer::MT_SUBST)
{
// if it is an entity
if(MindEntity::isEntity($word))
$details= false;
$details= Array();
if($prop->size)
$details[]= $prop->size;
if($prop->uinque)
$details[]= "unique";
if($prop->key)
$details[]= "key";
if($prop->required)
$details[]= "not null";
if(!is_null($prop->default) && trim($prop->default) != '')
$details[]= ($prop->default!= AUTOINCREMENT_DEFVAL)?
'"'.$prop->default.'"':
"AUTO_INCREMENT";
if(sizeof($prop->options) > 0)
{
// yeah, I know it looks crazy, but try to follow my thoughts
// let's instantiate a new Entity in case it has not been
// instantiated before
if(!isset(self::$entities[$word]))
self::$entities[$word]= new MindEntity($word);
// each instruction *should* have one focused entity
// we will use the first entity on each expression as focus
if(!$focus)
{
$focus= self::$entities[$word];
}else{
/*
* here, if it is an entity and the focused
* entity has already been selected, it means
* it is the second entity on the instruction, so,
* it is a relation between entities(or should be)
*/
$rel= self::$entities[$word];
/*
* we will use this relationName as index on an
* indexed array to speed up the search for
* relations in the future
*/
$relationName= $focus->name."_".$rel->name;
// let's create the relation itself
$curRelation= new MindRelation($relationName);
$curRelation->setLinkType($linkType)
->setMin($min)
->setMax($max)
->setUsedVerb($linkVerb)
->setEntities($focus, $rel);
// now, both entities will POINT to the same relation
$focus->addRef($curRelation);
$rel->addRef($curRelation);
// and let's use the relation name as index, as said before
self::$relations[$relationName]= &$curRelation;
}
}else{
// ok, after that, this is just easy, now :)
// let's store all the properties to a temporary array
$tmpProperties[]= new MindProperty($word);
}
$details[]= "{".implode("|", array_keys($prop->default))."}";
}
$props++;
echo " ".$prop->name.
":".$prop->type.
"(".
implode(", ", $details).
")".
($prop->refTo? " => ".$prop->refTo->name: "").
"\n";
}
}
// adding the properties to the focused entity
// we're doing it now, because according to the selected idiom
// the sequence of focused entity and properties may vary
if(sizeof($tmpProperties)>0 && $focus)
echo "RELATIONS:".sizeof(self::$relations)."\n";
foreach(self::$relations as $k=>$rel)
{
foreach($tmpProperties as $prop)
$focus->addProperty($prop);
if(!$rel)
continue;
echo " ".
$k.': '.
$rel->rel->name.' -> '.
$rel->focus->name.
($rel->uniqueRef? "[pk]": "").
"\n";
}
echo "Properties: ".$props."\n";
echo "Relations: ".sizeof(self::$relations)."\n";
}
}
/**
* Applies normalization rules to the currently analized structure.
* This method uses the Normalizer methods and properties to apply
* the required rules.
*/
public static function normalizeIt()
{
Normalizer::normalize();
self::$relations= array_filter(self::$relations);
self::$entities= array_filter(self::$entities);
}
/**
* Reset the properties of the analyst itself.
*/
public static function reset()
{
self::$entities = false;
self::$relations= false;
self::$entities = Array();
self::$relations= Array();
self::clearFocused();
}
/**
* Sweeps through all the matched expressions.
* @param Array $matches
*/
public static function sweep($matches)
{
// let's clear the Analyst memory as it uses static properties
self::reset();
// now we gotta analyze each valid expression
foreach($matches as $found)
{
$len= strlen($found[0]);
$expression= array_slice(Token::$words, $found[1], $len);
$tokens= array_slice(Token::$spine, $found[1], $len);
$struct= $found[0];
// let's analize it, now
// Analyst will store it on its own static structure
Analyst::analize($expression, $struct, $tokens);
}
self::clearFocused();
self::normalizeIt();
}
}
+210
Ver Arquivo
@@ -0,0 +1,210 @@
<?php
/**
* This file is part of theWebMind 3rd generation.
* Under Cortex/Analyst structure
*
* @filesource
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
/**
* Generic methods to be used by the Normalizer.
*
* @abstract Normal
* @package Cortex
* @subpackage Analyst
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
*/
abstract class Normal {
public static $oneByOne = Array();
public static $nByN = Array();
public static $oneByN = Array();
public static $focus = Array();
public static $predicate = Array();
/**
* Merges all the poperties from the $rel into the $focus
*
* @param MindEntity $focus The entity that will receive the other's properties
* @param MindEntity $rel The entity which will lose its properties
*/
public static function mergeProperties(MindEntity &$focus, MindEntity &$rel)
{
GLOBAL $_MIND;
if($_MIND->conf['use_prefix_on_merged_entities'])
{
foreach($rel->properties as $prop)
{
$prop->setName($rel->name.PROPERTY_SEPARATOR.$prop->name);
}
}
$focus->properties= array_merge($focus->properties, $rel->properties);
}
/**
* Merges the passed entities.
*
* Merges the $rel entity into the $focus entity, merging
* the properties and relations
*
* @param MindEntity $focus The main entity
* @param MindEntity $rel The weaker entity
* @return MindEntity
*/
public static function mergeEntities(MindEntity &$focus,
MindEntity &$rel,
MindRelation &$relation)
{
self::mergeProperties($focus, $rel);
Analyst::unsetRelation($relation->opposite);
Analyst::unsetRelation($relation);
Normalizer::redirectRelations($rel, $focus);
Analyst::removeEntity($rel->name);
return $focus;
}
/**
* Fixes 1:1 relations.
* It will fix the relations between the passed entities, as they
* will not be merged.
*
* @param MindEntity $focus The pointed entity
* @param MindEntity $rel The weaker entity
* @param MindRelation $relation The relation between
*/
public static function fixOneByOneRelation(MindEntity &$focus,
MindEntity &$rel,
MindRelation &$relation)
{
/*
* excluir a relação entre a mais forte e a mais fraca
* marcar a fk como pk
*/
Analyst::unsetRelation( Analyst::$relations[$rel->name.
PROPERTY_SEPARATOR.
$focus->name]);
Analyst::$relations[$focus->name.
PROPERTY_SEPARATOR.
$rel->name]->uniqueRef= true;
}
/**
* Gets the relevance amount for the passed entity.
*
* Gets the pontuation amount for the relevance an entity may have.
* It takes many directrizes to define how relevant an entity is.
* New parameters for such decision can be added here.
*
* @param MindEntity $entity The entity to be analysed
* @return int The relevance the entity has
*/
public static function relevanceAmount(MindEntity $entity)
{
GLOBAL $_MIND;
$pts= 0;
// if the entity has many properties, it might be important
if(sizeof($entity->properties) > $_MIND->conf['big_entities_length'])
$pts++;
// if the entity has many big fields
if(self::hasBigProperties($entity) > $_MIND->conf['big_fields_in_entity'])
$pts++;
// if it has many relations
if(sizeof($entity->relations) >= $_MIND->conf['relations_length'])
$pts++;
return $pts;
}
/**
* Sets the most and less relevant entities.
* Returns an array with the most relevant entity in the first position
* and the other entity in the second position
*
* @param MindEntity $en1
* @param MindEntity $en2
* @return Array
*/
public static function setByRelevance(MindEntity &$en1, MindEntity &$en2)
{
$en1Rlv= $en1->relevance;
$en2Rlv= $en2->relevance;
$en1Rlv+= self::relevanceAmount($en1);
$en2Rlv+= self::relevanceAmount($en2);
if($en1Rlv == $en2Rlv)
if(strlen($en1->name) > strlen($en2->name))
$en1Rlv++;
else
$en2Rlv++;
if($en1Rlv > $en2Rlv)
return Array($en1, $en2);
else
return Array($en2, $en1);
}
/**
* Verifies wether the entity has big properties or not.
*
* Verifies if the entity has properties classified as big.<br/>
* If yes, returns the number of big properties found, or
* false(0) if no big property has been found
*
* @param MindEntity $entity
* @return boolean|int The number of big properties, or false when none
*/
public static function hasBigProperties(MindEntity $entity)
{
GLOBAL $_MIND;
$bigFields= 0;
foreach($entity->properties as $prop)
if( $prop->size > $_MIND->conf['big_fields_size'] ||
$prop->type=='text')
$bigFields++;
return $bigFields;
}
/**
* Organizes the relations by its cardinalities.
*
* Organizes the relations between entities to each group,
* separating by n:n, 1:1 or 1:n
*
*/
public static function separateByRelationQuantifiers()
{
reset(Analyst::$relations);
while($rel= current(Analyst::$relations))
{
next(Analyst::$relations);
$relName = $rel->name;
$relOtherName= $rel->rel->name.
PROPERTY_SEPARATOR.
$rel->focus->name;
if(isset(Analyst::$relations[$relOtherName]))
{
$otherRel= &Analyst::$relations[$relOtherName];
Analyst::$relations[$rel->name]->opposite=
&Analyst::$relations[$otherRel->name];
Analyst::$relations[$otherRel->name]->opposite=
&Analyst::$relations[$rel->name];
// let's look for n/n relations
if($otherRel->max=='n' && $rel->max=='n')
{
self::$nByN[]= &Analyst::$relations[$rel->name];
}elseif($otherRel->max==1 && $rel->max==1)
{ // 1:1 relation
self::$oneByOne[]= &Analyst::$relations[$rel->name];
}else{
// useless re-definition
// if the relation was already specified as 1:n it doesn't
// need to be re-specified as n:1
Analyst::unsetRelation($otherRel);
}
}else{
self::$oneByN[]= &Analyst::$relations[$rel->name];
}
}
}
}
+310
Ver Arquivo
@@ -0,0 +1,310 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Normalizer components, within the Cortex/Analyst packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* Normalizes the data structure.
*
* Will normalize the data and entities structure
* applying rules and patterns. Thanks for
* Edgar F. Codd for all he created and wondered
* for the Relational Model
*
* @package Cortex
* @subpackage Analyst
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @filesource
*/
class Normalizer extends Normal{
public static $tmpEntities = Array();
public static $tmpRelations = Array();
/**
* Redirects all the relations between entities.
*
* Redirects all the relations that point to, or are pointed by the
* $from entity, to the $to entity.
*
* @param MindEntity $from Entity which will lose its references
* @param MindEntity $to Entity which will be reffered instead
*/
public static function redirectRelations(MindEntity &$from, MindEntity &$to)
{
foreach($from->relations as &$rel)
{
if(!$rel)
continue;
if($rel->focus->name == $from->name)
{
$rel->setFocus($to);
$rel->rename($rel->rel->name.
PROPERTY_SEPARATOR.
$rel->focus->name);
}else{
$rel->setRel($to);
$rel->rename($rel->focus->name.
PROPERTY_SEPARATOR.
$rel->rel->name);
}
}
}
/**
* Fixes the 1:1 relations, normalizing them
*/
public static function fixOneByOneRel()
{
if(sizeof(self::$oneByOne) == 0)
return true;
reset(self::$oneByOne);
$rel= current(self::$oneByOne);
foreach(self::$oneByOne as &$rel)
{
$rel= &Analyst::$relations[$rel->name];
if(is_null($rel) || is_null($rel->focus) || is_null($rel->rel))
continue;
// defining the focus
$entities= self::setByRelevance($rel->focus, $rel->rel);
self::$focus= $entities[0];
self::$predicate= $entities[1];
// let's check the minimun quantifiers
if($rel->min== 1 && $rel->opposite->min == 1)
{
// for 1:1 / 1:1 relations
self::mergeEntities(self::$focus, self::$predicate, $rel);
}elseif($rel->min== 0 && $rel->opposite->min == 0)
{
// for 0:1 / 0:1 relations
if(Analyst::isItWorthMerging(self::$predicate))
{
self::mergeEntities(self::$focus, self::$predicate, $rel);
}else{
self::fixOneByOneRelation(self::$focus,
self::$predicate,
$rel);
}
}else{
// for 0:1 / 1:1 relations
self::fixOneByOneRelation(self::$focus,
self::$predicate,
$rel);
}
}
}
/**
* Creates an extra entity to link multiple relations.
*
* Creates the entity to be used as a link between the
* other two entities due to an N:N relation
*
* @param MindRelation $rel
* @return MindEntity
*/
public static function &createNByNEntity(MindRelation &$rel)
{
$linkTable= false;
$relName= $rel->focus->name.
PROPERTY_SEPARATOR.
$rel->rel->name;
$relOtherName= $rel->rel->name.
PROPERTY_SEPARATOR.
$rel->focus->name;
if(isset(Analyst::$entities[$relName]))
$linkTable= &Analyst::$entities[$relName];
if(isset(Analyst::$entities[$relOtherName]))
$linkTable= &Analyst::$entities[$relOtherName];
if(!$linkTable)
{
$linkTable= new MindEntity($relName);
Analyst::$entities[$linkTable->name]= $linkTable;
}
return Analyst::$entities[$linkTable->name];
}
/**
* Create all the relations needed to fix n:n relations.
*
* It takes the $left and $right entities and set the
* $center to reffer to it. The $rel parameter is used
* to identifies characteristics from an original
* relation, like linkVerb or linkType.
*
* @param MindEntity $left
* @param MindEntity $center
* @param MindEntity $right
* @param MindRelation $rel
*/
public static function createNbyNRelations( MindEntity &$left,
MindEntity &$center,
MindEntity &$right,
MindRelation &$rel)
{
Analyst::addToFocus($left);
Analyst::addToFocus($right);
$relations= Analyst::addRelationToFocused( $center,
$rel->linkType,
$rel->linkVerb,
0,
'n',
true);
}
/**
* Fixes all the n:n relations
*/
public static function fixNByNRel()
{
foreach(self::$nByN as &$rel)
{
if(!$rel->treated)
{
$entity= self::createNByNEntity($rel);
$rel->opposite->treated= true;
self::createNbyNRelations($rel->focus,
$entity,
$rel->rel,
$rel);
}
Analyst::unsetRelation($rel);
Analyst::clearFocused();
}
}
/**
* Adds all the foreign keys to all the entities that
* may need it.
*/
public static function addFks()
{
GLOBAL $_MIND;
$fkPrefix= $_MIND->defaults['fk_prefix'];
foreach(Analyst::$relations as &$relation)
{
$propName= $fkPrefix.$relation->focus->name;
$entity= &$relation->rel;
if(!$entity->hasProperty($propName))
{
$fk= new MindProperty();
$fk ->setName($propName)
->setRequired(true)
//->setAsKey()
->setType('int')
->setRefTo($relation->focus);
if($relation->uniqueRef)
$fk->setAsKey();
$entity->addProperty($fk);
}else{
$entity ->properties[$propName]
->setRefTo($relation->focus);
}
}
}
/**
* Adds all the primary keys the entities will need.
*/
public static function addPks()
{
GLOBAL $_MIND;
$pkPrefix= $_MIND->defaults['pk_prefix'];
foreach(Analyst::$entities as &$entity)
{
if( sizeof($entity->properties) == 0
||
sizeof($entity->properties) != sizeof($entity->pks))
{
$propName= $pkPrefix.$entity->name;
if(!$entity->hasProperty($propName))
{
$pk= new MindProperty();
$pk ->setAsKey()
->setName($propName)
->setDefault(AUTOINCREMENT_DEFVAL)
->setRequired(true)
->setType('int');
$entity->addProperty($pk, true);
}else{
$entity->properties[$propName]->setAsKey();
}
}
}
}
/**
* Will set the primary and foreign keys to entities.
*/
public static function setUpKeys()
{
GLOBAL $_MIND;
Analyst::$entities= array_filter(Analyst::$entities);
Analyst::$relations= array_filter(Analyst::$relations);
self::addFks();
self::addPks();
}
/**
* Clears static properties setting them to their default value.
* Quite useful when used through a command line single session.
*/
public static function reset()
{
self::$oneByOne = false;
self::$oneByOne = Array();
self::$nByN = false;
self::$nByN = Array();
self::$oneByN = false;
self::$oneByN = Array();
self::$focus = false;
self::$focus = Array();
self::$predicate= false;
self::$predicate= Array();
}
/**
* Normalizes the known structure.
*
* It will apply the n:n and 1:1 rules, plus setting the
* foreign and primary keys to all the entities.
* Please, notice that there are rules to be followed here,
* such as:<pre>
* 1:1 to 1:1 relations will always merge entities
* 0:1 to 0:1 relations will always try to identify the less
* important and set it to point to the other entity
* setting its foreign key as a primary key
* 0:1 to 1:1 will decide if it should wether merge or fix the
* relation. It will decide it using the following
* parameters of decision:
* - number of properties: as many, less mergeable
* - number of relations: as less reffered,
* more mergeable
* - big properties: as many big properties,
* less mergeable
* n:n relations will generate an extra entity, altough,
* if the entity with that name already exists, it
* takes the existing one.
* If the antity ONLY has keys, no pk will be added.
* </pre>
*/
public static function normalize()
{
self::reset();
self::separateByRelationQuantifiers();
self::fixOneByOneRel();
self::fixNByNRel();
self::setUpKeys();
}
}
+36 -16
Ver Arquivo
@@ -1,59 +1,79 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Canonic, within the Cortex/Canonic packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* This class will take the content to be used, and take
* it to its canonical form.
* It extends the Inflect class, from the selected language
*
* @package cortex.analyst
* @author felipe
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Cortex
* @subpackage Canonic
*/
class Canonic{
public static $substantives= Array();
/**
* Takes a word to its canonic form(singular/male form)
* @param string$word
* Takes a word to its canonic form(singular/male form).
* @param string $word
* @return string
*/
public static function canonize($word)
{
$inflec= Mind::$currentProject['idiom']."\Inflect";
if(!$inflec::isSingular($word)) /* TODO: fix it*/
if(!$inflec::isSingular($word))
$word= $inflec::toSingular($word);
/*if(self::isFemale($word)) // demands more tests
// apparently, female substantives are brought to a wrong male form
$word= self::toMale($word);*/
return $word;
}
/**
* Brings all the words in the Array to their canonical form
* @param array $content
* Sweeps all the content and take all the substantives
* to their canonical form.
*
* @return Array
*/
public function sweep()
{
self::$substantives= false;
self::$substantives= Array();
$content= Mind::$content;
$newContent= Array();
// PAREI AQUI
//print_r(Mind::$content);
//echo "\ncanonic--------------------------\n";
Mind::$tokenizer= new Tokenizer();
$ignoreForms= Mind::$currentProject['idiom'].'\IgnoreForms';
$verbalizer= Mind::$currentProject['idiom'].'\Verbalizer';
$posVerb= false;
foreach($content as $word)
{
if($ignoreForms::shouldBeIgnored($word))
continue;
if(!Tokenizer::isQualifier($word) && !Tokenizer::isQuantifier($word))
{
if(strlen($word) > 1 && ($isVerb= $verbalizer::isVerb($word)))
if( strlen($word) > 1
&&
!isset(self::$substantives[$word])
&&
($isVerb= $verbalizer::isVerb($word))
)
{
// is a verb
$word= $verbalizer::toInfinitive($word);
}
else{
// is a substantive
$word= explode(':', $word);
$word[0]= Canonic::canonize($word[0]);
self::$substantives[$word[0]]= true;
$word= implode(':', $word);
}
}
+55 -21
Ver Arquivo
@@ -1,26 +1,40 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Syntaxer, within the Cortex/Syntaxer packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* Identifies and organizes the valid syntaxes on the content.
*
* This class will work with the tokenized strucure and
* the original code, due to identify patterns and apply
* any needed rules
* any needed rules.
* <pre>
* Legend:
* Q=May have, Must have
* S=Substantive
* V=Verb
* 0,N=Quantifiers
* O=Or
* C=Complement(like "of", or "de")
* C=Complement/Composite(like "of", or "de")
* A=Addition(like "," or "and"
*
* @author felipe
*</pre>
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Cortex
* @subpackage Syntaxer
*/
class Syntaxer {
public static $sintatics= Array();
/**
* Loads the file which has the list of avaliable sintaxes
* @static loadSintaticList
* Loads the file which has the list of avaliable sintaxes.
*/
public static function loadSintaticList()
{
@@ -36,11 +50,35 @@ class Syntaxer {
}
/**
* Sweeps the content to apply the rules and identify patterns
* @name sweep
* Fetches the identified composed substantives.
*
* Fixes the composed substantives(defined by the use of
* the "of" tokens defined into the qualifiers.xml of the current idiom)
*/
public function fetchComposedSubstantives()
{
while(preg_match(COMPOSED_SUBST,
Token::$string,
$matches,
PREG_OFFSET_CAPTURE))
{
$matches= $matches[0];
array_splice(Token::$spine, $matches[1], 3, Token::MT_SUBST);
array_splice(Token::$words, $matches[1], 3,
Token::$words[$matches[1]].
'_'.
Token::$words[$matches[1]+2]);
Token::$string= preg_replace(COMPOSED_SUBST, 'S', Token::$string, 1);
}
}
/**
* Sweeps the content to apply the rules and identify patterns.
*/
public function sweep()
{
// loading stintatic list: all the avaliable, allowed syntaxes
// formats, specified by the selected idiom
self::loadSintaticList();
// mounting the regular expression
@@ -48,25 +86,21 @@ class Syntaxer {
// let's find all the patterns that match
// that means that we'll find only expressions with valid syntax
$pattern= str_replace('S', 'S((( )?\,( )?S)?)+', $pattern);
// reminding that the pattern was dynamicaly created before
$pattern= str_replace('S', VALID_SUBST_SYNTAX, $pattern);
$this->fetchComposedSubstantives();
// finding the valid syntaxes
preg_match_all('/'.$pattern.'/',
Token::$string,
$matches,
PREG_OFFSET_CAPTURE);
// as we know it's only one block, we can use it straight
// as we know it's only one block, we can use it straightly
$matches= $matches[0];
foreach($matches as $found)
{
$len= strlen($found[0]);
$expression= array_slice(Token::$words, $found[1], $len);
$tokens= array_slice(Token::$spine, $found[1], $len);
$struct= $found[0];
// let's analize it, now
Analyst::analize($expression, $struct, $tokens);
}
return $this;
Analyst::sweep($matches);
return $matches;
}
}
+53 -21
Ver Arquivo
@@ -1,43 +1,68 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Token, within the Cortex/Tokenizer packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* The Token itself.
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Cortex
* @subpackage Tokenizer
*/
class Token
{
// Tokens to be used
// MT stands for MindTokenizer
// MS stands for MindSyntaxer
const MT_PERIOD = -2;
const MT_PERIOD = -2;
const MS_PERIOD = '.';
const MT_COMA = -1;
const MS_COMA = ',';
const MT_VOID = 0;
const MS_COMA = ',';
const MT_VOID = 0;
const MS_VOID = '';
const MT_VERB = 1;
const MS_VERB = 'V';
const MT_SUBST = 2;
const MS_SUBST = 'S';
const MT_NONE = 4;
const MS_NONE = 'N';
const MT_ONE = 8;
const MT_VERB = 1;
const MS_VERB = 'V';
const MT_SUBST = 2;
const MS_SUBST = 'S';
const MT_NONE = 4;
const MS_NONE = 'N';
const MT_ONE = 8;
const MS_ONE = 'N';
const MT_OR = 16;
const MS_OR = 'O';
const MS_OR = 'O';
const MT_MANY = 32;
const MS_MANY = 'N';
const MT_QMUST = 64;
const MS_MANY = 'N';
const MT_QMUST = 64;
const MS_QMUST = 'Q';
const MT_QMAY = 128;
const MS_QMAY = 'Q';
const MT_QMAY = 128;
const MS_QMAY = 'Q';
const MT_QNOTNULL= 254;
const MT_QKEY = 564;
const MT_QOF = 1024;
const MS_QOF = 'C';
const MT_QBE = 2048;
const MT_ANY = 4096;
const MS_ANY = '*';
const MT_QKEY = 564;
const MT_QOF =1024;
const MS_QOF = 'C';
const MT_QBE =2048;
const MS_QBE = 'B';
const MT_QBRAKE = -4;
const MS_QBRAKE = 'b';
const MT_ANY =4096;
const MS_ANY = '*';
public static $spine= Array();
public static $words= Array();
public static $string= '';
/**
* Identifies the word type and adds it to the structure.
* As the identified type, the word represents an assumed token.
* @param string $word
* @return string
*/
public function add($word)
{
$ignoreForms= Mind::$currentProject['idiom'].'\IgnoreForms';
@@ -123,6 +148,7 @@ class Token
if(Tokenizer::isQualifier('be', $word))
{
self::$spine[]= Token::MT_QBE;
self::$string.= Token::MS_QBE;
return;
}
if(Tokenizer::isQualifier('key', $word))
@@ -130,6 +156,12 @@ class Token
self::$spine[]= Token::MT_QKEY;
return;
}
if(Tokenizer::isQualifier('brake', $word))
{
self::$spine[]= Token::MT_QBRAKE;
self::$string.= Token::MS_QBRAKE;
return;
}
// we know these words are already on its
// canonic form, so, we can simply look for
// it on the list
+40 -14
Ver Arquivo
@@ -1,10 +1,22 @@
<?php
/**
* This file is part of TheWebMind 3rd generation.
*
* Tokenizer, within the Cortex/Tokenizer packages.<br/>
* Notice that, these packages are being used only for documentation,
* not to organize the classes.
*
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @license licenses/mind3rd.license
*/
/**
* This class will apply the most important tokens to be used.
* It also builds the main structure to compare it to avaliable
* sintatics. This structure is called SPINE
*
* @author felipe
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
* @package Cortex
* @subpackage Tokenizer
*/
class Tokenizer extends Token{
@@ -16,7 +28,7 @@ class Tokenizer extends Token{
public static $dataTypes= Array();
/**
* Parses a string into an array, splited by comas
* Parses a string into an array, splited by comas.
* @param Mixed $str
* @return Array The string splited by comas, ignoring a space after each coma
*/
@@ -62,6 +74,7 @@ class Tokenizer extends Token{
}
/**
* Loads the qualifiers into the class properties.
* This method loads and builds the structure required
* to use and identify the qualifiers, from a passed XML
*
@@ -80,17 +93,20 @@ class Tokenizer extends Token{
self::$qualifiers['of'] = self::parseByComa($xml->of);
self::$qualifiers['be'] = self::parseByComa($xml->be);
self::$qualifiers['coma'] = self::parseByComa($xml->coma);
self::$qualifiers['unique'] = self::parseByComa($xml->unique);
self::$qualifiers['brake'] = self::parseByComa($xml->brake);
return self::$qualifiers;
}
/**
* Loads the possible types to be accepted
* Loads the possible types to be accepted.
* @param SimpleXML $xml
* @return Array The parsed avaliable types
*/
public static function loadTypes($xml)
{
self::$dataTypes['varchar'] = self::parseByComa($xml->varchar);
self::$dataTypes['text'] = self::parseByComa($xml->text);
self::$dataTypes['char'] = self::parseByComa($xml->char);
self::$dataTypes['int'] = self::parseByComa($xml->int);
self::$dataTypes['float'] = self::parseByComa($xml->float);
@@ -102,6 +118,8 @@ class Tokenizer extends Token{
}
/**
* Identifies if the passed word is a quantifier.
*
* This method verifies whether the passed word is
* a valid quantifier in the passed list of quantifiers
* or if it is a quantifier, in case a list is not sent
@@ -124,6 +142,8 @@ class Tokenizer extends Token{
}
/**
* Verifies if the passed word is a qualifier.
*
* This method verifies whether the passed word is
* a valid quantifier in the passed list of qualifiers
* or if it is a qualifier, in case a list is not sent
@@ -149,9 +169,9 @@ class Tokenizer extends Token{
/**
* This method is called to load each possible modifier
*/
public static function loadModifiers()
public static function loadModifiers($modifiersSrc= false)
{
if(!file_exists('sintatics.list'))
if(!$modifiersSrc && !file_exists('sintatics.list'))
{
self::loadSintatics(fopen(Mind::$langPath.Mind::$currentProject['idiom'].
'/sintatics.list', 'rb'));
@@ -168,10 +188,10 @@ class Tokenizer extends Token{
self::loadQualifiers($qlf);
self::loadTypes($tps);
}else{
self::loadSintatics(fopen('sintatics.list', 'rb'));
$qnt= simplexml_load_file('quantifiers.xml');
$qlf= simplexml_load_file('qualifiers.xml');
$tps= simplexml_load_file('datatypes.xml');
self::loadSintatics(fopen($modifiersSrc.'sintatics.list', 'rb'));
$qnt= simplexml_load_file($modifiersSrc.'quantifiers.xml');
$qlf= simplexml_load_file($modifiersSrc.'qualifiers.xml');
$tps= simplexml_load_file($modifiersSrc.'datatypes.xml');
self::loadQuantifiers($qnt);
self::loadQualifiers($qlf);
self::loadTypes($tps);
@@ -180,15 +200,20 @@ class Tokenizer extends Token{
}
/**
* Sweeps the content.
*
* This method runs through all the words within Mind::$content
* and perform all verifications
*
* @return Array the spine, the whole structure of the abstracted text
*/
public function sweep()
public function sweep($content=false)
{
$cont= &Mind::$content;
if($content)
$cont= $content;
else
$cont= &Mind::$content;
// seek for data types
foreach(self::$dataTypes as $type=>$options)
{
@@ -199,9 +224,10 @@ class Tokenizer extends Token{
);
}
foreach($cont as $word)
// adding each word as its token
for($i=0, $j=sizeof($cont); $i<$j; $i++)
{
$word= strtolower($word);
$word= strtolower($cont[$i]);
$this->add($word);
}
@@ -70,7 +70,6 @@ class Shell
if (false === $command)
{
$this->output->writeln("\n");
break;
}
@@ -133,7 +132,6 @@ class Shell
protected function getHeader()
{
return <<<EOF
ZZZZZZZZZZZZZZZZZZZZZ
Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
At the prompt, type <comment>help</comment> for some help,
+1 -1
Ver Arquivo
@@ -34,7 +34,7 @@
public static function loadIgnoreList()
{
if(!file_exists('ignore.list'))
$fR= fopen(\Mind::$langPath.\Mind::$l10n->name.'/ignore.list', 'rb');
$fR= fopen(\Mind::$langPath.\Mind::$currentProject['idiom'].'/ignore.list', 'rb');
else
$fR= fopen('ignore.list', 'rb');
self::$ignoreList= Array();
+1
Ver Arquivo
@@ -11,6 +11,7 @@
-->
<root>
<varchar>string,characters,chars,varchar,description,desc,obs,observation</varchar>
<text>text,desc,description,obs,observation</text>
<char>char,character,c,letter,digit</char>
<int>int,integer,number</int>
<float>float,real,double,money,percentage,perc,precision</float>
+2 -1
Ver Arquivo
@@ -5,4 +5,5 @@ which
whom
whose
well
too
too
also
+3 -3
Ver Arquivo
@@ -12,10 +12,10 @@
<upper>ABCDEFGHIJKLMNOPQRSTUVXYZW</upper>
<special>."</special>
<numbers>1234567890</numbers>
<symbols>\/!@#$%*()_-+=,.'":>&amp;&lt;</symbols>
<symbols>\/!@#$%*()_-+=,.'":>&amp;&lt;|{}[]</symbols>
</validchars>
<replacements>
<from></from>
<to ></to>
<from>-</from>
<to >_</to>
</replacements>
</root>
+3
Ver Arquivo
@@ -14,4 +14,7 @@
<be>is,are</be>
<key>key,pk,index</key>
<coma>and</coma>
<unique>unique,single,only,alone</unique>
<!-- indicates a change of subject in the middle of a sentence -->
<brake>all,each,while,when,but</brake>
</root>
+1 -1
Ver Arquivo
@@ -36,7 +36,7 @@
public static function loadIgnoreList()
{
if(!file_exists('ignore.list'))
$fR= fopen(\Mind::$langPath.\Mind::$l10n->name.'/ignore.list', 'rb');
$fR= fopen(\Mind::$langPath.\Mind::$currentProject['idiom'].'/ignore.list', 'rb');
else
$fR= fopen('ignore.list', 'rb');
self::$ignoreList= Array();
+13 -6
Ver Arquivo
@@ -38,16 +38,20 @@ class Verbalizer {
'/vo$/' => 'ver',
'/i$/' => 'er',
'/am$/' => 'ar',
'/o$/' => 'ar',
'/ndo$/' => 'r',
'/(ado|ados|ada|adas)$/' => 'ar',
// these rules below are commented on theWebMind because
// we wont treat first person sentenses
/*'/o$/' => 'ar',
'/(.+)o$/' => '$1er',
'/(.+)a$/' => '$1er',
'/em$/' => 'er',
'/remos$/' => 'r',
'/emos$/' => 'er',
'/mos$/' => 'r',
'/ei$/' => '',
'/.ei$/' => 'ar',
'/(.)ei$/' => '$1er',
'/(.)ei$/' => '$1er',*/
'/(.+)a$/' => '$1er',
'/em$/' => 'er',
'/ou$/' => 'ar',
'/eu$/' => 'er',
'/ás$/' => '',
@@ -67,11 +71,14 @@ class Verbalizer {
'dei' => 'dar',
'dou' => 'dar',
'deu' => 'dar',
'farão' => 'fazer',
'fará' => 'fazer',
'dão' => 'dar',
'dará' => 'dar',
'darão' => 'dar',
'terem' => 'ter',
'terão' => 'ter'
'terão' => 'ter',
'amigo' => 'amigo'
);
/**
@@ -172,7 +179,7 @@ class Verbalizer {
public static function loadVerbs()
{
if(!file_exists('verbs.list'))
$fR= fopen(\Mind::$langPath.\Mind::$l10n->name.'/verbs.list', 'rb');
$fR= fopen(\Mind::$langPath.\Mind::$currentProject['idiom'].'/verbs.list', 'rb');
else
$fR= fopen('verbs.list', 'rb');
self::$verbs= Array();
+1
Ver Arquivo
@@ -11,6 +11,7 @@
-->
<root>
<varchar>string,characteres,varchar,descrição,desc,obs</varchar>
<text>text,texto,obs,observação,desc,descrição</text>
<char>char,caracter,caractere,letra,digito</char>
<int>int,integer,inteiro,dígito,número</int>
<float>float,real,double,dinheiro,percentagem,perc,porcentagem,precisão</float>
+5 -1
Ver Arquivo
@@ -5,4 +5,8 @@ os
aos
que
bem
também
também
tanto
somente
por
em
+3 -4
Ver Arquivo
@@ -12,11 +12,10 @@
<upper>ABCDEFGHIJKLMNOPQRSTUVXYZW</upper>
<special>áéíóúÁÉÍÓÚ"."ÀàÂâêÊîÎôÔûÛãÃõÕẽẼüÜçÇ</special>
<numbers>1234567890</numbers>
<symbols>\/!@#$%*()_-+=,.'":>&amp;&lt;</symbols>
<!--<symbols>\/!@#$%&*()_-+=[]{},.'"</symbols>-->
<symbols>\/!@#$%*()_-+=,.'":>&amp;&lt;|{}[]</symbols>
</validchars>
<replacements>
<from>áéíóúÁÉÍÓÚÀàÂâêÊîÎôÔûÛãÃõÕẽẼüÜçÇ</from>
<to >aeiouAEIOUAaAaeEiIoOuUaAoOeEuUcC</to>
<from>áéíóúÁÉÍÓÚÀàÂâêÊîÎôÔûÛãÃõÕẽẼüÜçÇ-</from>
<to >aeiouAEIOUAaAaeEiIoOuUaAoOeEuUcC_</to>
</replacements>
</root>
+5 -3
Ver Arquivo
@@ -7,11 +7,13 @@
This file describes the words that may be used as qualifiers
-->
<root>
<must>dever,precisar,demandar,necessitar</must>
<must>precisa,dever,precisar,demandar,necessitar</must>
<may>poder</may>
<notnull>obrigatório,not null,notnull,não nulo,requerido,required,necessário</notnull>
<of>de,do,da,dos,das</of>
<be>é,são,será,serão</be>
<be>é,são,será,serão,está,estar,estão,estarão,estará</be>
<key>chave,key,pk,indice,índice</key>
<coma>e</coma>
<coma>e,quanto</coma>
<unique>unico,único,isolado,isolada,isoladamente</unique>
<brake>todo,cada,qualquer,enquanto</brake>
</root>
+1 -1
Ver Arquivo
@@ -8,7 +8,7 @@
-->
<root>
<none>nada,nenhum,zero,0,nenhuma</none>
<one>um,uma,1,algum,alguma</one>
<one>um,uma,1,algum,alguma,único,única,unico,unica</one>
<many>uns,alguns,umas,algumas,muito,muita,muitos,vários,muitas,várias,diversos,diversas,n,m,x</many>
<or>ou,até,/</or>
</root>
+6
Ver Arquivo
@@ -1,4 +1,10 @@
SVS
SBVS
SQBVS
SQBVNONS
SQBVNS
SBVNONS
SBVNS
SQVS
SVNONS
SVNS
-1
Ver Arquivo
@@ -1143,7 +1143,6 @@ danificar
dançar
dar
dardejar
datar
datilografar
debandar
debater
+21 -1
Ver Arquivo
@@ -13,13 +13,16 @@
class Analyze extends MindCommand implements program
{
private $nameSpace= false;
public $autoCommit= 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')
new InputArgument('namespace', InputArgument::OPTIONAL, 'Analyze an specific namespace'),
new InputOption('commit', false, InputOption::PARAMETER_NONE, "Commit the result after analisys")
))
->setHelp(<<<EOT
This program will analyze your code, typed on your application directory, on all the files .mnd starting for the main.mnd
@@ -34,6 +37,7 @@ EOT
if(!parent::execute($input, $output))
return false;
$this->nameSpace= $input->getArgument('namespace');
$this->autoCommit= $input->getOption('commit');
$this->runAction();
}
@@ -44,6 +48,8 @@ EOT
return false;
if(isset($_REQ['data']['namespace']))
$this->nameSpace= $_REQ['data']['namespace'];
if(isset($_REQ['data']['commit']))
$this->autoCommit= $_REQ['data']['commit'];
$this->runAction();
}
@@ -57,6 +63,9 @@ EOT
}
$startingTime= microtime();
$startingTime= explode(' ', $startingTime);
$startingTime= $startingTime[1] + $startingTime[0];
Mind::$lexer= new Lexer();
$srcs= Mind::$currentProject['sources'];
@@ -77,13 +86,24 @@ EOT
if(!Mind::$syntaxer->sweep())
return false;
if($this->autoCommit)
{
MindProject::commit();
}
$endingTime= microtime();
$endingTime= explode(' ', $endingTime);
$endingTime= $endingTime[1] + $endingTime[0];
// do NOT print it if you have MANY entities, the webbrowser freezes
//print_r(Analyst::getUniverse());
echo Analyst::printWhatYouGet();
echo "Time: ".
number_format(((float)$endingTime) - ((float)$startingTime), 4).
"s\n";
$memory= ((memory_get_usage() / 1024)/1024);
$memory= number_format($memory, 2);
echo $memory."MBs\n";
return $this;
}
-68
Ver Arquivo
@@ -1,68 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Auth extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('auth')
->setDescription('Autenticate a user')
->setDefinition(Array(
new InputArgument('login', InputArgument::REQUIRED, 'Login to access')
))
->setHelp(<<<EOT
Sets the user with a password.
It is required to run most of the commands
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$pw= $this->getPassword(true);
echo "\n[OK] ".$input->getArgument('login')." autenticated\n";
}
/**
* function taken from: http://www.dasprids.de/blog/2008/08/22/getting-a-password-hidden-from-stdin-with-php-cli
* this method should read the user's password not showing any character of their password
* @param Booladn $stars if true, show an * for each typed char
* @return String password
*/
private function getPassword($stars = false)
{
// Get current style
$oldStyle = shell_exec('stty -g');
if ($stars === false) {
shell_exec('stty -echo');
$password = rtrim(fgets(STDIN), "\n");
} else {
shell_exec('stty -icanon -echo min 1 time 0');
$password = '';
while (true) {
$char = fgetc(STDIN);
if ($char === "\n") {
break;
} else if (ord($char) === 127) {
if (strlen($password) > 0) {
fwrite(STDOUT, "\x08 \x08");
$password = substr($password, 0, -1);
}
} else {
fwrite(STDOUT, "*");
$password .= $char;
}
}
}
// Reset old style
shell_exec('stty ' . $oldStyle);
// Return the password
return $password;
}
}
-22
Ver Arquivo
@@ -1,22 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Quit extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('Mind:exit')
->setDescription('Finishes the application')
->setDefinition(null)
->setHelp(<<<EOT
Finishes the application, leaving the console;
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
//exit;
}
}
-23
Ver Arquivo
@@ -1,23 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Quit extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('quit')
->setDescription('Finishes the application')
->setDefinition(Array())
->setHelp(<<<EOT
Finishes the application, leaving the console;
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
echo "Logging out...\n";
exit;
}
}
+48 -1
Ver Arquivo
@@ -13,8 +13,10 @@
$this
->setName('test')
->setDescription('Performs some tests on theWebMind')
->setDefinition(array())
->setRestrict(false)
->setDefinition(Array(
new InputOption('unit', '-u', InputOption::PARAMETER_NONE, 'Execute unit tests, also')
))
->setFileName('RunTest')
->setHelp(<<<EOT
Executes specific tests and report their results, about the system itself
@@ -24,9 +26,44 @@ EOT
private function action()
{
GLOBAL $_MIND;
$this->runStep1();
$this->runStep2();
$this->runStep3();
if($this->unitTestsAlso)
{
if(file_exists(_MINDSRC_."/Tests/bundle.list"))
{
if(!isset($_MIND->conf['phpunit-src']))
{
// TODO: put it into speaker classes, to use l10n messages
echo " You must specify where to find phpUnit classes\n";
echo " You can configure it on mind3rd/env/mind.ini ini file\n";
echo " changing the phpunit-src ini property\n";
return false;
}
// TODO: it doesn't work yet
/*
$unitTestsFolder= _MINDSRC_."/Tests/";
$unitTestsList= file_get_contents($unitTestsFolder."bundle.list");
$unitTestsList= explode("\n", $unitTestsList);
foreach($unitTestsList as $unitTests)
{
$unitTests= explode(' ', $unitTests);
echo "Applying Unit tests to ".$unitTests[1]."\n";
//include_once $unitTestsFolder.$unitTests[0];
echo shell_exec("phpunit ".$unitTestsFolder.$unitTests[0]);
break;
}
*/
}else
{
// TODO: send it to the speaker
echo "[Error] Unit Tests not fount in [root]/Tests\n";
return false;
}
}
}
public function runAction()
@@ -40,13 +77,23 @@ EOT
{
if(!parent::execute($input, $output))
return false;
$this->unitTestsAlso= $input->getOption('unit')? true: false;
return $this->runAction();
}
public function HTTPExecute()
{
GLOBAL $_REQ;
if(!parent::HTTPExecute())
return false;
$this->unitTestsAlso= (isset($_REQ['data'])
&&
isset($_REQ['data']['unit']))?
true: false;
return $this->runAction();
}
-30
Ver Arquivo
@@ -1,30 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class RunTest extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this
->setName('test')
->setDescription('Executes arbitrary DQL directly from the command line.')
->setDefinition(array())
->setHelp(<<<EOT
Executes arbitrary DQL directly from the command line.
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$this->runStep1();
}
private function runStep1()
{
Mind::message('Autoloader', '[OK]');
return true;
}
}
-22
Ver Arquivo
@@ -1,22 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Clear extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('clear')
->setDescription('Clears the console')
->setDefinition(array())
->setHelp(<<<EOT
Clears the console
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
system('clear');
}
}
-32
Ver Arquivo
@@ -1,32 +0,0 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class CommandName extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('Mind:commandName')
->setDescription('CommandDescription')
->setDefinition(array(
new InputArgument('arg1', InputArgument::REQUIRED, 'ArgDescription.'),
new InputOption(
'Option', null, InputOption::PARAMETER_REQUIRED,
'Description of the option',
'object'
),
new InputOption(
'first-result', null, InputOption::PARAMETER_REQUIRED,
'The first result in the result set.'
)
))
->setHelp(<<<EOT
Executes arbitrary DQL directly from the command line.
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
}
}
-89
Ver Arquivo
@@ -1,89 +0,0 @@
<?php
require(_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Shell.php');
require(_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Application.php');
require(_MINDSRC_.'/mind3rd/API/external/Symfony/Component/Console/Command/Command.php');
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
$app= new Symfony\Component\Console\Application('teste');
$app->addCommands(Array(
new RunTest(),
new Quit(),
new Auth(),
new Clear()
));
$helperSet= false;
$helperSet = ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet();
$app->setHelperSet($helperSet);
include_once('external/Symfony/Component/Console/Shell.php');
$sh= new external\Symfony\Component\Console\Shell($app);
$sh->run();
/**
* This file receives the shell call for a program,
* and parses its parameters, calling the program from the API
*
*/
/*
function shellExecute($command)
{
GLOBAL $_MIND;
readline_completion_function('mmindAutoComplete');
if(!is_array($command))
$command= explode(' ', $command);
$program= array_shift($command); // the first parameter is the program itself
try
{
$program= new $program($command);
//echo "\n";
}catch(Exception $e){
print_r($e->getMessage());
}
}
$fp = fopen("php://stdin", "r");
$in = '';
if(isset($params[0]))
{
if($params[0]== 'help' || $params[0]== '-h' || $params[0]== '--help')
{
new help();
exit;
}elseif($params[0]== '-u' && isset($params[1]))
{
new autenticate(Array($params[1]));
}
}else
new clear();
echo "Welcome to mind3rd:\nType help to see the help content\n";
while($in != "exit")
{
if(!isset($_SESSION['login']))
echo "mind > ";
else
echo $_SESSION['login'].'@mind > ';
$in=trim(fgets($fp));
if($in!='exit' && trim($in)!='')
{
shellExecute($in);
}
}
new clear();
exit;
*/
-78
Ver Arquivo
@@ -1,78 +0,0 @@
<?php
/**
* This file corresponds to the bootstrap.
* Every requisition should pass here
* This file decides which environment will be used
* and also some permissions, starting some environmental
* variables, such as language for localization
*/
session_start();
function __autoload($what)
{
GLOBAL $_MIND;
$what= preg_replace("/[ '\"\.\/]/", '', $what);
if(file_exists(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'))
{
include(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php');
return true;
}
if(strpos($what, '\\')>=0)
{
$what= explode('\\', $what);
$what= array_pop($what);
}
$dirs= Array(
_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/'
);
for($i=0; $i<sizeof($dirs); $i++)
{
if(file_exists($dirs[$i].$what.'.php'))
{
require_once($dirs[$i].$what.'.php');
return true;
}
}
echo " [ERROR] Class not found: ".$what."\n";
exit;
return false;
}
/*
function __autoload($class)
{
GLOBAL $_MIND;
$class= preg_replace("/[ '\"\\\.\/]/", '', $class);
if(!isset($_SESSION['auth']) && $class != 'autenticate' && $class != 'help' && $class != 'clear')
{
$_MIND->write('not_allowed');
throw new Exception('');
return false;
}
$f= _MINDSRC_.'/mind3rd/API/programs/'.$class.'.php';
if(file_exists($f) && !class_exists($class))
require $f;
else{
$f= _MINDSRC_.'/'.$class.'.php';
if(file_exists($f) && !class_exists($class))
require $f;
else{
throw new Exception($_MIND->write('shell_no_such_file', false));
return false;
}
}
return true;
}*/
require('interfaces/program.php');
require('classes/Mind.php');
if(isset($_SERVER['argv']))
{
$params= $_SERVER['argv'];
array_shift($params);
}
$_MIND= new Mind();
if($_REQ['env']=='shell')
include('shell.php');
else
include('http.php');
+29 -9
Ver Arquivo
@@ -6,12 +6,32 @@
*/
// REGULAR EXPRESSIONS
define('PROP_DETAILS', "/\(.*/");
define('PROP_DEFAULT', "/\".*\"/");
define('PROP_DEFEXEC', "/(^(\"=)|(\"exec\:))|(\"$)/i");
define('PROP_SIZE', "/\d+(\.?\d+)/");
define('COMA_SEPARATOR', '/\s/');
define('SINGLE_COMMENT', '/\/\/.+\n/');
define('MULTILINE_COMMENT', '/\/\*.+?\*\//');
define('NEW_LINE', "/\n/");
define('EXEC_STRING', 'exec:'); // equal(=) is also acceptable
define('PROP_DETAILS', "/\(.*/");
define('PROP_DEFAULT', "/(?<!\\\)\".+?(?<!\\\)\"/");
define('PROP_OPTIONS', "/\{(.+?)\}/");
define('PROP_OPTIONS_CLEAR', "/^\{|\}$/");
define('PROP_DEFEXEC', "/(^(\"=)|(\"exec\:))|(\"$)/i");
define('PROP_SIZE', "/\d+(\.?\d+)/");
define('COMA_SEPARATOR', "/\s/");
define('SINGLE_COMMENT', "/\/\/.+\n/");
define('MULTILINE_COMMENT', "/\/\*.+?\*\//");
define('NEW_LINE', "/\n/");
define('EXEC_STRING', "exec:"); // equal(=) is also acceptable
define('VALID_SUBST_SYNTAX', "S((( )?\,( )?S)?)+");
define('COMPOSED_SUBST', "/SCS/");
define('FIX_PROP_NAME', "/\\\|\,|\./");
// addresses
define('PROJECTS_DIR', '/mind3rd/projects/');
define('MODELS_DIR', '/mind3rd/API/models/');
define('ABOUT_INI', '/mind3rd/env/about.ini');
define('DEFAULTS_INI', '/mind3rd/env/defaults.ini');
define('MIND_CONF', '/mind3rd/env/mind.ini');
define('L10N_DIR', '/mind3rd/API/L10N/');
define('LANG_PATH', '/mind3rd/API/languages/');
// other constants
define('QUANTIFIER_MAX_MAX', 'n');
define('QUANTIFIER_MAX_MIN', 1);
define('PROPERTY_SEPARATOR', "_");
define('AUTOINCREMENT_DEFVAL', -101234567890);
+21 -13
Ver Arquivo
@@ -9,6 +9,21 @@
exit;
}
Mind::autoloadRegisterPath(Array(
_MINDSRC_.'/mind3rd/API/external/',
_MINDSRC_.'/mind3rd/API/interfaces/',
_MINDSRC_.'/mind3rd/API/programs/',
_MINDSRC_.'/mind3rd/API/L10N/',
_MINDSRC_.'/mind3rd/API/classes/',
_MINDSRC_.'/mind3rd/API/cortex/Lexer/',
_MINDSRC_.'/mind3rd/API/cortex/tokenizer/',
_MINDSRC_.'/mind3rd/API/cortex/canonic/',
_MINDSRC_.'/mind3rd/API/cortex/syntaxer/',
_MINDSRC_.'/mind3rd/API/cortex/analyst/',
_MINDSRC_.'/mind3rd/API/cortex/Darwin/',
_MINDSRC_.'/mind3rd/API/languages/'
));
function __autoload($what)
{
GLOBAL $_MIND;
@@ -25,19 +40,9 @@
$what= explode('\\', $what);
$what= array_pop($what);
}
$dirs= Array(
_MINDSRC_.'/mind3rd/API/external/',
_MINDSRC_.'/mind3rd/API/cortex/Lexer/',
_MINDSRC_.'/mind3rd/API/interfaces/',
_MINDSRC_.'/mind3rd/API/programs/',
_MINDSRC_.'/mind3rd/API/L10N/',
_MINDSRC_.'/mind3rd/API/classes/',
_MINDSRC_.'/mind3rd/API/cortex/tokenizer/',
_MINDSRC_.'/mind3rd/API/cortex/canonic/',
_MINDSRC_.'/mind3rd/API/cortex/syntaxer/',
_MINDSRC_.'/mind3rd/API/cortex/analyst/',
_MINDSRC_.'/mind3rd/API/languages/'
);
$dirs= Mind::$autoloadPaths;
for($i=0; $i<sizeof($dirs); $i++)
{
if(file_exists($dirs[$i].$what.'.php'))
@@ -55,6 +60,9 @@
return true;
}
// cortex has a special treatment
echo " [ERROR] Class not found: ".$what."\n";
return false;
}
+9 -3
Ver Arquivo
@@ -2,8 +2,8 @@
; it should represent your preferences about how mind should behave
;
; the default idiom
default_human_language=pt
default_human_languageName=pt
default_human_language=en
default_human_languageName=en
; default timezone
timezone=America/Sao_paulo
; the default programming language
@@ -25,4 +25,10 @@ ask_about_doubts=on
show_decisions=on
show_tips=on
; you can also enable the use of plugins
plugins=on
plugins=on
; default identifier of primary key properties
pk_prefix="pk_"
; add the pk_prefix to properties that were defined as key, manuyally?
add_pk_prefix_to_all_keys=on
; default identifier of foreign key properties
fk_prefix="fk_"
+19
Ver Arquivo
@@ -0,0 +1,19 @@
; This file describes options theWebMind will use
; to set up its own environment
;
;
; specify where theWebMind will find the phpunit classes
phpunit-src= "/usr/bin/phpunit"
; what is the minimun size of a field, that may identify it as a big
; field or not
big_fields_size= 255
; how many big properties should identify an entity as important
big_fields_in_entity= 1
; how many fields should define an entity as a long entity or smal entity
big_entities_length= 4
; how many relations should define an entity as an importante entity
relations_length= 4
; should use the entity's name as prefix on merged entities
use_prefix_on_merged_entities= true
; how many points should consider an entity worth of mergin or not
merging_amount_pts=2
+49 -14
Ver Arquivo
@@ -1,16 +1,51 @@
aluno tem professor
//professor tem piça
professor tem aluno
aluno tem foto:arquivo(xx)
/*
A universidade tem muitos alunos. Aluno tem nome:varchar, matrícula:int,
cpf:int e identidade:int, endereço:varchar,
telefone:int, data de nascimento:date, sexo:char, graduação:int.
Cada aluno pode estar matriculado em vários cursos sendo que cada curso pode ter muitos alunos matriculados.
Aluno também tem as disciplinas em que está matriculado, lembrando que cada disciplina terá diversos alunos inscritos.
blablabla
mimimi
xxx
blabelaebamimi
/*
registro tem uma id.
id tem um registro.
id tem codigo:int e nro:int.
registro tem data:date e descrição:text.
registro2 tem uma id2.
id2 tem um registro2.
id2 tem codigo2:int e nro2:int.
registro2 tem data2:date e descrição2:text.
registro3 tem um ou uma id3.
id3 tem nenhum ou um registro3.
id3 tem codigo3:int e nro3:int.
registro3 tem data3:date e descrição3:char(100).
*/
aluno tem pai, mãe e papagaio.
aluno tem nome:caractere(128, obrigatório, não nulo, "josé's da conceição")
pai tem \pilha.
mae tem nome, idade e sexo:char().
mãe tem nome, idade e sexo.
/*
Algumas aplicações precisam se referenciar à cidade, estado e CEP do
endereço do estudante. Cada estudante pode ser identificado pelo
número de sua matrícula.
Cada departamento é descrito por um nome, um código, um telefone.
Tanto o nome como o código têm valores únicos para cada
departamento. Cada curso tem um nome, uma descrição, um código,
um número de horas de aula semestrais e um departamento
responsável. O valor do código é único para cada curso.
Cada disciplina tem um nome,um código,um número de horas-aula
semanais, e uma ou mais disciplinas como pré-requisito. O valor do
código e do nome é único para cada disciplina.
Para cada disciplina de um curso podem ser abertas uma ou mais turmas.
Cada turma é caracterizada por um código, o número do ano e do
semestre em que ela se realiza, o professor responsável, e o(s)
número(s) da(s) sala(s) que ela utiliza.
A universidade emprega professores e funcionários técnicoadministrativos. O funcionário tem uma matrícula que o identifica
dentro da universidade. Além disso devem ser guardados o nome,
endereço, sexo, documentos pessoais, telefone(s) de contato, nome e
data de nascimento dos seus dependentes, departamento ao qual está
vinculado e data de admissão. Um professor pode ministrar várias
disciplinas. Deve-se conhecer a capacitação do professor: congressos,
cursos de pós-graduação, cursos de extensão e trabalhos publicados.
Deve-se prover um relatório contendo a grade de avaliação dos alunos por
turma contendo as suas notas. Deve-se prover também o histórico
escolar contendo cada disciplina já cursada pelo aluno dentro de um
curso (com o ano,/semestre em que foi cursada e o resultado final).
*/
+3 -1
Ver Arquivo
@@ -1,5 +1,7 @@
auxiliary.org-netbeans-modules-php-phpdoc.target=/var/www/mind/docs/PHPDoc
copy.src.files=false
copy.src.target=/var/www/mind
index.file=index.php
debug.url=DEFAULT_URL
index.file=docs/ide/index.php
run.as=LOCAL
url=http://localhost/mind/