Skip to content

Commit

Permalink
feat(database): started new database generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
camarm-dev committed Jul 5, 2024
1 parent 87d515c commit 9200f23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
17 changes: 6 additions & 11 deletions scripts/add_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sqlite3
import sys

from scripts.utils.dictionary_database import RemedeDatabase
from scripts.utils.sanitize import sanitize_word


Expand Down Expand Up @@ -70,19 +71,13 @@ def getTimeDetails(time_object):
document = get_word_document(word, phoneme)
print("Fait.")

print("- Ajout du document aux bases JSON")
add_to_json(word, document)
print("- Insertion du document Remède...")
database.insert(word, phoneme)
print("Fait.")

print("- Ajout du document à la base Sqlite")
insert_document(document, word)
print("Fait.")

print("- Mise à jour de l'index...")
cursor.execute("INSERT INTO wordlist VALUES (?,?)", (word, sanitize_word(word)))
print("Fait.")


print("- Sauvegarde de la base de données...")
database.save()
print("Fait.")
print("- Génération des ressources...")
runpy.run_module('pre_generate_ressources', run_name='__main__')
print("Fait.")
Expand Down
5 changes: 3 additions & 2 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scripts.utils.dataset import get_words, get_word2ipa, get_custom_words
from scripts.utils.dictionary_database import RemedeDatabase
from scripts.utils.sanitize import sanitize_word
from scripts.utils.scrap import get_conjugaisons, get_synonyms, get_antonyms, count_syllables
from scripts.utils.scrap import get_conjugaisons, get_synonyms, get_antonyms, count_syllables, get_word_stats

modes_conjugation_subjects = {
"Participe_Présent": "(en)",
Expand Down Expand Up @@ -94,7 +94,8 @@ def remedize(word_list: list):
if not document:
errored += 1
# TODO nature
database.insert(word, sanitize_word(word), ipa, "", count_syllables(ipa), )
elidable, feminine, syllables = get_word_stats(word, ipa)
database.insert(word, sanitize_word(word), ipa, "", syllables, elidable, feminine, document)
print(f"\033[A\033[KMot n°{word_list.index(word) + 1}/{total}: \"{word}\"{' ' * (22 - len(word))} | {errored} erreurs")


Expand Down
1 change: 1 addition & 0 deletions scripts/utils/scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_word_stats(word: str, phoneme: str):
:param phoneme: phoneme of word
:return: Elidable, Feminine, Syllable count
"""
# TODO find with drime database
return False, phoneme[-1] == 'e', count_syllables(word.lower())


Expand Down

0 comments on commit 9200f23

Please sign in to comment.