forked from UniversalDependencies/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddlanguage.sh
executable file
·105 lines (89 loc) · 3.13 KB
/
addlanguage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
### WARNING: this is a brittle and poorly tested script that makes
### bulk additions to the repository. Don't run this unless you're
### sure what you're doing and know how to clean up the repo if
### anything goes wrong.
set -u
set -e
lc=$1
language=$2
# check that no collection exists already
for c in overview pos feat dep; do
f="_${lc}-${c}"
if [ -e "$f" ]; then
echo "$f exists, not clobbering"
exit 1
fi
done
# check that no table exists already
for c in pos feat dep status; do
f="_includes/${lc}-${c}-table.html"
if [ -e "$f" ]; then
echo "$f exists, not clobbering"
exit 1
fi
done
# create a copy of each template collection
for c in overview pos feat dep; do
f="_${lc}-${c}"
cp -r "_template-$c" "$f"
done
# create copies of HTML tables
for c in pos feat dep status; do
f="_includes/${lc}-${c}-table.html"
cp "_includes/template-${c}-table.html" "$f"
done
# replace references to "template" with references to the language
# code in the copied materials:
perl -p -i -e 's/template/'"$lc"'/' "_${lc}-"{overview,pos,feat,dep}/*.md
tmp=`mktemp`
# add the newly created collections to config.yml.
(perl -pe 'exit if(/^# Template\s*$/)' _config.yml;
echo "# $language
#
${lc}-pos:
output: true
permalink: /${lc}/pos/:path.html
${lc}-feat:
output: true
permalink: /${lc}/feat/:path.html
${lc}-dep:
output: true
permalink: /${lc}/dep/:path.html
${lc}-overview:
output: true
#"
perl -pe '$past=1 if(/^# Template\s*$/); $_ = "" unless($past);' _config.yml;
) > $tmp; mv $tmp _config.yml
(perl -pe 'exit if(/^\s*<li .*"#language-other"/)' index.md;
echo ' <li class="ui-state-default"><a href="#language-'${lc}'">'${language}'</a></li>'
perl -pe '$past=1 if(/^\s*<li .*"#language-other"/);
$_ = "" unless($past);
exit if(/^\s*<!-- new tab template -->\s*$/)' index.md;
echo "<!-- \"${language}\" tab -->
<div id=\"language-${lc}\" markdown=\"1\" class=\"ui-tabs-hide\">
{% include ${lc}-status-table.html %}
[Introduction](${lc}/overview/introduction.html)
* [Tokenization](${lc}/overview/tokenization.html)
* Morphology
* [General principles](${lc}/overview/morphology.html)
* [$language POS tags](${lc}/pos/index.html) ([single document](${lc}/pos/all.html))
* [$language features](${lc}/feat/index.html) ([single document](${lc}/feat/all.html))
* Syntax
* [General principles](${lc}/overview/syntax.html)
* [Specific constructions](${lc}/overview/specific-syntax.html)
* [$language dependency relations](${lc}/dep/index.html) ([single document](${lc}/dep/all.html))
[CoNLL-U format](format.html)
<small>
This is part of the language-specific documentation for Universal
Dependencies. <strong>Language-specific guidlines are currently under
revision and should not be considered final.</strong> Our goal is to
have a stable version of this part of the documentation by 2015-01-01.
</small>
</div>
"
perl -pe '$past=1 if(/^\s*<!-- new tab template -->\s*$/);
$_ = "" unless($past)' index.md;
) > $tmp; mv $tmp index.md
git add _${lc}-{overview,pos,dep,feat} _includes/${lc}-{pos,feat,dep,status}-table.html index.md _config.yml
git commit