diff options
author | Peng Wu <alexepico@gmail.com> | 2012-07-18 17:24:55 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-07-18 17:25:20 +0800 |
commit | 007a7871e4b6c0e7beb90ceba1abdd439eb2329b (patch) | |
tree | 789ac4c00cc001cab2baab92bc7d5ff72649a0a2 | |
parent | 47e41081fcc385894c8aa2694fdad41db65db42e (diff) | |
download | ibus-libpinyin-007a7871e4b6c0e7beb90ceba1abdd439eb2329b.tar.gz ibus-libpinyin-007a7871e4b6c0e7beb90ceba1abdd439eb2329b.tar.xz ibus-libpinyin-007a7871e4b6c0e7beb90ceba1abdd439eb2329b.zip |
write strokes.awk
-rw-r--r-- | data/english.awk | 6 | ||||
-rw-r--r-- | data/strokes.awk | 29 |
2 files changed, 32 insertions, 3 deletions
diff --git a/data/english.awk b/data/english.awk index 1828d2c..c5dc0aa 100644 --- a/data/english.awk +++ b/data/english.awk @@ -6,7 +6,7 @@ BEGIN { # Create english table print "CREATE TABLE IF NOT EXISTS \"english\" ( " \ - "\"word\" TEXT NOT NULL PRIMARY KEY," \ + "\"word\" TEXT NOT NULL PRIMARY KEY," \ "\"freq\" FLOAT NOT NULL DEFAULT(0)" \ ");"; @@ -16,10 +16,10 @@ BEGIN { } # Insert data into english table - { printf "INSERT INTO english (word, freq) VALUES (\"%s\", \"%f\");\n", $1, $2} + { printf "INSERT INTO english (word, freq) VALUES (\"%s\", %f);\n", $1, $2} #quit sqlite3 END { # Commit the transcation print "COMMIT;" -}
\ No newline at end of file +} diff --git a/data/strokes.awk b/data/strokes.awk new file mode 100644 index 0000000..5c61062 --- /dev/null +++ b/data/strokes.awk @@ -0,0 +1,29 @@ +#!/usr/bin/awk + +BEGIN { + # Begin a transaction + print "BEGIN TRANSACTION;" + + # Create english table + print "CREATE TABLE IF NOT EXISTS \"strokes\" ( " \ + "\"character\" TEXT NOT NULL," \ + "\"sequence\" INTEGER NOT NULL," \ + "\"strokes\" TEXT NOT NULL," \ + "\"token\" INTEGER NOT NULL DEFAULT (0)" \ + ");"; + + # Create desc table + print "CREATE TABLE IF NOT EXISTS desc (name TEXT PRIMARY KEY, value TEXT);"; + print "INSERT OR IGNORE INTO desc VALUES ('version', '1.2.0');"; +} + + # Insert data into english table +NF == 4 { + printf "INSERT INTO strokes (\"character\", \"sequence\", strokes, token) VALUES (\"%s\", %d, \"%s\", %d);\n", $1, $2, $3, $4; + } + + #quit sqlite3 +END { + # Commit the transcation + print "COMMIT;" +} |