MorfaS
Documenting MorfaS
Morfa-S relies on three types of files to be installed properly.
File dependencies
- Word lexicon file (n_smanob.xml)
- Paradigm file (paradigms.txt)
- tags file (tags.txt)
paradigms.txt
Both the paradigms file and tags file are important for Morfa-S and Morfa-C to function. paradigms.txt is simply a list of all of the tags for the wordforms that will be generated. These are separated by newlines.
V+Ind+Prs+Sg1 V+Ind+Prs+Sg2 V+Ind+Prs+Sg3 etc...
It may be useful to split up the paradigm files by part of speech (v_paradigms.txt, n_paradigms.txt), in order to have more detailed control over the paradigms in the event that certain kinds of verbs need to be separated from eachother, and so on...
NOTE: If you split up paradigm files, it is important to also have one file containing all of the possible tag strings, because tag and paradigm files are also installed separately for Morfa-C.
tags.txt
This file defines tag classes and groups. It is required for both Morfa-C and Morfa-S. The file is a collection of lists of individual tags (Prop, Pers, Logo; PxSg1, PxSg2, etc.) split up by a name.
#Subclass Prop Pers Logo #Possessive PxSg1 PxSg2 PxSg3
This file may also be used to generate custom tag sets for Morfa-C, so that when creating questions, one could refer to only 1st and 2nd persons:
#1st2ndPerson Sg1 Sg2 Du1 Du2 Pl1 Pl2
Installation command
python install.py --file n_smanob.xml --paradigmfile paradigms.txt --tagfile tags.txt
FST locations
See FST documentation for more information.
Relevant classes and variables
- settings.py
- DEFAULT_DIALECT
- L1
- DEFAULT_DIALECT
- smadrill/urls.py
- Several URL patterns are set up for 'pretty' URLS. The relevant ones are morfa/baakoe/ (sma. *baakoe* 'word')
- smadrill/views.py
- views.morfa_game - instantiates a Gameview class, returns a response
- views.Gameview - class for POST/GET responses, which calls the Morfa class, game.BareGame
- views.morfa_game - instantiates a Gameview class, returns a response
- smadrill/game.py
- relax
- Game - Parent class to all game classes, contains a lot of shared methods for all subclasses.
- BareGame (a subclass of Game) - subclass of Game, overrides several methods. See BareGame docstrings for more information.
- relax
- smadrill/forms.py
- MorfaSettings - Settings form dropdown menues and choices
- MorfaQuestion - Handles the display and generation of form fields
- Form Choice data: CASE_CHOICES, CASE_CHOIES_PRONOUN, VTYPE_CHOICES, etc.
- MorfaSettings - Settings form dropdown menues and choices
templates/smaoahpa_main.html templates/smaoahpa.html smadrill/templates/game.html smadrill/templates/mgame.html smadrill/templates/mgame_a.html smadrill/templates/mgame_l.html smadrill/templates/mgame_n.html smadrill/templates/mgame_p.html smadrill/templates/mgame_v.html
Adding question types
To add a new question type to Morfa-S I need to edit the following files, often doing things that are repeated across multiple places. It is also a little more complex if adding a new part of speech, for instance, since this isn't a question of adding another value to a form, but also adding form fields.
- smadrill/game.py
- Add an entry to BareGame.casetable, review code for things dependent on casetable. The methods in BareGame also contains miscellaneous other instances of dictionaries that correspond to parts of speech and morphological type that need to be checked here
- Add an entry to BareGame.casetable, review code for things dependent on casetable. The methods in BareGame also contains miscellaneous other instances of dictionaries that correspond to parts of speech and morphological type that need to be checked here
- smadrill/views.py
- Add a key-value pair to self.gamenames
- Add a key-value pair to self.gamenames
- smadrill/forms.py
- CASE_CHOICES, POS_CHOICES, etc.,
- CASE_CHOICES, POS_CHOICES, etc.,