aboutsummaryrefslogtreecommitdiff
path: root/db/dict
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-06-29 11:33:23 +0200
committerlonkaars <loek@pipeframe.xyz>2023-06-29 11:33:23 +0200
commitc998e1c0477d51c886f9e4246e102dec4d7ef8dd (patch)
tree4d979c57f16b138ff4b2ce5fb3151ce241af6881 /db/dict
parent67dbb6421976254658c5e38045513129dd18187a (diff)
add jmdict importer to repo
Diffstat (limited to 'db/dict')
-rw-r--r--db/dict/template.sql (renamed from db/dict/template.sql.m4)23
1 files changed, 16 insertions, 7 deletions
diff --git a/db/dict/template.sql.m4 b/db/dict/template.sql
index 00de413..1a07252 100644
--- a/db/dict/template.sql.m4
+++ b/db/dict/template.sql
@@ -14,9 +14,18 @@ create temporary table ingest(
glossary_tags text null default null -- add tags to single glossary entry
);
-include(`/dev/stdin')dnl --'
--- the apostrophe is so my editor highlighting keeps working if I force the
--- filetype to sql instead of m4
+-- #DICTIONARY_CONTENT_BEGIN
+-- this template is 'rendered' by pasting a .dict.sql file in between these
+-- DICTIONARY_CONTENT markers. the makefile can render these using the
+-- following m4 code (called using m4 -P template.sql < any.dict.sql):
+--
+-- m4_undivert(`/dev/stdin')
+--
+-- this breaks when the first line of the input file is not a comment or empty
+-- line, so the makefile accounts for this by concatenating an empty line with
+-- the dict first. the runtime typescript dictionary importer handles this by
+-- not calling m4 for this.
+-- #DICTIONARY_CONTENT_END
-- create dict id
insert into dict (tag, language) values ('dict:' || :dict, :lang);
@@ -49,8 +58,8 @@ with tag_map(term_id, temp, tag) as (
union
select
term_id,
- `substr'(temp, instr(temp, ' ') + 1),
- `substr'(temp, 0, instr(temp, ' '))
+ substr(temp, instr(temp, ' ') + 1),
+ substr(temp, 0, instr(temp, ' '))
from tag_map
where length(temp) > 1
)
@@ -71,8 +80,8 @@ with tag_map(definition_id, temp, tag) as (
union
select
definition_id,
- `substr'(temp, instr(temp, ' ') + 1),
- `substr'(temp, 0, instr(temp, ' '))
+ substr(temp, instr(temp, ' ') + 1),
+ substr(temp, 0, instr(temp, ' '))
from tag_map
where length(temp) > 1
)