Web-Mind-Language

From TheWebMind.org Docs

Jump to: navigation, search

The WML(Web Mind Language) is based on NLP(Natural Language Processing) concepts, an area of computer science which studies the integration between machine languages and the human(natural) languages.
WML is the first language considered a discrete programming language, and for that reason, it seems very similar to natural languages, such as Portuguese, English, Spanish, etc., by following a few specific rules of syntax.

Contents

Sintax

On its sintax, the WML uses as default the conceptual model of relations and entities of databases.
This way, coding in WML means being very close to the conceptual analysis of a software project.
Based on ER models, you are provided with a platform that creates entities and relations in the WML syntax.
in your WML, each entity will be a table and every relation will have rules and optimization applied.
The code written in WML is self-explanatory, in other words, the logic and the structure of your system are generated in a "natural" form, as if you were describing your system.
Each command is identified by the use of a period(.) or the charactere ";" in the end.

After abstracting the knowledge of the system through this semi-natural code, Mind's engine will be able to generate:

  • Relational Data Base structure
  • Object Oriented Structure
  • Diagrams and documentation
  • HTML forms (views)
  • Many other outputs, as you configure plugins and modules

Following an example of its basic syntax in english:

each teacher has 1 or n student.

With this code, the Mind's engine will interpret this:

teacher and student as Entities

has as a verb keyword, a link

1 and n as the relation

Entities

Making an analogy with the traditional software development and WML, entities may be either Tables in a database or a Class, in an OO system.
In the example, we'll have 2 tables in our database: teacher and student.
These tables will have a 1 to many relation (to each teacher, we will have 1 or n student)
TheWebMind will take care of database keys and relations. The image under this text shows the ER diagram generated by the exemplified code:
File:teacher_student.jpg

The following code was used for this example:
1. student has many teacher.
2. and each teacher has one or many student.
3. we also know that student has a name:char(60, needed).
4. every teacher has a name:character(60, not null) too.
5. we might consider: every student has a mother.

WML identifies the entities in the code using the Mind-Natural-Entities 1.0 algorithm.
Use the character "#" to indicate when an entity must be abstract, as treated by the module. It's enough to define it only once to set it as an abstract entity.

person is a #human.
human has height:real(5.2).

Human will become an abstract entity.

Attributes

TheWebMind can identify attributes by using the Mind-Natural-Attributes-1.0 algorithm. Remember, this identification is based on the selected and loaded configuration file or develop the project into theWebMind. This file might change due to the interaction with different languages or dialects, traditions, etc. These files may be changed by the developer and we're working on "teaching" theWebMind new things as it gets used, then, it will be able to learn and to adapt itself to the developers who use it.

  • Types and instructions

There is a sintax to identify attributes in entities. This sintax looks for a verb in your expression, an element followed by ":", and then a valid identifier. After this, there must be a "( )" with an specification about the attribute in between the parentheses.

E.g.:
student has name:varchar(60, needed).

Notice that the details about this attribute are separated by commas, one after the other inside the parentheses. There is not an specific order to them. Name will be an attribute tht the entity student has, this will be not null, of type varchar with the size 60.

  • Comments

You can set comments to properties by using double forward slash in the end of the line, like a normal one-line comment:

student has name:varchar(60, needed) // the name of they student.

"the name of they student" will be the comment. Depending on the module you choose to generate the project, it may be used like aliases or labels to fields. Not only for comments in your database (if your chosen database supports it) or inside theWebMind.

  • Masks

You can also specify a mask to each attribute. This parameter must be inside "[ ]". If your mask uses either "[" or "]" These should be escaped with a "\".

E.g.:
student has birthday:date(8, [99/99/9999]).
NOTE: This mask will be shown to you from theWebMind and will be passed to the chosen module, but theWebMind
will NOT use it or check it. To know how the chosen module works with masks and what patterns it expects you to use, check its documentation. The modules can use this mask either to validate on the server-side before saving any data into your database, or even to validade fields on the client-site before submiting forms, using JavaScrit, for example. It depends on the way the module uses this mask.
  • Attribute options

We can specify different options to an attribute. The module can generate codes to verify them before saving or show only the valid options on the client-side. The sintax:

{optionValue=Label of this optione|secondOptionValue=Label of this other option}

We use "|" to separate each option, while the "=" character tells what the option value is and what is the text to be shown.

E.g.:
student has sex:char(1, {F=Female|M=Male}).

Here, the values "F" and "M" will be sent to database, while Female and Male will be the options your client will see. Thus, the module can implement a validation to accept ONLY these two options before saving it into the database.

  • Default values

TheWebMind identifies default values simply by the use of ". It also can be escaped with "\" if necessary.

E.g.:
subscriber has name:text(-1, "anonymous").

Here, anonymous will be saved everytime the field is null.

Tip: we can use a number less than 0 to indicate infinite fields, if the chosen database accepts it, like the fieldtype text.

If you want to use a method your DBMS offers, or to set a value which is NOT a string as a default value, you can use the keyword "Exec:", exactly like this (case sensitive).

E.g.:
student has subscribing_date:date("Exec:now()").

In this case, when the field subscribing_date is null the function "now()" will be called in the database. We can also do that with numbers:

Student has age:integer("Exec:0").

The number 0 will be the default value. Note that the Exec: command must me exactly like it it. It must be the first word and it is case sensitive. If you use " Exec:" or "exec:", the default value will be handled as a string. We can set an attribute as hidden, or to be handled differently by the module. To do so, we use the "#" character before the name of each attribute.

student has #email:varchar(200).

Subtypes

Sometimes we need to use the same type and features in many different attributes of entities and we don't want it to be a new entity. For these cases, we indicate the creation of subtypes.

"A subtype has the scope of a type with its features in a neutral form, to be re-used easily."

The specification of a subtype is the use of a "$" in the begining of it, followed by a valid signature of an attribute.

E.g.:
$sex:char(1, not null, {F=Female|M=Male}).

We can use it as a valid type without the "$" on it.

Example of use:
student has sex:sex().
teacher has sex:sex().
worker has sex_definition:sex().

The three entities above have separately an attribute of type char with size 1, needed and with the two pre-defined options.

Aggregation

The Mind2.0 engine uses a file with information about the language(idiom) to understand the code. Based on that, there are two special types of relation, the "belongs" and "obligations". They are especially identified by affirmative verbs or for probabilities, like "is", "may be" or "may have".

Obligation is used when an entity refers to another to be rendered as such. For example:

person is a human.

In this case, the module will recieve the information that these two entities in the database are the same entity in a OO universe. Then, the class person will extend the class human inheriting all its properties and methods. Depending on the module you've chosen the class human may be set as abstract, once person is now a more usable class. Meanwhile, entities that belong to others will be simple extentions of them.

E.g.:
person may be a teacher.
person might be a student.

Now, both teacher and student will extend person, but person does not need to be one of them. In the database, what we see is an aggregation.

Teaching theWebMind

The webMind can learn with the developer, that is one of the premises the Discrete programming language must to match. The way theWebMind can learn with you is asking you about details, details you used and it couldn't recognize. To do so, Mind will ask you for new verbs, quantifiers or types that it didn't know. At the debug panel, you can see all the notices, steps, warnings and errors theWebMind found during the "compilation" of your instructions. There you will see all the warnings, in which theWebmind may be asking you something. By clicking the little "engine" icon in the right side of the message, you'll see the possibilities you have to help theWebMind how to understand what you need. With this, Mind will learn this to the next times, do not need to ask you about them. File:adding-verb-thewebmind.png


Personal tools