@@ -7,6 +7,7 @@ import type {
77 ConfigYaml ,
88 CategoryPropertyYaml ,
99 LemmaYaml ,
10+ CategoryImplicationYaml ,
1011} from './yaml.types'
1112
1213const db = get_client ( )
@@ -27,9 +28,9 @@ function seed() {
2728
2829 seed_lemmas ( )
2930 seed_category_properties ( )
31+ seed_category_implications ( )
3032 seed_categories ( )
3133
32- // TODO: seed implications
3334 // TODO: seed functors
3435 // TODO: seed all the remaining tables
3536}
@@ -307,3 +308,56 @@ function seed_lemmas() {
307308 }
308309 } ) ( )
309310}
311+
312+ function seed_category_implications ( ) {
313+ const implications_folder = path . join ( data_folder , 'category-implications' )
314+
315+ const implication_files = fs
316+ . readdirSync ( implications_folder )
317+ . filter ( ( file ) => file . endsWith ( '.yaml' ) )
318+ . sort ( )
319+
320+ const implication_insert = db . prepare (
321+ `INSERT INTO category_implications (
322+ id, reason, is_equivalence
323+ ) VALUES (?, ?, ?)` ,
324+ )
325+
326+ const assumption_insert = db . prepare (
327+ `INSERT INTO category_implication_assumptions (
328+ implication_id, property_id
329+ ) VALUES (?, ?)` ,
330+ )
331+
332+ const conclusion_insert = db . prepare (
333+ `INSERT INTO category_implication_conclusions (
334+ implication_id, property_id
335+ ) VALUES (?, ?)` ,
336+ )
337+
338+ db . transaction ( ( ) => {
339+ for ( const implication_file of implication_files ) {
340+ const content = fs . readFileSync (
341+ path . join ( implications_folder , implication_file ) ,
342+ 'utf8' ,
343+ )
344+ const implications = YAML . parse ( content ) as CategoryImplicationYaml [ ]
345+
346+ for ( const implication of implications ) {
347+ implication_insert . run (
348+ implication . id ,
349+ implication . reason ,
350+ Number ( implication . is_equivalence ) ,
351+ )
352+
353+ for ( const assumption of implication . assumptions ) {
354+ assumption_insert . run ( implication . id , assumption )
355+ }
356+
357+ for ( const conclusion of implication . conclusions ) {
358+ conclusion_insert . run ( implication . id , conclusion )
359+ }
360+ }
361+ }
362+ } ) ( )
363+ }
0 commit comments