Ada Young avatar Ada Young committed 97a7d58

extended data model to include race and gender as well

Comments (0)

Files changed (1)

   >
   <send>
 desc_text = []
+gender = gender_map["%1"]
+race = "%2".split(' ')
+if len(race) > 1:
+    race = race[1]
+else:
+    race = race[0]
 desc_text.append("%0")
 world.EnableTrigger("CaptureAll", True)
 world.EnableTrigger("DescriptionEnd", True)
     cursor.execute("""
     CREATE TABLE IF NOT EXISTS descriptions (
         id INTEGER PRIMARY KEY AUTOINCREMENT,
-        description TEXT,
-        name TEXT
+        name TEXT,
+        race TEXT,
+        gender TEXT,
+        description TEXT
     )""")
     cursor.execute("""
-    CREATE VIRTUAL TABLE IF NOT EXISTS desc_fts USING fts4(content="descriptions", f_content)
-    """)
+    CREATE VIRTUAL TABLE IF NOT EXISTS desc_fts USING fts4 (
+        content="descriptions",
+        name,
+        race,
+        gender,
+        description
+    )""")
     cursor.execute("""
     CREATE TRIGGER IF NOT EXISTS descriptions_ai AFTER INSERT ON descriptions BEGIN
-        INSERT INTO desc_fts(docid, f_content) VALUES(new.rowid, new.description);
+        INSERT INTO desc_fts(docid, name, race, gender, description) VALUES(new.rowid, new.name, new.race, new.gender, new.description);
     END;
     """)
     cursor.execute("""
     db.commit()
 
 createdb()
+
 desc_text = []
+gender = ""
+race = ""
 name = ""
 
+gender_map = {
+    "She" : "female",
+    "He" : "male",
+}
+
 def ProcessDescription(description):
     split_desc = re.split("A rune.+?\.", description)
     description = "".join(split_desc)
+
     split_desc = re.split("(?:He|She) walks with the .+?favour.+?\.", description)
     description = "".join(split_desc)
 
     cursor.execute("SELECT name, description FROM descriptions WHERE name=? AND description=?", (name, description))
     results = cursor.fetchall()
     if not len(results) > 0:
-        cursor.execute("INSERT INTO descriptions (name, description) VALUES (?, ?)", (name, description))
+        cursor.execute("INSERT INTO descriptions (name, race, gender, description) VALUES (?, ?, ?, ?)", (name, race, gender, description))
         db.commit()
 ]]>
 </script>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.