parent
90a6cda9fe
commit
f609177d33
@ -0,0 +1,8 @@
|
|||||||
|
# Build
|
||||||
|
|
||||||
|
To build, you need transcrypt, you need to do npm install and then you need api key for gitea (`token=$API_KEY`), just find this on gitea.cjvt.si, not that hard.
|
||||||
|
|
||||||
|
After you have all of this, move to build folder, set `API_KEY` environment variable and then build it just using `make` or for release use `make release` - optimized javascript build.
|
||||||
|
|
||||||
|
For me its `API_KEY=(cat ~/.gitea_api_key) make`.
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# fail if any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -z "${API_KEY}" ]]; then
|
||||||
|
echo "API_KEY not defined, should be api key to CJVT's gitea"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OUT_FILE=conversions.csv
|
||||||
|
|
||||||
|
rm -f $OUT_FILE
|
||||||
|
|
||||||
|
for fname in glagol pridevnik prislov samostalnik; do
|
||||||
|
curl -s "https://gitea.cjvt.si/api/v1/repos/redmine_projects/kolokacije/contents/resources/structure_conversions/$fname.csv?token=$API_KEY" |
|
||||||
|
python3 -c "import sys, json; print(json.load(sys.stdin)['content'])" | base64 -d >> $OUT_FILE
|
||||||
|
done
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
__pragma__ ('noanno')
|
||||||
|
__pragma__ ('js', """
|
||||||
|
var fs = require('fs');
|
||||||
|
var conversion_csv = fs.readFileSync('build/conversions.csv', 'utf8');
|
||||||
|
""", None)
|
||||||
|
# above is magically read (browserify plugin) at compile time
|
||||||
|
# browserify is run from root, so we need build/ in path for this to work
|
||||||
|
|
||||||
|
# convert to useful structure
|
||||||
|
structure_conversions = None
|
||||||
|
|
||||||
|
def build_structure_conversions():
|
||||||
|
global structure_conversions
|
||||||
|
structure_conversions = []
|
||||||
|
|
||||||
|
structure_conversions_raw = [line.split(",") for line in conversion_csv.split("\n")]
|
||||||
|
for line in structure_conversions_raw:
|
||||||
|
if min(len(line[0]), len(line[1])) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# header
|
||||||
|
if line[1] == "struktura":
|
||||||
|
continue
|
||||||
|
|
||||||
|
vfrom = line[0].replace("?", "\?").replace("%s", "([a-zA-Z螚ȎŠ-]+)")
|
||||||
|
vmatch = "^" + vfrom + "$"
|
||||||
|
vto = line[1].replace("<struktura>", "").replace("</struktura>", "").replace("%s", "$1").strip()
|
||||||
|
|
||||||
|
structure_conversions.append((__new__(RegExp(vmatch, 'u')),
|
||||||
|
__new__(RegExp(vfrom, 'u')),
|
||||||
|
vto))
|
||||||
|
|
||||||
|
|
||||||
|
def convert_structure(structure):
|
||||||
|
if structure_conversions is None:
|
||||||
|
build_structure_conversions()
|
||||||
|
|
||||||
|
for vmatch, vfrom, vto in structure_conversions:
|
||||||
|
if vmatch.test(structure):
|
||||||
|
# for some reason some times this fails to do correct replacement, but this helps #FML
|
||||||
|
# structure += " "
|
||||||
|
return structure.replace(vfrom, vto).strip()
|
||||||
|
|
||||||
|
return None
|
Loading…
Reference in new issue