aboutsummaryrefslogtreecommitdiff
path: root/challenge-024/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-024/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-024/paulo-custodio/python/ch-2.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/challenge-024/paulo-custodio/python/ch-2.py b/challenge-024/paulo-custodio/python/ch-2.py
index 7b3aff407a..6f4ab47bb9 100644
--- a/challenge-024/paulo-custodio/python/ch-2.py
+++ b/challenge-024/paulo-custodio/python/ch-2.py
@@ -47,6 +47,9 @@ def create_database():
word_id INTEGER
);
''')
+ cur.execute('''
+ CREATE UNIQUE INDEX found_index ON found(document_id, word_id);
+ ''')
con.commit()
con.close()
@@ -94,7 +97,7 @@ def add_found(con, document_id, word_id):
def add_doc(file):
con = sqlite3.connect(DBFILE)
- title = os.path.basename(file)
+ title = re.sub(r"\.\w+$", "", os.path.basename(file))
document_id = get_document_id(con, title)
# read document