|
Contents:
Search: |
FeaturesWhat is a feature again?A feature is a typed value which is an attribute of an object. The object type of an object determines which features it has. See here for more information. How do I store the text?Well, the text arises because objects exist in the monad stream which carry the textual information. That may seem a bit cryptic, so let's try an example. CREATE OBJECT TYPE [Word surface : STRING; ] GO Here we have created an object type "Word" with a feature called "surface". The idea is that the objects of type Word will make up the text collectively, but filling the monad stream with word-sized chunks of the text. Note that we need not have "Word" as the text-bearing unit: It can also be "Morpheme" or "Grapheme", or even "Sentence" if we don't care about individual words. How do I store parts of speech?The easiest is to create an enumeration with the parts of speech, then have this enumeration type as the type of a feature on the Word object type:
CREAT ENUMERATION pos_t = {
NA = -1,
noun = 1,
verb,
adjective,
adverb,
preposition,
conjunction,
interjection,
negative,
article
}
GO
CREATE OBJECT TYPE
[Word
surface : STRING;
pos : pos_t;
lemma : STRING;
]
GO
How do I store complex grammatical tags?Well, there are two ways:
The latter makes the grammatical "tag" searcheable in its individual parts through the topographic search-features of MQL. The former is more compact, is less prone to error, and is also searcheable through regular expressions. How do I store a phrase type?Much in the same way as you store a part of speech (see above). How do I point to other objects?You use the ID_D type and then let that feature point to the other object through that object's "self" feature. That is, say you want object A to point to object B. Object A must have a feature of type ID_D, say, "parent". Then, when creating object A, set object A.parent to B.self. How do I create a syntax tree?You can either express it top-down (with a LIST OF ID_D pointing to the children) or bottom-up (with ID_D pointers pointing to the parents). Bottom-up with pointers to parentsIf you want to do the tree bottom-up, and it really is a tree (not a Directed Acyclic Graph), then every node will have one or zero parents. This can be elegantly modeled in EMdF with an id_d feature called "parent" (or similar) on every node that may have a parent. Then that feature just has the id_d of the parent object. Or, if there is no parent for this particular node, the feature can be the special value NIL.
CREATE OBJECT TYPE
[Word
surface : STRING;
parent : ID_D; // Points to phrase or clause
]
GO
CREATE OBJECT TYPE
[Phrase
phrase_type : phrase_type_t; // A suitably defined enumeration
parent : ID_D; // Points to phrase or clause
]
GO
CREATE OBJECT TYPE
[Clause
parent : ID_D; // Points to clause or sentence (or phrase, in some languages)
]
GO
CREATE OBJECT TYPE
[Sentence
parent : ID_D; // Points to paragraph...
]
CREATE OBJECT TYPE
[Paragraph] // The buck stops here.
GO
CREATE OBJECT TYPE
[Word
surface : STRING;
parent : ID_D; // Points to phrase or clause
]
GO
CREATE OBJECT TYPE
[Phrase
phrase_type : phrase_type_t; // A suitably defined enumeration
parent : ID_D; // Points to phrase or clause
]
GO
CREATE OBJECT TYPE
[Clause
parent : ID_D; // Points to clause or sentence (or phrase, in some languages)
]
GO
CREATE OBJECT TYPE
[Sentence
parent : ID_D; // Points to paragraph...
]
CREATE OBJECT TYPE
[Paragraph] // The buck stops here.
GO
Of course, if you have a Directed Acyclic Graph rather than a tree, then there may be zero or more parents. Then just subsitute "LIST OF ID_D" for "ID_D" in the above, and call all the "parent" features "parents" instead. Searching trees with parentsThe idiom for searching a tree such as the above is as follows:
SELECT ALL OBJECTS
WHERE
[Clause AS c1
[Phrase
// This ensures that this Phrase is a direct descendant
// of the clause
parent = c1.self
]
]
GO
Top-down with pointers to childrenYou can also do it with children instead of parents:
CREATE OBJECT TYPE
[Word
surface : STRING;
// No parent or children feature: This is a leaf!
]
GO
CREATE OBJECT TYPE
[Phrase
phrase_type : phrase_type_t; // A suitably defined enumeration
children : LIST OF ID_D; // Points to word or phrase (or clause)
]
GO
CREATE OBJECT TYPE
[Clause
children : LIST OF ID_D; // Points to clause or phrase
]
GO
CREATE OBJECT TYPE
[Sentence
children : LIST OF ID_D; // Points to clause or sentence
]
CREATE OBJECT TYPE
[Paragraph
children : LIST OF ID_D; // Points to sentence
]
GO
Searching trees with childrenThe idiom for searching trees with children is as follows:
SELECT ALL OBJECTS
WHERE
[Clause AS c1
[Phrase
// This ensures that this Phrase is a direct descendant
// of the clause
self IN c1.children
]
]
GO
|