grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Grammatica-users] Lookahead feature?


From: Andres Hohendahl
Subject: RE: [Grammatica-users] Lookahead feature?
Date: Thu, 20 Oct 2005 13:52:14 -0300

Hi there!

I am now working on a modification of the Grammatica Parser-Generator under
C# to allow this:
Get (read) a Full EBNF grammar file (on the fly) then parse it (with a
EBNF-grammatica generated parsed) and generate a Parse Tree.

NOTE:
I've successfully ported the Grammatica-Core Parse's towards C# (.net)
Also I modified the Run-time library to be more C# friendly while
maintaining full compatibility towards the grammatical generated code. I
think I've improved readability and may be some performance.
(Per: do you want me to send in the source's)?

...
Then take this Parser, and scan an input text (implementing this grammar)
and generate an interpreted representation of this input fed from the
grammar-parser tree into a new hierarchical tree to represent the
"parsed/compiled/acquired" data from the input.

This idea came from the fact that many tokens/words (in natural languages)
has multiple possible functions, and thus generate ambiguous grammar's.
So this is the point: let's generate a tree of the input tokens, with all
the (possibilities) as branches.
Then generate a (recursive) method of: 
1 Taking all possible token-sequence's and feeding them into the parser's
tree, to see if they succeed. After each success, the system will generate a
"possible representation list of token's" along with a "ponderation" in
which each word who has several "functions" has a value associated to the
each function (creating a most-used hierarchy). Then all "values are added,
and the final result will be a ordered (probabilistically) list of the
possible input token's values (functions) thet responds to thei
deterministic grammar.

Thoughts are welcome

Andres
----------------
By the Way, Per:

Is there any grammar translation tool to-from EBNF(grammatica's) <->
EBNF(std) / YACC / BRISON / etc. (standard) 
Because there are a lot of tools out there (IE. The Gold-Parsed) to
debug/test your grammars graphically... but they don’t use this EBNF syntax,
and the conversion must be made by hand (quite tedious)!

url-Links are welcome..too!

---------------------------------------------------------------------------
Here is a grammar file in which I have been wonkin in, and the "words" will
be fed into pre-tagged as follows, for the phrase "this word is red"

This.AR word.SN is.VB red.AD

I have some problems in representing this ambiguous (Spanish) grammar, can
anyone help me out?

HERE IT IS:

-------------------------------

/*
 * Gramática Sintaxis Española 
 */
%header%
GRAMMARTYPE = "LL"
DESCRIPTION = "Spanish grammar for SINTACTIC-spanish recognition"
AUTHOR      = "AndySoft"
VERSION     = "1.0"
DATE        = "19 Oct 2005"
LICENSE     = ".."
COPYRIGHT   = "All rights.. hmmm.. reserved.?"

%tokens%

LEFT_BRACKET = "["
RIGHT_BRACKET = "]"
WHITESPACE = <<[ \t\n\r]+>> %ignore%

// POS (Part Of Speech )
//      Auxiliary Verb (haber, ser, estar) ' Copulative ' no Direct/Indirect
Object
VX =  <<\w+\.VX\w*>>
//      Verb Transitive (need direct object)
VT =  <<\w+\.VT\w*>>
//      Verb Intransitive (Reflexive) don't need direct object
VI =  <<\w+\.VI\w*>>
//      Verb (Transitive or Intransitive)
VB =  <<\w+\.VB\w*>>
//      Verb Participio
VP =  <<\w+\.VP\w*>>
//      Verb Gerund
VG =  <<\w+\.VG\w*>>
//      Verb Suplemento
VS =  <<\w+\.VS\w*>>
//      Adverb
AV =  <<\w+\.AV\w*>>
//      Adverbio de Cantidad
AC = <<\w+\.AC\w*>>
//      Adjective
AJ =  <<\w+\.AJ\w*>>
//      Noun singular or Mass
NN =  <<\w+\.NN\w*>>
//      Proper Noun, singular
SN =  <<\w+\.SN\w*>>
//      Noun, Numeral
NU = <<\w+\.NU\w*>>
//      Article
AR = <<\w+\.AR\w*>>
//      Personal Pronoun
PP = <<\w+\.PP\w*>>
//      Possessive Pronoun
PO = <<\w+\.PO\w*>>
//      Demonstrative Pronoun
PD = <<\w+\.PD\w*>>
//      Interrogative Pronoun
PI = <<\w+\.PI\w*>>
//      Preposition
PR = <<\w+\.PR\w*>>
//      Conjunction
CJ = <<\w+\.CJ\w*>>
//      Interjection
IJ = <<\w+\.IJ\w*>>
//      Pronominal
PL = <<\w+\.PL\w*>>
//      Un-Known
UK = <<\w+\.UK\w*>>
// Special reflexive particle "se"
SE = <<\w+\.SE>>

// SINTAGMAS (construcciones)
%productions%

// Frase
// Fras = Orac | Orel | SNom ;
// Oración
Orac    = [ SNom ]  SVer ;
// Oracíon de Relativo
Orel    =  Orac ;
// Oración Interrogativa
// Oint = Orac ;

// Sintagma Nominal
SNom    = [ Det ]  SNuc ;
// Nucleo Nominal
SNuc    =  ( NN | SN | NU )  [ CNuc ] ;
//      un nombre común 
//      un nombre propio (y entonces no aparece ningún determinante en Det) 
//      un pronombre personal (y entonces no aparece ningún determinante en
Det) 
//      cualquier elemento sustantivado (infinitivos aislados, adjetivos,
oraciones subordinadas //       sustantivas, adverbios...), que generalmente
irá precedido por un artículo.
// Determinante
Det     =   AR ;
//      artículo 
//      demostrativo 
//      indefinido 
//      numeral 
//      posesivo 
//      distributivo 
//      interrogativo 
//      exclamativo
//  Complemento del Núcleo
CNuc    =  (  SAdj | SPre |  SNom |  Orel ) [ CNuc ] ;
//      un sintagma adjetival 
//      un sintagma preposicional 
//      un SN en aposición 
//      una oración de relativo


// Sintagma Adjetival
SAdj    = [ AC ] NAdj [ CAdj ] ;
// Núcleo Adjetival
NAdj    =   AJ  ;
// Complemento del Adjetivo
CAdj    =  SPre ;


// Sintagma Verbal
SVer    =  ( VTr CDir ) | ( VI CInd ) | ( VS CCir ) ;
VTr     = VT | VT VI ;
// Si el verbo es transitivo: un SNom, un SPre o una oración en función de
Complemento Directo. 
CDir    = SNom | SPre | Orac ;
// Si el verbo es copulativo: cualquier sintagma (salvo SVer) o una oración
en función de Atributo.
CInd    = ( SNom | SAdv | SPre | Orac ) [ CInd ] ;
// Si el verbo es de suplemento: un SP (que contenga un SNom o una oración)
en función de Suplemento 
CCir    = [ PR ]  ( SNom | Orac ) ;
// Verbo Compuesto
VComp = [ VI ] VT [VI] ;

// Sintagma Adverbial
SAdv    = [ AC ] NAdv ;

// Núcleo (Adverbio/forma Adverbial)
NAdv    =  AV  [ CAdv ] ;
// Complemento del Adverbio
CAdv    = SPre ;

// Sintagma Preposicional  
SPre    = [ PR ]  ( SNom | SAdv |  Orac | SPre ) ;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]