Tag: sqlite stem list - adamb924/mortal-engine GitHub Wiki

The <sqlite-stem-list> reads stems from a SQLite database instead of an XML file. This is probably the better way to go if you're doing a project with a lot of words.

The element looks just like <stem-list>, so see the explanations there. In this case <filename> is a path to a SQLite database.

<sqlite-stem-list label="Stem">
    <filename>my-database.sqlite</filename>
    <matching-tag>noun</matching-tag>
</sqlite-stem-list>

Advanced Topics

Creating allomorphs procedurally

The <sqlite-stem-list> tag can also contain the <create-allomorphs> tag, which will generate stem allomorphs automatically for you. For instance, if you have word-final devoicing, you could put the voiced versions in your stem list, and then automatically generate devoiced allomorphs using <create-allomorphs>.

Specifying a database name instead of a path

If as a developer you want Mortal Engine to read from a database that you have opened yourself, then instead of the <filename> tag you can use <external-database>, like <external-database>mydatabasename</external-database>.

In that case Mortal Engine will open the database as follows:

QSqlDatabase db = QSqlDatabase::database(mDbName);

SQLite structure

If you ran the above snippet through Mortal Engine, it would produce my-database.sqlite with all of the needed tables. By way of feeble documentation, here is an explanation of the tables and fields. (These statements are executed in mortal-engine/nodes/sqlitestemlist.cpp.)

create table if not exists Stems ( _id integer primary key autoincrement, liftGuid text  );
  • _id Row ID
  • liftGuid Not used in Mortal Engine itself. (It can be used to keep track of relationships to LIFT files).
create table if not exists Allomorphs ( _id integer primary key autoincrement, stem_id integer);
  • _id Row ID
  • stem_id Corresponds to the _id in the Stems table that the allomorph belongs to.
create table if not exists Forms ( _id integer primary key autoincrement, allomorph_id integer, Form text, WritingSystem text );
  • _id Row ID
  • allomorph_id Corresponds to the _id in the Allomorphs table that the Form belongs to.
  • Form The text of the form, e.g., “apple”
  • WritingSystem The lang attribute value of the writing system, e.g., 'en-US'.
create table if not exists Glosses ( _id integer primary key autoincrement, stem_id integer, Form text, WritingSystem text );
  • _id Row ID
  • stem_id Corresponds to the _id in the Stems table that the allomorph belongs to.
  • Form The text of the form, e.g., “apple”
  • WritingSystem The lang attribute value of the writing system, e.g., “en-US”.

(Glosses are not used in parsing, but can be used by other applications.)

create table if not exists Tags ( _id integer primary key autoincrement, Label text );
  • _id Row ID
  • Label The name of the tag, e.g., “noun”
create table if not exists TagMembers ( tag_id integer, allomorph_id );
  • _id Row ID
  • allomorph_id Corresponds to the _id in the Allomorphs table that the Tag belongs to.
⚠️ **GitHub.com Fallback** ⚠️