remove punctuation and upper case problems

This commit is contained in:
BimDav
2024-02-09 10:44:02 +01:00
parent 1211226ccd
commit 1f332def33
2 changed files with 10 additions and 5 deletions
@@ -11,10 +11,14 @@ func update_lesson() -> void:
func _add_from_additional_word_list(new_text: String) -> int:
var punc: = "'!()[]{};:'\"\\,<>./?@#$%^&*_~"
var new_text_clean: = new_text.to_lower()
for char in punc:
new_text_clean = new_text_clean.replace(char, " ")
var word_list_element: = word_list_element_scene.instantiate()
var all_found: = true
var word_ids: Array[int] = []
for word in new_text.split(" "):
for word in new_text_clean.split(" "):
var word_id: int = word_list_element._try_to_complete_from_word(word)
word_ids.append(word_id)
if word_id < 0:
@@ -23,7 +27,7 @@ func _add_from_additional_word_list(new_text: String) -> int:
if all_found:
gp_ids = word_ids
unvalidated_gp_ids = gp_ids
graphemes = new_text
graphemes = new_text_clean
Database.db.insert_row("Sentences", {
Sentence = new_text,
+4 -3
View File
@@ -279,12 +279,12 @@ func insert_in_database() -> void:
func _already_in_database(text: String) -> int:
var query: = "SELECT ID, %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %sIDs
var query: = "SELECT %s.ID, %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %sIDs
FROM %s
INNER JOIN ( SELECT * FROM %s ORDER BY %s.Position ) %s ON %s.ID = %s.%sID
INNER JOIN %s ON %s.ID = %s.%s
WHERE %s.%s = ?
GROUP BY %s.ID" % [table_graph_column, sub_table_graph_column, sub_table_graph_column,
GROUP BY %s.ID" % [table, table_graph_column, sub_table_graph_column, sub_table_graph_column,
sub_table_phon_column, sub_table_phon_column,
relational_table, relational_table,
table,
@@ -295,7 +295,8 @@ func _already_in_database(text: String) -> int:
Database.db.query_with_bindings(query, [text])
if not Database.db.query_result.is_empty():
var e = Database.db.query_result[0]
graphemes_edit.text = e[sub_table_graph_column + "s"]
if graphemes_edit:
graphemes_edit.text = e[sub_table_graph_column + "s"]
id = e.ID
return id
return -1