These instructions are intended to let the reader start with a corpus of interlinear 
glossed text in Toolbox or FLeX format and produce an enriched Xigt corpus and the 
appropriate config files to run BASIL. This is not an automated process and has some 
manual steps.
If you have questions please contact Kristen Howell. I will do my best to help.

Converting to Xigt:
Xigt is an extensible, flexible, xml-based format for IGT. More information can be found 
here: https://github.com/xigt/xigt

From Toolbox:
Xigt has a built-in toolbox to xigt converter
1) download Xigt
   git clone https://github.com/xigt/xigt.git 
2) download the xigt toolbox module
   git clone https://github.com/goodmami/toolbox.git
3) add the toolbox module to your python path
   PYTHONPATH=[location of toolbox module]
4) change repeated ids in the toolbox file (xigt will throw an error if the toolbox file 
uses the same \ref for multiple IGT)
   awk '/^\\ref/{print "\\ref igt" NR;};!/^\\ref/' < [toolbox_file > new_toolbox_file  
6) create a config file (optional)
   The default config can be found in xigt/xigt/importers/toolbox.py
   Create a new config as appropriate for the tags in your dataset. If you omit this, 
   the default will be used.
5) convert toolbox to xigt
   cd xigt
   ./xigt.sh import -f toolbox -i new_toolbox_file -o [language].xml -c config.json

From FLeX:
1) download or install Xigt
   pip install xigt
   git clone https://github.com/xigt/xigt.git 

2) Download the converter. The converter repository is private. For access, please contact 
Emily M. Bender
   git clone https://git.ling.washington.edu/agg/temp-flex2xigt.git

3) Run converter
   python3 ./xigtconversion.py [my_file}.flextext

From Plain Text:
If your data is in plain text format, eg. 3-line IGT, the easiest thing to do might be to 
convert it to the "odin" format and then use Xigt's odin to xigt converter
Create a file, where your data is formatted like this. Separate each IGT with a blank line:

doc_id=adverb.tex igt_id=jpn-3 1 3 M L G T
language:japanese (jpn)
line=1 tag=M: b: vetted:a
line=2 tag=L:   kyou Toukyou loc iki-masu
line=3 tag=G:   today Tokyo to go-ahonplus
line=4 tag=T:    ``Today I go to Tokyo.''

doc_id=adverb.tex igt_id=jpn-4 1 3 M L G T
language:japanese (jpn)
line=1 tag=M: b: vetted:a
line=2 tag=L:     sorosoro taberu
line=3 tag=G:     soonish eat
line=4 tag=T:      ``I'll eat soonish.''

1) download Xigt
   git clone https://github.com/xigt/xigt.git 
2) dowload oding utils
   git clone https://github.com/xigt/odin-utils.git
3) add odin- utils to your pythonpath
   PYTHONPATH=[location of odin module]
4) convert odin-formatted file, as described above to xigt
   cd xigt
   ./xigt.sh import -f odin -i [my_data].odin -o [my_data].xml
   
Other:
Those are the only 3 formats we support right now, but we are aware of other researchers working 
on additional converters (eg. ELAN). If your data is in another format, feel free to contact us 
and we'll point you in the right direction if we can.


Enriching with INTENT (Georgi 2016):
The next step is to "enrich" the XIgt file with INTENT. This is a process that creates alignments 
between the translation line (note: INTENT expects an English translaation) and the language, via 
the gloss line. INTENT parses the English translation and projects information from that parse 
(eg. dependency and POS tags) onto the language via the alignments. More information can be found in:
  Ryan Georgi. 2016. From Aari to Zulu: Massively Multilingual Creation of Language Tools Using 
  Interlinear Glossed Text. PhD thesis, University of Washington.

1) download and install INTENT
   git clone https://github.com/rgeorgi/INTENT2.git
   cd intent2
   pip install -r requirements.txt
   pip install .

2) enrich xigt file
   intent -i [my_data].xml -o [my_data]_enriched.xml --ignore-import-errors
   
3) if you want to preserve information like POS tags from your original dataset, merge the enriched file 
with the original
   merge-xigt -f merge-xigt -f [my_data].xml -f [my_data]_enriched.xml -o [my_data]_merged.xml -v

Changing tag names:
BASIL/MOM and INTENT are out of sync regarding the xigt tier names they use. MOM and BASIL should be updated 
to take tier names as a config. For now, though, you just need to change the tier names INTENT produces to 
the ones MOM and BASIL expect
BASIL/MOM expect the following tier ids:
id="g-pos"
id="gw-pos"
id="w-pos"
id="tw-pos"
id="w-ds"
id="tw-ds"

INTENT2 tends to use and _ instead of a -. The w-pos tier is sometimes called "x" or something like that. 
The dependency (ds) tiers are sometimes called dependencies. Change any of these ids to match the list above.

Producing config files:
MOM has a few pre-processing steps as well.
1) create a config file. a sample file and description can be found here: 
https://git.ling.washington.edu/agg/mom/-/tree/master/mom/config_files
2) collect the tags mom requires. In the following [pos] is the name of the pos tier you want to use. this 
will probably be "pos" "m-pos" or "w-pos". [g] is the name of your glosses tier. it will probably be "g".
   cd mom
   python3 .\mom\util\collect_tags_xigt.py [my_enriched_data].xml [pos] [g] [my_config]
3) This script creates a "pos_tags.txt" file and a "glosses.txt" file
4) You need to create "noun-tags.txt", "verb-tags.txt", and "adp-tags.txt". From "pos_tags.txt" pased the noun, 
verb and adposition tags into their respective files.
5) The glosses file contains every gloss in the corpus. You need to go through and delete any lemmas, so that 
the file only contains grams.

Producing Item files:
If you want to produce an item file (the testsuite expected by LKB and ACE parsers), do the following:
1) download Xigt
   git clone https://github.com/xigt/xigt.git 
2) replace with the itsdb.py file in xigt/exporters with the one here: https://git.ling.washington.edu/agg/temp-xigt2itsdb.git
3) convert xigt file to item file:
   cd xigt
   python3 -m xigt.main export -f itsdb -i [my_data].xml -o [my_data]