compobot/lib
J. Elfring (x) 4bf3fb5dad First small refactoring :)
With these tings:
- Create db during runtime
- Better generation of psv
- Lower case symbol descriptions
- Some Readme fixes
- ...
2020-09-21 21:05:46 +02:00
..
Compose.pre First small refactoring :) 2020-09-21 21:05:46 +02:00
initDb.sql First small refactoring :) 2020-09-21 21:05:46 +02:00
phrases.txt First small refactoring :) 2020-09-21 21:05:46 +02:00
README.txt First small refactoring :) 2020-09-21 21:05:46 +02:00

How to get the list of usable key-sequences?
--------------------------------------------
Download the X11 compose-sequences for en_US.UTF-8¹ and get rid of some things:
- Comments (XCOMM)
- Sequences not started my Multi_key
- Sequences containing non-standard characters
- Sequences containing other dead keys

¹) en_US.UTF-8 seems to be quite complete and also available on other locales.

$ wget https://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre
$ grep -i '^<multi' Compose.pre | grep -v '<dead' | grep -v '<U....>' | grep -v '<U.....>' > Compose.usable


Convert to psv
--------------
- Plus-separated-values because + is not used elsewhere in the file.
- Regex to extract the fields into psv.
- The second description is all-uppper, we'll convert it to all lower.

$ sed --regexp-extended 's/(.*>)\s*:\s\"(.*)\"\s*(\S*)\s*#\s*(.*)/\1+\2+\3+\L\4/' Compose.usable > Compose.psv

Load into SQLite
----------------
$ sqlite3 Compose.db3
	CREATE TABLE "keySequences" (
		"keySequence"    TEXT NOT NULL,
		"utfCharacter"   TEXT NOT NULL,
		"desc1"          TEXT,
		"desc2"          TEXT
	);
	.mode csv
	.separator "+"
	.import Compose.psv keySequences



How to get random, unique entries that do not repeat
----------------------------------------------------
Create a table for characters we already sent.
	CREATE TABLE "alreadySent" (
		"keySequenceROWID" INTEGER,
		"timestamp"        INTEGER
	);

Create a view with yet unsent characters
	CREATE VIEW stillAvailable (
		keySequenceROWID,
		keySequence,
		utfCharacter,
		desc1,desc2
		)
	AS
    	SELECT ROWID, keySequence, utfCharacter, desc1, desc2
		FROM keySequences
		WHERE ROWID NOT IN (
			SELECT keySequenceROWID
			FROM alreadySent
		);

Add some phrases to start the toot with
---------------------------------------
Create a table with some entry-phrases:
	CREATE TABLE "phrases" (
		"phrase" TEXT
	);
	.mode csv
	.separator "+"
	.import phrases.txt phrases