Features

What 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:

  1. Either you use a single STRING or ASCII feature, or
  2. You split up the grammatical tag into its constituent parts (for example, part of speech, person, number, gender, discourse type, etc. etc.) and store those as individual enumerations or strings.

The latter makes the grammatical "tag" searcheable in its individual parts through the topographic search-features of MQL.

The former is more compact, 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.

Starting with Emdros 3.3.1, there is another option: "Point" to the other object through a feature on the "pointing" object which has a feature type of "Set of monads", and whose values consist of the sets of monads making up the "other object". That way, you can correlate the objects through their monads.

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 parents

If 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 parents

The 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 children

You 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 children

The 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

Previous:Object types
Up:Schema
Next:Enumerations