Commits

Lars Yencken committed c3e649e

Updates database references to match new app name.

Comments (0)

Files changed (4)

src/explain_query.py

             result.append('<span class="explanation">%s</span> ' % g_seg)
             continue
         
-        alternation = get_model('reading_alt', 'kanjireading'
+        alternation = get_model('jp_reading_alt', 'kanjireading'
                 ).objects.get(kanji=g_seg, reading=r_seg).reading_alternation
         tree = model_tree.build_path(alternation, 'value')
         tree = _collapse_tree(tree)
         # We didn't align to any real reading, so our reading was bad.
         return set([QueryError.ChoiceOfReading])
     
-    KanjiReading = get_model('reading_alt', 'kanjireading')
+    KanjiReading = get_model('jp_reading_alt', 'kanjireading')
     
     # We aligned to a real reading, so we can compare segment by segment
     errors = set()
     return None.
     """
     # Can we align this to any single real reading?
-    get_reading = get_model('reading_alt', 'kanjireading').objects.get
+    get_reading = get_model('jp_reading_alt', 'kanjireading').objects.get
     for reading in real_readings:
         reading_segs = _segment_reading(grapheme_segs, reading)
         if reading_segs is None:
     or return None.
     """
     # Build list of part candidates
-    KanjiReading = get_model('reading_alt', 'kanjireading')
+    KanjiReading = get_model('jp_reading_alt', 'kanjireading')
     reading_parts = []
     for g_seg in grapheme_segs:
         if script_type(g_seg) == Script.Kanji:

src/migrations/0001_initial.py

     def forwards(self):
         
         # Model 'ReadingAlternation'
-        db.create_table('reading_alt_readingalternation', (
+        db.create_table('jp_reading_alt_readingalternation', (
             ('left_visit', models.IntegerField(primary_key=True)),
             ('right_visit', models.IntegerField(db_index=True)),
             ('value', models.CharField(
             ('probability', models.FloatField()),
         ))
         # Model 'KanjiReading'
-        db.create_table('reading_alt_kanjireading', (
+        db.create_table('jp_reading_alt_kanjireading', (
             ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
             ('reading', models.CharField(
                 max_length=settings.MAX_READING_LENGTH * \
             ('alternations', models.CharField(max_length=len(ALTERNATION_TYPES), blank=True, null=True, help_text='The alternation codes used to get this reading.')),
             ('probability', models.FloatField( help_text='The log-probability of this reading for this kanji.')),
             ('reading_alternation', models.ForeignKey(
-                get_model('reading_alt', 'readingalternation'),
+                get_model('jp_reading_alt', 'readingalternation'),
                 blank=True, null=True,
                 help_text='The final alternation step which' \
             ' provided this reading.')),
         ))
         
-        db.send_create_signal('reading_alt', ['ReadingAlternation','KanjiReading'])
+        db.send_create_signal('jp_reading_alt', ['ReadingAlternation','KanjiReading'])
     
     def backwards(self):
-        db.delete_table('reading_alt_kanjireading')
-        db.delete_table('reading_alt_readingalternation')
+        db.delete_table('jp_reading_alt_kanjireading')
+        db.delete_table('jp_reading_alt_readingalternation')
         
 #
 
 """
-Models for the reading_alt app.
+Models for the jp_reading_alt app.
 """
 
 from django.db import models

src/reading_database.py

 
         # Insert them to the database.
         cursor = connection.cursor()
-        cursor.execute('DELETE FROM reading_alt_kanjireading')
-        cursor.execute('DELETE FROM reading_alt_readingalternation')
+        cursor.execute('DELETE FROM jp_reading_alt_kanjireading')
+        cursor.execute('DELETE FROM jp_reading_alt_readingalternation')
         max_per_run = 10000
         all_results = iter_results(root_node)
 
         for results in groups_of_n(max_per_run, all_results):
             cursor.executemany(
                     """
-                    INSERT INTO reading_alt_readingalternation 
+                    INSERT INTO jp_reading_alt_readingalternation 
                     (value, code, probability, left_visit, right_visit)
                     VALUES (%s, %s, %s, %s, %s)
                     """,
         max_per_insert = 10000
         all_results = iter_results(alt_tree)
         cursor = connection.cursor()
-        cursor.execute('DELETE FROM reading_alt_kanjireading')
+        cursor.execute('DELETE FROM jp_reading_alt_kanjireading')
 
         for results in groups_of_n(max_per_insert, all_results):
             cursor.executemany(
                     """
-                    INSERT INTO reading_alt_kanjireading
+                    INSERT INTO jp_reading_alt_kanjireading
                     (kanji, reading, alternations, probability,
                         reading_alternation_id)
                     VALUES (%s, %s, %s, %s, %s)
         cursor = connection.cursor()
         cursor.execute(
                 """
-                SELECT id FROM reading_alt_kanjireading AS A
+                SELECT id FROM jp_reading_alt_kanjireading AS A
                 WHERE A.probability != (
                     SELECT MAX(B.probability)
-                    FROM reading_alt_kanjireading AS B
+                    FROM jp_reading_alt_kanjireading AS B
                     WHERE A.kanji = B.kanji AND A.reading = B.reading
                 )
                 """
             )
         ids = cursor.fetchall()
         cursor.executemany(
-                """DELETE FROM reading_alt_kanjireading WHERE id = %s""",
+                """DELETE FROM jp_reading_alt_kanjireading WHERE id = %s""",
                 ids
         )
         return