Skip to content

Commit 2395107

Browse files
parse annotations script
1 parent 67e4f28 commit 2395107

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ jobs:
1212
- name: Checkout 🛎️
1313
uses: actions/checkout@v6
1414

15+
- name: Prepare annotations
16+
run: |
17+
cd Input\ Processing
18+
python parse_annotations.py
19+
cd ..
20+
1521
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
1622
run: |
1723
cd site

Input Processing/parse_annotations.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def parse_annotations(filename, act_number):
6161
if len(measure_range) == 1:
6262
current_measures = [measure_range[0], measure_range[0]]
6363
else:
64+
if (len(str(measure_range[1])) < len(str(measure_range[0]))):
65+
# Number format like 123-35
66+
prefix = str(measure_range[0])[-len(str(measure_range[1]))+1:]
67+
measure_range[1] = int(prefix + str(measure_range[1]))
6468
current_measures = [measure_range[0], measure_range[1]]
6569

6670
a['annotation'] = replaceSymbols(row[2])
@@ -83,5 +87,20 @@ def test_replaceFlatSymbols():
8387
act_number = 1
8488
elif 'actiii' in f.lower():
8589
act_number = 3
90+
else:
91+
print("Cannot determine act of", f)
92+
continue
8693
all_annotations += parse_annotations('annotations/' + f, act_number)
87-
print(all_annotations)
94+
with open("../site/src/data/annotations.ts", 'w', encoding='utf8') as annotations_file:
95+
annotations_file.write("""export type AnnotationCode = 'dy' | 'du' | 'for' | 'int' | 'mo' | 'tim' | 'graph';
96+
97+
export interface Annotation {
98+
code : Array<AnnotationCode>;
99+
annotation : string;
100+
act : number;
101+
measure_range : [number, number];
102+
}
103+
104+
export const annotations : Array<Annotation> =
105+
""")
106+
annotations_file.write(str(all_annotations))

site/src/data/annotations.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)