Augmented Syntax Diagrams - Examples
Copyright 2003-2021 James A. Mason
page last updated on 2021 Jun 4
Examples from a "Real World" application:
These are screen shots from ASDEditor of several components of an
ASD grammar that was used successfully to translate Toronto,
Ontario, parking bylaws from English to a coded form suitable for
use in computer applications:
Miscellaneous examples - example grammars
and applications that do not specifically involve the English
language:
- Arithmetic expressions
-
a grammar for expressions consisting of numbers, arithmetic
operations,
parentheses and brackets, and an application that uses the
grammar to
parse and evaluate such expressions
English examples - example
grammars and
applications for parts of the English language:
- 2010 May 13 and after: CardWorld,
a
small example of English-language understanding including
syntax,
semantics and pragmatics.
- 2005 Apr 20: A revised subset of the npX grammar and
some new semantic classes are described in and accessible from
page SemanticValuesClassHierarchy.
They
demonstrate
how
meaning
representations
can
be
computed
for
English
phrases in a way that is more sophisticated than is possible
with only the basic tools provided in the asd and asdx packages.
- 2003 Aug 12: npX
- a large
modularized grammar for English noun phrases. This grammar
is
defined
in 18 separate modules and provides a good example for testing
ASDEditor,
ASDParser, and ASDTester and the utility programs ASDCheck,
MergeGrammars,
and DefinedUsed. However, it is a work in progress and is
far
from
complete. In particular, semantic action and semantic
value
computations
have not yet been written for it, and there is not yet a Java
program,
comparable to Nounphrase1.java below, to drive it.
Nevertheless,
it illustrates several things about constructing large ASD
grammars.
- cardinal.grm - a small
example
grammar
for English cardinal-numeral phrases such as "twelve million
twenty
three
thousand four hundred and seventeen". It can be displayed
and
edited
with the ASDEditor. It can also be edited with any simple
editor
for text files, though such editing must be done
carefully.
Otherwise
it may create an ill-formed file which cannot subsequently be
read by
the
ASDEditor. The latest version (2002 Feb 2) accepts commas
and
hyphens
in the input, so it will recognize phrases like "two million,
three
hundred
forty-six thousand, five hundred and seventy-nine". The
new
version
requires version 1.04 or higher of ASDParser.
- cardinal.jpg - the
grammar
from cardinal.grm
as it is displayed by ASDEditor.
- Numerals.java - the
Java
source code
for an example program that uses the cardinal.grm
grammar to
translate
English cardinal-numeral phrases into integer numbers.
(This
example
has been improved from the version originally posted at this
site on
2001
Dec. 1.)
- Numerals.class - the
compiled
version
of Numerals.java. If the Java run-time
environment has
been
installed on your computer (see below), and if you have
downloaded the
files asddigraphs.jar, cardinal.grm, and Numerals.class
and stored them in single subdirectory, then you can run the
Numerals
example
from a command-line window in that subdirectory with the command
the
following
commands:
In an MS-Windows command window: java -cp
asddigraphs.jar;.
Numerals
In a Unix command window: java -cp
asddigraphs.jar:.
Numerals
Alternatively, if you add the asddigraphs.jar file to
your
system's CLASSPATH, then you can simply use
java Numerals
If you want to see the parse trees for each of the phrases parsed
by
the Numerals example, run it with the option show at
the
end
of the command:
In an MS-Windows command window: java -cp
asddigraphs.jar;.
Numerals show
In a Unix command window: java -cp
asddigraphs.jar:.
Numerals show
If asddigraphs.jaris in the system classpath:
java
Numerals
show
- nounphrasesimple0.grm
- a
larger example grammar, a partial grammar of English noun
phrases like
"my three big, friendly dogs", "the five hundred members of a
square-dancing
club", "those two of my father's suits in the front hall
closet", or
"the
Queen of England's crown". (Notice the syntactic ambiguity
of the
possessive in the last example.) This file uses, but does
not
include,
the grammar from the file cardinal.grm.
- nounphrasesimple.grm
-
the
grammar obtained by using an ASDEditor to merge nounphrasesimple0.grm
into cardinal.grm.
- Nounphrase1.java -
The
source code
for the class Nounphrase1 in the package english.
Nounphrase1
uses an ASDParser and illustrates use of the nounphrasesimple.grm
grammar to parse English noun phrases. It provides a
graphical
user
interface that permits the user to type in a phrase, to parse
the
phrase
to try to find one or more interpretations of it, and, when
parse
attempts
are successful, to display the phrase structure and the semantic
feature
values computed for the phrase. Although this example
provides
only
partial coverage of English noun phrase structures, it involves
a
fairly
large example grammar and it illustrates a number of interesting
ways
in
which ASDParsers and ASDEditors can be used. Note: For
this
program
to work correctly, the grammar file nounphrasesimple.grm
must be in the subdirectory from which the program is
started. See
the package notes for more details
about how Nounphrase1
works and what it illustrates.
Command-line usage:
In an MS-Windows command-line window:
java -cp asddigraphs.jar;english.jar;. english/Nounphrase1
Or under UNIX:
java -cp asddigraphs.jar:english.jar:. english/Nounphrase1
OR if asddigraphs.jar and asdx.jar have been put in the system
classpath:
java english/Nounphrase1
- EnglishNoun.java and EnglishWord.java
- source code for two other classes in the package english.
These
provide
static
methods
for
some
useful
computations
on
words in
English.
See the source code, the package notes
and
the javadoc
documentation for details.
- english.jar, english.zip,
and english.tar.gz -
class
archive
files for the package english, which currently
includes the
classes EnglishNoun, EnglishWord,
and Nounphrase1.
- Package notes about the english
package.
Here are some suggested examples to try parsing with the demo
version
of ASDParser:
With the example grammar cardinal.grm:
-- "one hundred and twenty-five thousand"
Try parsing it stepwise, with
and without the check boxes being checked. Try for more than
one
successful parse.
With the example grammar npX.grm:
-- "the last doughnut in this big box"
-- "the very first little green apple"