Add french word and GP database

This commit is contained in:
BimDav
2023-03-08 17:39:00 +01:00
parent e41c19896d
commit 686b85a9a6
7 changed files with 150 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2023 Piet Bronders & Jeroen De Geeter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
[configuration]
entry_symbol = "sqlite_library_init"
[libraries]
macos = "res://addons/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework"
macos.template_release = "res://addons/godot-sqlite/bin/libgdsqlite.macos.template_release.framework"
windows.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.windows.template_debug.x86_64.dll"
windows.template_release.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.windows.template_release.x86_64.dll"
linux.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.linux.template_debug.x86_64.so"
linux.template_release.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.linux.template_release.x86_64.so"
[dependencies]
macos = {}
macos.template_release = {}
windows.x86_64 = {}
windows.template_release.x86_64 = {}
linux.x86_64 = {}
linux.template_release.x86_64 = {}
+14
View File
@@ -0,0 +1,14 @@
# ############################################################################ #
# Copyright © 2019-2023 Piet Bronders & Jeroen De Geeter <piet.bronders@gmail.com>
# Licensed under the MIT License.
# See LICENSE in the project root for license information.
# ############################################################################ #
@tool
extends EditorPlugin
func _enter_tree():
pass
func _exit_tree():
pass
+7
View File
@@ -0,0 +1,7 @@
[plugin]
name="Godot SQLite"
description="GDNative wrapper for SQLite (Godot 4.X+), making it possible to use SQLite databases as data storage in all your future games."
author="Piet Bronders & Jeroen De Geeter"
version="4.0-rc1"
script="godot-sqlite.gd"
Binary file not shown.
+5
View File
@@ -23,6 +23,7 @@ buses/default_bus_layout="res://resources/audio_buses/main_audio_bus_layout.tres
LessonLogger="*res://sources/utils/autoloads/lesson_logger.gd"
UserDataManager="*res://sources/utils/autoloads/user_data_manager.gd"
Database="*res://sources/utils/autoloads/Database.gd"
[display]
@@ -32,6 +33,10 @@ window/size/window_width_override=1280
window/size/window_height_override=900
window/stretch/mode="canvas_items"
[editor_plugins]
enabled=PackedStringArray("res://addons/godot-sqlite/plugin.cfg")
[gui]
theme/custom="res://resources/themes/kalulu_theme.tres"
+82
View File
@@ -0,0 +1,82 @@
extends Node
const db_path: = "res://language_resources/fr/fr.db"
@onready var db: = SQLite.new()
func _ready() -> void:
db.path = db_path
db.open_db()
func _exit_tree() -> void:
db.close_db()
func get_GP_for_lesson(lesson_nb: int) -> Array:
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb <= ?", [lesson_nb])
return db.query_result
func get_GP_from_word(word: String) -> Array:
db.query_with_bindings("SELECT Grapheme, Phoneme FROM Words INNER JOIN GPsInWords ON Words.ID = GPsInWords.WordID AND Words.Word=? INNER JOIN GPs WHERE GPS.ID = GPsInWords.GPID ORDER BY Position", [word])
return db.query_result
func get_words_containing_grapheme(grapheme: String) -> Array:
db.query_with_bindings("SELECT Word FROM Words INNER JOIN GPsInWords INNER JOIN GPs on Words.ID = GPsInWords.WordID AND GPs.Grapheme=? AND GPS.ID = GPsInWords.GPID", [grapheme])
return db.query_result
# Import data from previous Kalulu version
func _import_gps(db) -> void:
var file = FileAccess.open("res://data3/gp_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
var g = e.GRAPHEME
var p = e.PHONEME
db.query_with_bindings("SELECT * FROM GPs WHERE Grapheme=? AND Phoneme=?", [g, p])
if db.query_result.is_empty():
db.insert_row("GPs", {Grapheme=g, Phoneme=p})
db.query_with_bindings("SELECT * FROM GPs WHERE Grapheme=? AND Phoneme=?", [g, p])
print(db.query_result)
func _import_words(db) -> void:
var file = FileAccess.open("res://data3/words_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
db.query_with_bindings("SELECT * FROM Words WHERE Word=?", [e.GRAPHEME])
if db.query_result.is_empty():
db.insert_row("Words", {Word=e.GRAPHEME})
db.query_with_bindings("SELECT * FROM Words WHERE Word=?", [e.GRAPHEME])
var word_id = db.query_result[0]["ID"]
var GP_list_str: String = e.GPMATCH
var GP_list: = GP_list_str.split(".")
for i in GP_list.size():
var GP_str = GP_list[i]
var GP = GP_str.split("-")
db.query_with_bindings("SELECT * FROM GPs WHERE Grapheme=? AND Phoneme=?", [GP[0], GP[1]])
var GP_id = db.query_result[0]["ID"]
db.insert_row("GPsInWords", {
WordID = word_id,
GPID = GP_id,
Position = i,
})
func _import_lessons(db) -> void:
var file = FileAccess.open("res://data3/gp_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
var g = e.GRAPHEME
var p = e.PHONEME
db.query_with_bindings("SELECT * FROM GPs WHERE Grapheme=? AND Phoneme=?", [g, p])
var GP_id = db.query_result[0]["ID"]
var lesson_nb: = int(e.LESSON)
db.insert_row("Lessons", {
GPID = GP_id,
LessonNb = lesson_nb
})