-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,145 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
-- Create procedure to check for prolog constraints | ||
DELIMITER // | ||
CREATE PROCEDURE stixd_corpus.check_prolog_constraints(IN base_form VARCHAR(255)) | ||
BEGIN | ||
DECLARE done INT DEFAULT FALSE; | ||
DECLARE constraint_violation VARCHAR(255); | ||
DECLARE constraint_message VARCHAR(255); | ||
|
||
DECLARE cur CURSOR FOR SELECT pattern, message FROM stixd_corpus.prolog_constraints; | ||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; | ||
|
||
OPEN cur; | ||
|
||
read_loop: LOOP | ||
FETCH cur INTO constraint_violation, constraint_message; | ||
IF done THEN | ||
LEAVE read_loop; | ||
END IF; | ||
IF NOT (base_form REGEXP constraint_violation) THEN | ||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = constraint_message; | ||
END IF; | ||
END LOOP; | ||
|
||
CLOSE cur; | ||
END; | ||
// | ||
DELIMITER ; | ||
|
||
-- Create main procedure to check lexicon constraints | ||
DELIMITER // | ||
CREATE PROCEDURE stixd_corpus.sp_check_lexicon_constraints( | ||
IN new_base_form VARCHAR(255), | ||
IN new_word_class VARCHAR(31), | ||
IN new_preposition INT, | ||
IN new_gender VARCHAR(7) | ||
) | ||
BEGIN | ||
-- Step 1: Check prolog constraints | ||
CALL stixd_corpus.check_prolog_constraints(new_base_form); | ||
|
||
-- Step 2: Check prohibited words | ||
DECLARE prohibited_word_found INT DEFAULT 0; | ||
SELECT COUNT(*) | ||
INTO prohibited_word_found | ||
FROM stixd_corpus.prohibited_words | ||
WHERE word = new_base_form; | ||
|
||
IF prohibited_word_found > 0 THEN | ||
SIGNAL SQLSTATE '45000' | ||
SET MESSAGE_TEXT = 'base_form contains a prohibited word'; | ||
END IF; | ||
|
||
-- Step 3: Check prohibited intersections | ||
CALL stixd_corpus.check_prohib_intersections(new_base_form); | ||
|
||
-- Step 4: Ensure preposition is not null if word_class starts with adj_tr or dv_ | ||
IF (new_word_class LIKE 'adj_tr%' OR new_word_class LIKE 'dv_%') THEN | ||
IF (new_preposition IS NULL) THEN | ||
SIGNAL SQLSTATE '45000' | ||
SET MESSAGE_TEXT = 'preposition must be NOT NULL if word_class starts with "adj_tr" or "dv_"'; | ||
END IF; | ||
END IF; | ||
|
||
-- Step 5: Ensure gender is not null if word_class starts with noun_ or pn | ||
IF (new_word_class LIKE 'noun_%' OR new_word_class LIKE 'pn%') THEN | ||
IF (new_gender IS NULL) THEN | ||
SIGNAL SQLSTATE '45000' | ||
SET MESSAGE_TEXT = 'gender must be NOT NULL if word_class starts with "noun_" or "pn"'; | ||
END IF; | ||
END IF; | ||
|
||
-- Step 6: Enforce the mutual exclusivity of preposition and gender | ||
IF (new_preposition IS NOT NULL AND new_gender IS NOT NULL) THEN | ||
SIGNAL SQLSTATE '45000' | ||
SET MESSAGE_TEXT = 'preposition and gender cannot both be NOT NULL'; | ||
END IF; | ||
END// | ||
// | ||
DELIMITER ; |
2 changes: 1 addition & 1 deletion
2
...edures/17_pr_check_prolog_constraints.sql → ...rocedures/sp_check_prolog_constraints.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
DELIMITER // | ||
|
||
CREATE PROCEDURE stixd_corpus.run_seed_scripts() | ||
BEGIN | ||
-- Seed Genders | ||
SET @sql = 'SOURCE ../seeds/seed_genders.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
|
||
-- Seed Prohibited Words | ||
SET @sql = 'SOURCE ../seeds/seed_prohib_words.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
|
||
-- Seed Prohibited Intersections | ||
SET @sql = 'SOURCE ../seeds/seed_prohib_intersections.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
|
||
-- Seed Prolog Constraints | ||
SET @sql = 'SOURCE ../seeds/seed_prolog_constraints.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
|
||
-- Seed Word Tags | ||
SET @sql = 'SOURCE ../seeds/seed_word_tags.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
|
||
-- Seed Special Characters | ||
SET @sql = 'SOURCE ../seeds/seed_spec_chars.sql'; | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
END // | ||
|
||
DELIMITER ; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
info579/sql/schema/tables/03_create_table_prohib_intersections.sql
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Create the stixd_corpus.word_tags table in the specified database | ||
-- DROP TABLE IF EXISTS stixd_corpus.word_tags; | ||
CREATE TABLE IF NOT EXISTS stixd_corpus.word_tags ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
word_tag VARCHAR(12) NOT NULL, | ||
first_arg VARCHAR(31) NOT NULL, | ||
second_arg VARCHAR(31) NOT NULL, | ||
third_arg VARCHAR(31) DEFAULT NULL, | ||
word_class VARCHAR(31) NOT NULL | ||
); | ||
|
||
-- SHOW CREATE TABLE stixd_corpus.word_tags | ||
|
||
-- Populating the table done with SQL seed script. |
6 changes: 3 additions & 3 deletions
6
...ema/tables/22_create_table_doc_lex_jt.sql → ...schema/tables/create_table_doc_lex_jt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ma/tables/21_create_table_doc_sent_jt.sql → ...chema/tables/create_table_doc_sent_jt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Create the stixd_corpus.documents table | ||
-- DROP TABLE IF EXISTS stixd_corpus.documents; | ||
CREATE TABLE IF NOT EXISTS stixd_corpus.documents ( | ||
doc_id INT AUTO_INCREMENT PRIMARY KEY, | ||
raw_text LONGTEXT, | ||
raw_text_hash CHAR(64) UNIQUE, | ||
proc_text JSON, | ||
metadata JSON | ||
); | ||
-- SHOW CREATE TABLE stixd_corpus.documents; | ||
|
||
-- Populating table done from Python script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Create the stixd_corpus.genders table | ||
-- DROP TABLE IF EXISTS stixd_corpus.genders; | ||
CREATE TABLE IF NOT EXISTS stixd_corpus.genders ( | ||
gender VARCHAR(7) PRIMARY KEY | ||
); | ||
-- SHOW CREATE TABLE stixd_corpus.genders; | ||
|
||
-- Populating the table done with SQL seed script. |
6 changes: 3 additions & 3 deletions
6
...schema/tables/09_create_table_lexicon.sql → ...ql/schema/tables/create_table_lexicon.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ema/tables/20_create_table_obj_doc_jt.sql → ...schema/tables/create_table_obj_doc_jt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ema/tables/24_create_table_obj_lex_jt.sql → ...schema/tables/create_table_obj_lex_jt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
info579/sql/schema/tables/create_table_prohib_intersections.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Create the stixd_corpus.prohibited_intersections table | ||
-- DROP TABLE IF EXISTS stixd_corpus.prohibited_intersections; | ||
CREATE TABLE IF NOT EXISTS stixd_corpus.prohibited_intersections ( | ||
class1 VARCHAR(31), | ||
class2 VARCHAR(31), | ||
PRIMARY KEY (class1, class2) | ||
); | ||
-- SHOW CREATE TABLE stixd_corpus.prohibited_intersections; | ||
|
||
-- Populating the table done with SQL seed script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Create the stixd_corpus.prohibited_words table | ||
-- DROP TABLE IF EXISTS stixd_corpus.prohibited_words; | ||
CREATE TABLE IF NOT EXISTS stixd_corpus.prohibited_words ( | ||
word VARCHAR(20) PRIMARY KEY | ||
); | ||
-- SHOW CREATE TABLE stixd_corpus.prohibited_words; | ||
|
||
-- Populating the table done with SQL seed script. |
6 changes: 3 additions & 3 deletions
6
...es/04_create_table_prolog_constraints.sql → ...ables/create_table_prolog_constraints.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ma/tables/23_create_table_sent_lex_jt.sql → ...chema/tables/create_table_sent_lex_jt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.