Skip to content

Latest commit

 

History

History
84 lines (56 loc) · 2.87 KB

database.rst

File metadata and controls

84 lines (56 loc) · 2.87 KB

camel_tools.morphology.database

The .MorphologyDB class parses a morphology database file and generates indexes to be used by the analyzer, generator, and reinflector components. You will never have to access .MorphologyDB instances directly but only pass them as arguments when creating new instances of the analyzer, generator, and reinflector components.

Classes

camel_tools.morphology.database.MorphologyDB

Databases

Below is a list of databases that ship with CAMeL Tools:

  • calima-msa-r13 Database for analyzing Modern Standard Arabic.1
  • calima-egy-r13 Database for analyzing Egyptian Arabic.2

Examples

from camel_tools.morphology.database import MorphologyDB

# Initialize the default database ('calima-msa-r13')
db = MorphologyDB.builtin_db()

# In the above call, the database is loaded for analysis only by defaut.
# This is equivalent to writing:
db = MorphologyDB.builtin_db(flags='a')

# We can load it for generation as so:
db = MorphologyDB.builtin_db(flags='g')

# Or for reinflection as so:
db = MorphologyDB.builtin_db(flags='r')

# Since reinflection uses the database in both analysis and generation modes
# internally, the above is equivalent to writing:
db = MorphologyDB.builtin_db(flags='ag')


# We can initialize other builtin databases by providing the name of the
# desired database. In the examples above, we loaded the default database
# 'calima-msa-r13'. We can load other builtin databases by providing the
# desired databases name. Here we'll load the builtin Egyptian database,
# 'calima-egy-r13':
db = MorphologyDB.builtin_db('calima-egy-r13')

# Or with flags:
db = MorphologyDB.builtin_db('calima-egy-r13', flags='r')


# We can also initialize external databases:
db = MorphologyDB('/path/to/database')

# or with flags:
db = MorphologyDB('/path/to/database', flags='g')

Footnotes


  1. calima-msa-r13 is a modified version of the almor-msa-r13.db database that ships with MADAMIRA. The calima-msa-r13.db database is distributed under the GNU General Public License version 2.

  2. calima-egy-r13 is a modified version of the almor-cra07.db database that ships with MADAMIRA. The calima-egy-r13.db database is distributed under the GNU General Public License version 2.