maintenance
This is the original Maintenance document for Oahpa. Please do not edit it. Part of the content is obsolete, but the content is kept as the original documentation.
Maintenance
This document contains the basic instructions for updating the content
All the data is stored in xml-files which are installed to mysql
Everyday maintentance consists of updating the information in the
All the commands described in this document have to be run in victorio.
Install Django locally
To test applications and interfaces, install Django to your own
Go to victorio and start mysql with the administrator username and password.
$ mysql -u root -p mysql> GRANT all ON oahpa.* TO 'your-username'@'your-own-ip-address';
Edit the file ped/oahpa/settings.py in your own computer with the information
DATABASE_USER = 'your-username' DATABASE_PASSWORD = '' DATABASE_HOST = 'gtsvn.uit.no' DATABASE_PORT = '' (port number)
And, finally, you need to create a sami language directory. Django should be installed in /Library/Python/2.5/site-packages/ -directory. Look at that directory for django/conf/locale -directory. Create sme
mkdir your_pythonlib/django/conf/locale/sme cp your_pythonlib/django/conf/locale/no/django.* $(djangopath)/django/conf/locale/sme/
Then start the web development server in your own computer:
cd ped/oahpa/ python manage.py runserver
The pages should be available in
In the sandbox, it is possible to test the changes to the code and to
Some caveats with the local installation on MacOS:
- if you have two different python versions, both in
/usr/bin/python
and in
/opt/local/bin/python
you have to configure the Django installation as required (see, for instance, this site)
- if you have problems starting the sandbox web server and get the following error:
~/Django/someAppl>python manage.py runserver Validating models... Unhandled exception in thread started by <function inner_run at 0x6c1f70> Traceback (most recent call last): ............... from django.db import models, connection File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 22, in <module> backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, ['']) ImportError: No module named dummy.base
you might lack the py25-hashlib package
sudo port install py25-hashlib
Your own database
Sometimes it would be good idea to have a replicate also from the
Look at the file /etc/my.cnf. It should have these utf8-values:
[client] default-character-set=utf8 [mysqld] default-character-set=utf8 collation_server=utf8_bin character_set_server=utf8 character_set_client=utf8
Start the server with command:
sudo mysqld_safe &
Set root password and create a new user account:
mysqladmin -u root password "mypassword"
Look for manuals to create own user etc, but you may use the root as
mysql -u root -p mysql> create database oahpa character set utf8 collate utf8_bin; mysql> exit;
Change the local settings in ped/oahpa/settings.py:
DATABASE_USER = 'root' DATABASE_PASSWORD = 'myspassword' DATABASE_HOST = ''
Add the PYTHONPATH of the OAHPA! project in your .bashrc file:
export PYTHONPATH=$(YOUR-PATH-TO)/gtsvn/ped:$(YOUR-PATH-TO)/gtsvn/ped/oahpa:$(YOUR-PATH-TO)/gtsvn/ped/oahpa/drill
Adjust paths in ped/oahpa/ling.py:
fstdir="$(YOUR-PATH-TO)/gtsvn/gt/sme/bin" lookup = "$(YOUR-PATH-TO)/bin/lookup"
Adjust paths in ped/oahpa/drill/game.py:
fstdir="$(YOUR-PATH-TO)/gtsvn/gt/" + language + "/bin" lookup ="$(YOUR-PATH-TO)/bin/lookup"
Start installing the database information:
cd ped/oahpa python manage.py syncdb python install.py -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt -b python install.py -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt -f ../sme/xml/nouns.xml
Install everything you need starting from the lexicons.
Start Django locally:
python manage.py runserver
Possible problem:
- if you get a DB connection error, for instance
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
first, find the mysql socket
~>mysqladmin variables | grep socket | socket | /tmp/mysql.sock
and then, change the value of the DATABASE_HOST in ped/oahpa/settings.py accordingly:
DATABASE_HOST = '/tmp/mysql.sock'
HTML
Overall look
- CSS-settings reside in ped/oahpa/media/css/oahpa.css
- Mainpage oahpa.no is defined in
- Basic look for all the games (divs, menubars) are given in file
- The file game.html contains the basic functionality for all the games.
- Morhpology games are controlled by the file mgame.html
In addition, it is possible to alter the pages of individual games by
ped/oahpa/drill/templates/mgame_n.html (Morfa for nouns) ped/oahpa/drill/templates/mgame_l.html (Morfa numerals) ped/oahpa/drill/templates/mgame_a.html (Morfa for adjectives) ped/oahpa/drill/templates/mgame_v.html (Morfa for verbs) ped/oahpa/drill/templates/quizz.html (Leksa common nouns) ped/oahpa/drill/templates/quizz_n.html (Leksa placenames) ped/oahpa/drill/templates/num.html (Numra cardinal) ped/oahpa/drill/templates/num_ord.html (Numra ordinals) ped/oahpa/drill/templates/vasta.html ped/oahpa/drill/templates/sahka.html
Game pages involve definitions from several html-pages. For example, S-MORFA: mgame_x.html, mgame.html, game.html and oahpa.html.
The files contain template tags such as:
{% block navbar %} .. {% endblock %}
They enable several pages to be generated from one source file. In
Examples
If you want to update a text in English, write inside the trans-tags in the html-file for the main page or the game :
{% trans ".." %}
To make a new box for option xxx in Leksa Placenames under geography choices, you have to add this to the files:
1. oahpa/drill/forms.py: GEOGRAPHY_CHOICES = ('xxx', _('xxx')), and # For placename quizz xxx = forms.BooleanField(required=False,initial=0) 2. oahpa/drill/views.py: if 'xxx' in settings_form.data: self.settings['geography'].append('xxx') 3. oahpa/drill/templates/quizz_n.html: {{ settingsform.xxx }}{% trans "xxx" %}<br/>
Javascripts
ped/oahpa/media/js/oahpa.js
In addition, there are couple of other scripts, one for fixing the png-images in earlier IE versions using pngfix.js.
FSTs
ped-sme.fst sme-num.fst isme-norm.fst isme-GG.restr.fst isme-KJ.restr.fst
Lookup server
The lookup-process for the analyzer ped-sme.fst, used in Vasta
NB: Any update of the FST requires a restart of the lookup server!
-
(re-)startingthe server:
- go to /home/oahpa/ped/src
- type the command sudo ./lookupserv restart
- go to /home/oahpa/ped/src
-
testing the server using the commad-line tool, that takes one word at a time:
- go to /home/oahpa/ped/src
- type the command sudo python client.py
- go to /home/oahpa/ped/src
-
checking the log file for the lookup output from Sahka and Vasta on victorio:
- inspect the file /var/log/lserv.log with you editor of choice
Updating the database
The script install.py is used for updating the database. First, cd to
cd ped/oahpa/ python install.py -h
Changes in the database are visible in the interface straight
Lexicons
Information of individual words such as lemmas, stem information,
python install.py -f ../sme/xml/nouns.xml
Forms and tags are updated when the tagfile and paradigmfile are given
python install.py -f ../sme/xml/nouns.xml -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt
This command generates paradigm for all the words in nouns.xml and
Remove words from the database one by one by giving the word id (or lemma) and the part of speech as option:
python install.py -w beana -p N
If you have deleted entries in the lexicon file, specify an extra
python install.py -d -f ../sme/xml/nouns.xml
To add the new words to the semantic supersets, update the semantic
Both Sami and Norwegian lexicons are installed using the same command. The
python install.py -f ../nob/xml/nouns.xml
Finally, the installation commands here only update old and add new
python install.py --delete -f ../sme/xml/nouns.xml
This command both updates and removes all the extra entries of pos
Numerals
python install.py -n
Placenames
python install.py --places -f ../sme/xml/propernouns.xml
Use option -d to remove entries from the database the same way as from
Semantic classes
The grouping of semantic classes is defined in
python install.py -s ../sme/xml/semantic_sets.xml
The semantic set information is used among others in Leksa. To update
SEMTYPE_CHOICES = ( ('FAMILY', _('family')), ('PROFESSION', _('profession')), ... )
The string in small letters is the string that appears in the menu in
Vasta and Morfa-C
python install.py -g ../sme/xml/grammar_defaults.xml -q ../sme/xml/questions_nouns.xml
Everything inside the question xml-file may be changed and the database
python install.py --qid <question_id> .. or by using the question text python install.py --qid "Maid SUBJ MAINV"
Of course the latter command will delete all the questions with that
Available tags and paradigms are stored to the database beforehand and
python install.py -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt -b
Feedback
Install first the feedback messages, preferably for all languages:
python install.py -m ../sme/xml/messages.xml python install.py -m ../sme/xml/messages.sme.xml
After that, install the feedback files for each pos. This may take
python install.py -e ../sme/xml/feedback_verbs.xml -f ../sme/xml/verbs.xml ..
You may update the content of the feedback messages, or add new
Sahka
Sahka contains pictures which have to be synchronized with the
Updating the database
<dialogue name="firstmeeting_man">
Install it to database using the command:
cd ped/oahpa python install.py -k ../sme/xml/dialoguefile.xml
The script will give errors on links that do not point to an utterance
When you want to update an existing dialogue, use the same command:
cd ped/oahpa python install.py -k ../sme/xml/dialoguefile.xml
It will first remove the old dialogue and then install it as it was new. Do not
Images
Store the images to directory ped/oahpa/media/img/, with the same name
If you are installing a new game, update the file
<td> <a href="javascript:submitSahka('firstmeeting_man');"> <img width="100" src="/oahpa/media/man.jpg"/> <p>{% trans "Meeting with Hansa" %}</p></a> </td>
Copy one such td, to a suitable place inside the table, specify a
CG-script
Copy the file sme-ped.cg3 to /opt/smi/sme/bin.
Other
Comments
python install.py -c ../sme/xml/comments.nob.xml
Running the script deletes all the old comments and creates everything anew.
Grammarlinks
python install.py -i ../sme/src/grammatikklinker.txt
Localisation
Translations for the texts in the interface are provided in files:
ped/oahpa/locale/fi/LC_MESSAGES/django.po ped/oahpa/locale/sme/LC_MESSAGES/django.po ped/oahpa/locale/no/LC_MESSAGES/django.po ped/oahpa/locale/en/LC_MESSAGES/django.po
The English file is needed for the names and strings that contain
Whenever the texts in the page are updated, the translations need to be checked and updated as well.
cd ped/oahpa django-admin.py makemessages -a svn ci -m "new generated files" locale/fi/LC_MESSAGES/django.po ... etc. for the other files.
After that, work on the respective django.po files, and check them
After fixing the files update the official directory and compile the messages.
cd ped/oahpa/ svn up django-admin.py compilemessages
Restarting the httpd server
Updates to the code require restart of the httpd-server. Sometimes
Restarting the server (requires sudo rights):
sudo /etc/init.d/httpd restart
Earlier, there was a memory leak problem, which should not be among us
ps aux | grep http
If the result indicates memory use too close to 100, this is a clear
Mysql
In general, the database does not have to be directly accessed, but
Sometimes, there may be a problem with the mysqld (a clear indication
sudo /etc/init.d/mysqld start
Admin-interface
Still undocumented.