Skip to content

Commit

Permalink
Update API example to zip on run
Browse files Browse the repository at this point in the history
  • Loading branch information
pmachapman committed Nov 11, 2024
1 parent f1a28c6 commit cb00855
Show file tree
Hide file tree
Showing 23 changed files with 656 additions and 8 deletions.
5 changes: 1 addition & 4 deletions samples/ApiExample/ApiExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\TEA.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\TMA.zip">
<Content Include="data\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions samples/ApiExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.IO.Compression;
using ApiExample;
using IdentityModel.Client;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -95,9 +96,12 @@ async Task CreatePreTranslationEngineAsync(CancellationToken cancellationToken)
{
// 1a. Create the source data file
Console.WriteLine("Create a source data file");
const string SourceFileName = "TEA.zip";
await using (Stream sourceFileStream = File.OpenRead(Path.Combine("data", SourceFileName)))
const string SourceDirectory = "TEA";
const string SourceFileName = $"{SourceDirectory}.zip";
await using (var sourceFileStream = new MemoryStream())
{
ZipFile.CreateFromDirectory(Path.Combine("data", SourceDirectory), sourceFileStream);
sourceFileStream.Seek(0, SeekOrigin.Begin);
DataFile sourceDataFile = await dataFilesClient.CreateAsync(
new FileParameter(sourceFileStream, SourceFileName),
FileFormat.Paratext,
Expand All @@ -109,9 +113,12 @@ async Task CreatePreTranslationEngineAsync(CancellationToken cancellationToken)

// 1b. Create the target data file
Console.WriteLine("Create a target data file");
const string TargetFileName = "TMA.zip";
await using (Stream targetFileStream = File.OpenRead(Path.Combine("data", TargetFileName)))
const string TargetDirectory = "TMA";
const string TargetFileName = $"{TargetDirectory}.zip";
await using (var targetFileStream = new MemoryStream())
{
ZipFile.CreateFromDirectory(Path.Combine("data", TargetDirectory), targetFileStream);
targetFileStream.Seek(0, SeekOrigin.Begin);
DataFile targetDataFile = await dataFilesClient.CreateAsync(
new FileParameter(targetFileStream, TargetFileName),
FileFormat.Paratext,
Expand Down
Binary file removed samples/ApiExample/data/TEA.zip
Binary file not shown.
66 changes: 66 additions & 0 deletions samples/ApiExample/data/TEA/84MANTEA.SFM
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
\id MAN - Test English Apocrypha
\h Prayer of Manasseh
\toc1 Prayer of Manasseh
\toc2 Prayer of Manasseh
\toc3 Prayer of Manasseh
\mt1 Prayer of Manasseh\f + \fr 1.0 \ft Latin adds \fq King of Judah when he was held captive in Babylon\f*
\imt Introduction
\ip This prayer for forgiveness purports to be from King Manasseh during his imprisonment (see \xt 2 Chronicles 33:19\xt*), and appears to be originally written in Greek. It is found in the eighth chapter in the Book of Odes (chapter 12 in Rahlf’s edition), and is present in the Eastern Orthodox canon.
\c 1
\q1
\v 1 Lord Almighty,\f + \fr 1.1 \fq Almighty \ft Codex Alexandrinus adds \fq in heaven\f*
\q2 the God of our fathers:\x - \xo 1.1 \xt 2 Chr 33:12\x*
\q1 of Abraham, and Isaac, and Jacob,\x - \xo 1.1 \xt Ex 3:15, 16; Acts 3:13\x*
\q2 and of their righteous seed;
\q1
\v 2 Who made heaven and the earth, and\f + \fr 1.2 \fq and \ft Greek \fq with\f* all the universe\f + \fr 1.2 \fq universe \ft Or \fqa adornment\fqa*. Greek \fq cosmos\fq*\f* within;
\q1
\v 3 Who bound the sea by the word of your command,\x - \xo 1.3 \xt Job 33:8-11; Ps 74:12\x*
\q2 who closed the abyss and sealed it by your terrible and glorious name.
\q1
\v 4 Who all things shudder and tremble before, because of your power;
\q1
\v 5 For your majesty and glory is unbearable,
\q1 and the anger of your threat towards sinners is unendurable;
\q1
\v 6 Both immeasurable and unsearchable is the mercy of your promise;\x - \xo 1.6 \xt Rom 11:33\x*
\q1
\v 7 For you are the Lord Most High,
\q2 tender-hearted, longsuffering, abounding in mercy,\x - \xo 1.7 \xt Ex 34:6; Ps 86:15; Joel 2:13\x*
\q3 and you repent at the time of man’s trouble.\f + \fr 1.7 \ft Latin adds \fq Lord, according to your great goodness, you have promised repentance and forgiveness to those that have sinned against you, and in your infinite mercy have appointed repentance for sinners, so that they may be saved.\f*
\q1
\v 8 Therefore you, Lord, the God of the righteous,
\q2 has not made repentance for the righteous,\x - \xo 1.8 \xt Lk 5:32\x*
\q1 for Abraham, and Isaac, and Jacob did not sin against you,
\q2 but you made repentance for me, a sinner.
\q1
\v 9 Therefore my sins number more than the sand of the sea,
\q2 \f + \fr 1.9 \ft Codex Alexandrinus adds \fq For\f*my transgressions are multiplied, Lord, \add they\add*\f + \fr 1.9 \ft Latin reads \fq my transgressions\f* are multiplied,\f + \fr 1.9 \fq Lord, they are multiplied, \ft Codex Alexandrinus omits.\f*\x - \xo 1.9 \xt Is 59:12 \x*
\q1 and I am not worthy to look upon and see the height of heaven,
\q2 because of the multitude of my iniquities.\f + \fr 1.9 \ft Latin adds \fq Lord I now suffer justly, I deserve the trouble I receive, I am caught in a trap.\f*\x - \xo 1.9 \xt Ezra 9:6\x*
\q1
\v 10 I am bowed down by many iron chains,\x - \xo 1.10 \xt 2 Chr 33:11\x*
\q2 I am rejected because of my sins,\f + \fr 1.10 \fq I am rejected because of my sins, \ft Latin reads \fq so that I cannot lift up my head,\f*
\q3 and I can find\f + \fr 1.10 \fq can find \ft Greek \fqa have\f* no rest;
\q1 Therefore I have kindled your anger,
\q2 I have done evil before you,\f + \fr 1.10 \ft Latin adds \fq I did not your will\f*
\q3 setting up abominations and abominable things.\f + \fr 1.10 \fq abominable things. \ft Greek \fqa objects of anger\fqa*. This word is often translated abominations (see \xt 2 Kings 23:13\xt*)\f*\x - \xo 1.10 \xt 2 Ki 21:2-9; 2 Chr 33:2-9\x*
\q1
\v 11 And now I bend the knee of my heart, to pray to you for your kindness,\x - \xo 1.11 \xt Sir 17:25\x*
\q1
\v 12 I have sinned, Lord, I have sinned,
\q2 and I acknowledge my transgressions.\f + \fr 1.12 \ft Ps 51:3\f*
\q1
\v 13 I ask you in prayer,
\q2 forgive me, Lord, forgive me,
\q1 do not destroy me for my transgressions,
\q2 neither stay angry with me forever, storing up evil for me,
\q3 and do not\f + \fr 1.13 \fq and do not \ft Greek \fqa neither\f* condemn me to the depths of the earth.\x - \xo 1.13 \xt Ps 63:9; Ps 88:6\x*
\q1 For you are, Lord,\f + \fr 1.13 \fq Lord \ft Latin reads \fq God\f* the God of those who repent;
\q2
\v 14 And to me you will show your goodness.
\q1 For \add though I am\add* unworthy, \add you will\add* save me according to your abounding mercy.
\q2
\v 15 And I will praise you for all of the days of my life.
\q1 For all of the host of heaven sing your praise,\x - \xo 1.15 \xt Ps 103:21; S3Y 39\x*
\q2 and yours is the glory forever.\f + \fr 1.15 \fq forever \ft Latin reads \fq forever and ever\f* Amen.\x - \xo 1.15 \xt Rom 11:36; 16:7\x*
32 changes: 32 additions & 0 deletions samples/ApiExample/data/TEA/85PS2TEA.SFM
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
\id PS2 - Test English Apocrypha
\h Psalm 151
\toc1 Psalm 151
\toc2 Psalm 151
\toc3 Psalm 151
\mt1 Psalm 151
\imt Introduction
\ip Psalm 151 is included in some Septuagint manuscripts, and is present in the Dead Sea Scrolls (4QPs\sup a\sup*) in both Hebrew (151A) and Syraic (151B). The following is a translation of the version found in the Septuagint.
\c 1
\cp 151
\d This psalm is written by David in his own hand (although it is outside the number), after he had fought one-on-one with Goliath.\f + \fr 1.1 \fq Goliath \ft Greek \fq Goliad\f*
\q1
\v 1 Smallest among my brothers, and the youngest in my father’s house;
\q2 I shepherded my father’s sheep.\x - \xo 1.1 \xt 1 Sam 16:11\x*
\q1
\v 2 My hands made a harp;
\q2 my fingers fashioned a lyre.\x - \xo 1.2 \xt 1 Sam 16:23\x*
\q1
\v 3 And who will report to my Lord?
\q2 The Lord himself, he hears.\f + \fr 1.3 \fq hears \ft Codex Sinaiticus: \fqa hears everything.\fqa*; Codex Alexandrinus: \fqa who will hear me. \f*
\q1
\v 4 He sent his messenger\f + \fr 1.4 \fq messenger \ft Or \fqa angel\f* \add to me\add*, took me from my father’s sheep,
\q2 and anointed me with olive oil.\x - \xo 1.4 \xt 1 Sam 16:13\x*
\q1
\v 5 My brothers were handsome and great \add indeed\add*,
\q2 but with them the Lord was not pleased.\x - \xo 1.5 \xt 1 Sam 16:10\x*
\q1
\v 6 I came out to meet the foreigner,
\q2 and he cursed me by his idols.\x - \xo 1.6 \xt 1 Sam 17:43\x*
\q1
\v 7 But I drew his own sword, beheaded him,\x - \xo 1.7 \xt 1 Sam 17:51\x*
\q2 and took away disgrace from Israel’s sons.
126 changes: 126 additions & 0 deletions samples/ApiExample/data/TEA/BookNames.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<BookNames>
<book code="GEN" abbr="" short="" long="" />
<book code="EXO" abbr="" short="" long="" />
<book code="LEV" abbr="" short="" long="" />
<book code="NUM" abbr="" short="" long="" />
<book code="DEU" abbr="" short="" long="" />
<book code="JOS" abbr="" short="" long="" />
<book code="JDG" abbr="" short="" long="" />
<book code="RUT" abbr="" short="" long="" />
<book code="1SA" abbr="" short="" long="" />
<book code="2SA" abbr="" short="" long="" />
<book code="1KI" abbr="" short="" long="" />
<book code="2KI" abbr="" short="" long="" />
<book code="1CH" abbr="" short="" long="" />
<book code="2CH" abbr="" short="" long="" />
<book code="EZR" abbr="" short="" long="" />
<book code="NEH" abbr="" short="" long="" />
<book code="EST" abbr="" short="" long="" />
<book code="JOB" abbr="" short="" long="" />
<book code="PSA" abbr="" short="" long="" />
<book code="PRO" abbr="" short="" long="" />
<book code="ECC" abbr="" short="" long="" />
<book code="SNG" abbr="" short="" long="" />
<book code="ISA" abbr="" short="" long="" />
<book code="JER" abbr="" short="" long="" />
<book code="LAM" abbr="" short="" long="" />
<book code="EZK" abbr="" short="" long="" />
<book code="DAN" abbr="" short="" long="" />
<book code="HOS" abbr="" short="" long="" />
<book code="JOL" abbr="" short="" long="" />
<book code="AMO" abbr="" short="" long="" />
<book code="OBA" abbr="" short="" long="" />
<book code="JON" abbr="" short="" long="" />
<book code="MIC" abbr="" short="" long="" />
<book code="NAM" abbr="" short="" long="" />
<book code="HAB" abbr="" short="" long="" />
<book code="ZEP" abbr="" short="" long="" />
<book code="HAG" abbr="" short="" long="" />
<book code="ZEC" abbr="" short="" long="" />
<book code="MAL" abbr="" short="" long="" />
<book code="MAT" abbr="" short="" long="" />
<book code="MRK" abbr="" short="" long="" />
<book code="LUK" abbr="" short="" long="" />
<book code="JHN" abbr="" short="" long="" />
<book code="ACT" abbr="" short="" long="" />
<book code="ROM" abbr="" short="" long="" />
<book code="1CO" abbr="" short="" long="" />
<book code="2CO" abbr="" short="" long="" />
<book code="GAL" abbr="" short="" long="" />
<book code="EPH" abbr="" short="" long="" />
<book code="PHP" abbr="" short="" long="" />
<book code="COL" abbr="" short="" long="" />
<book code="1TH" abbr="" short="" long="" />
<book code="2TH" abbr="" short="" long="" />
<book code="1TI" abbr="" short="" long="" />
<book code="2TI" abbr="" short="" long="" />
<book code="TIT" abbr="" short="" long="" />
<book code="PHM" abbr="" short="" long="" />
<book code="HEB" abbr="" short="" long="" />
<book code="JAS" abbr="" short="" long="" />
<book code="1PE" abbr="" short="" long="" />
<book code="2PE" abbr="" short="" long="" />
<book code="1JN" abbr="" short="" long="" />
<book code="2JN" abbr="" short="" long="" />
<book code="3JN" abbr="" short="" long="" />
<book code="JUD" abbr="" short="" long="" />
<book code="REV" abbr="" short="" long="" />
<book code="TOB" abbr="" short="" long="" />
<book code="JDT" abbr="" short="" long="" />
<book code="ESG" abbr="" short="" long="" />
<book code="WIS" abbr="" short="" long="" />
<book code="SIR" abbr="" short="" long="" />
<book code="BAR" abbr="" short="" long="" />
<book code="LJE" abbr="" short="" long="" />
<book code="S3Y" abbr="" short="" long="" />
<book code="SUS" abbr="" short="" long="" />
<book code="BEL" abbr="" short="" long="" />
<book code="1MA" abbr="" short="" long="" />
<book code="2MA" abbr="" short="" long="" />
<book code="3MA" abbr="" short="" long="" />
<book code="4MA" abbr="" short="" long="" />
<book code="1ES" abbr="" short="" long="" />
<book code="2ES" abbr="" short="" long="" />
<book code="MAN" abbr="" short="" long="" />
<book code="PS2" abbr="" short="" long="" />
<book code="ODA" abbr="" short="" long="" />
<book code="PSS" abbr="" short="" long="" />
<book code="JSA" abbr="" short="" long="" />
<book code="JDB" abbr="" short="" long="" />
<book code="TBS" abbr="" short="" long="" />
<book code="SST" abbr="" short="" long="" />
<book code="DNT" abbr="" short="" long="" />
<book code="BLT" abbr="" short="" long="" />
<book code="XXA" abbr="" short="" long="" />
<book code="XXB" abbr="" short="" long="" />
<book code="XXC" abbr="" short="" long="" />
<book code="XXD" abbr="" short="" long="" />
<book code="XXE" abbr="" short="" long="" />
<book code="XXF" abbr="" short="" long="" />
<book code="XXG" abbr="" short="" long="" />
<book code="FRT" abbr="" short="" long="" />
<book code="BAK" abbr="" short="" long="" />
<book code="OTH" abbr="" short="" long="" />
<book code="3ES" abbr="" short="" long="" />
<book code="EZA" abbr="" short="" long="" />
<book code="5EZ" abbr="" short="" long="" />
<book code="6EZ" abbr="" short="" long="" />
<book code="INT" abbr="" short="" long="" />
<book code="CNC" abbr="" short="" long="" />
<book code="GLO" abbr="" short="" long="" />
<book code="TDX" abbr="" short="" long="" />
<book code="NDX" abbr="" short="" long="" />
<book code="DAG" abbr="" short="" long="" />
<book code="PS3" abbr="" short="" long="" />
<book code="2BA" abbr="" short="" long="" />
<book code="LBA" abbr="" short="" long="" />
<book code="JUB" abbr="" short="" long="" />
<book code="ENO" abbr="" short="" long="" />
<book code="1MQ" abbr="" short="" long="" />
<book code="2MQ" abbr="" short="" long="" />
<book code="3MQ" abbr="" short="" long="" />
<book code="REP" abbr="" short="" long="" />
<book code="4BA" abbr="" short="" long="" />
<book code="LAO" abbr="" short="" long="" />
</BookNames>
37 changes: 37 additions & 0 deletions samples/ApiExample/data/TEA/C3LAOTEA.SFM
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
\id LAO - Test English Apocrypha
\h Laodiceans
\toc1 Laodiceans
\toc2 Laodiceans
\toc3 Laodiceans
\mt1 Epistle to the Laodiceans
\imt Introduction
\ip The following is a translation of the J.B. Lightfoot’s reverse translation of the surviving Latin translation of the Epistle to the Laodiceans into Koine Greek. This translation, published in his commentary on Colossians and Philemon (new edition, 1879) is based on the premise that the original epistle is a composition of quotations from the Pauline Epistles, compiled by an unknown author, purporting to be a letter from Paul to the church at Laodicea.
\c 1
\po
\v 1 Paul, an apostle—not from men nor through man, but through Jesus Christ,\x - \xo 1.1 \xt Gal 1:1\x* to the brothers who are in Laodicea.\x - \xo 1.1 \xt Col 4:16\x*
\v 2 Grace to you and peace from God the\f + \fr 1.2 \fq the \ft Some manuscripts \fq our\f* Father and the Lord Jesus Christ.\x - \xo 1.2 \xt Gal 1:3; Phil 1:2 \x*
\p
\v 3 I give thanks to Christ in all my prayers,\x - \xo 1.3 \xt Phil 1:3\x* that you are continuing in him and persevering in his works, eagerly awaiting the promise \add of salvation\add*\x - \xo 1.3 \xt Gal 5:5\x* in the day of judgment.\x - \xo 1.3 \xt 2 Pet 2:9; 3:7; cf. Phil 2:16\x*
\p
\v 4 Neither do the vain discussions of certain men\x - \xo 1.4 \xt 1 Tim 1:6\x* deceive you, with their aim to turn you away\x - \xo 1.4 \xt 2 Tim 4:4\x* from the truth of the gospel\x - \xo 1.4 \xt Col 1:5; Gal 2:5, 14\x* which is preached by me.\x - \xo 1.4 \xt Gal 1:11 (cf. Gal 1:8)\x*
\v 5 So\f + \fr 1.5 \fq So \ft Greek: \fqa And \f* now God will work in those who are \add imitators\add*\x - \xo 1.5 \xt 1 Thes 2:14\x* of me\f + \fr 1.5 \fq imitators of me \ft Greek \fqa of mine\f* to advance the truth of the gospel,\x - \xo 1.5 \xt Phil 1:12\x* […]\f + \fr 1.5 \fq […] \ft A section appears to be missing, according to J.B. Lightfoot. \f* worshipping and practicing generosity—works of salvation [and]\f + \fr 1.5 \fq [and] \ft It is doubtful that this word was in the original Greek.\f* of eternal life.
\v 6 And now my imprisonment\f + \fr 1.6 \fq imprisonment \ft Greek \fqa chains\f* is widely known, which I suffer in Christ, in which I rejoice and am glad.\x - \xo 1.6 \xt Matt 5:12 cf. Phil 1:18\x*
\v 7 And this is for my eternal salvation, which will occur through your prayers, and the help of the Holy Spirit,\x - \xo 1.7 \xt Phil 1:19\x* whether by life or by death.\x - \xo 1.7 \xt Phil 1:20\x*
\v 8 For to me, to live is Christ, and to die is joy.\x - \xo 1.8 \xt Phil 1:21\x*
\v 9 And so he will work in you according to his mercy, that you may have the same love, and be in full accord.\x - \xo 1.9 \xt Phil 2:2\x*
\v 10 Therefore beloved, as you have obeyed in my presence,\x - \xo 1.10 \xt Phil 2:12\x* so work, remembering\x - \xo 1.10 \xt 2 Thes 2:5 (Vulgate)\x* the fear of God,\f + \fr 1.10 \fq God \ft J.B. Lightfoot’s Greek text has \fqa Lord\fqa*, but this is not present in any Latin manuscripts.\f* and it will be to you eternal life,\f + \fr 1.10 \fq life, \ft The Latin and Greek text end the sentence here.\f*
\v 11 for it is God who works in you.\x - \xo 1.11 \xt Phil 2:13\x*
\v 12 And do without grumbling,\x - \xo 1.12 \xt Phil 2:14\x* whatever you do.\x - \xo 1.12 \xt Col 3:17\x*
\p
\v 13 And finally, beloved, rejoice in Christ.\x - \xo 1.13 \xt Phil 3:1\x* Look out for those \add who are\add* greedy for dishonest gain.\x - \xo 1.13 \xt 1 Tim 3:8; Tit 1:7\x*
\v 14 Let all your requests be made known to God,\x - \xo 1.14 \xt Phil 4:6\x* and be steadfast\x - \xo 1.14 \xt 1 Cor 15:58\x* in the mind of Christ.\x - \xo 1.14 \xt 1 Cor 2:16\x*
\v 15 Whatever is sound, and true, and honourable, and just,\f + \fr 1.15 \ft Some manuscripts add \fq and pure\f* and lovely,\x - \xo 1.15 \xt Phil 4:8\x* practice these things.\x - \xo 1.15 \xt Phil 4:9\x*
\v 16 And what you have heard and received, hold in your heart, and peace will be with you.
\p
\v 17 [Greet the brothers.\x - \xo 1.17 \xt 1 Thes 5:26\x*]\f + \fr 1.17 \ft Most manuscripts omit verse 17.\f*
\p
\v 18 The saints greet you.\f + \fr 1.18 \ft One manuscript omits this verse.\f*\x - \xo 1.18 \xt Phil 4:22\x*
\p
\v 19 The grace of the Lord Jesus Christ\f + \fr 1.19 \ft Some manuscripts omit \fq Christ\f* be with your spirit.\x - \xo 1.19 \xt Phil 4:28\x*
\p
\v 20 And have this \add letter\add* read to the Colossians, and that of the Colossians to you.\f + \fr 1.20 \ft One manuscript adds \fq Amen.\fq*, another manuscript omits this verse.\f*\x - \xo 1.20 \xt Col 4:16\x*
5 changes: 5 additions & 0 deletions samples/ApiExample/data/TEA/CommentTags.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TagList>
<Tag Id="1" Name="To Do" Icon="01flag1" CreatorResolve="false" />
<LastUsedID>1</LastUsedID>
</TagList>
Loading

0 comments on commit cb00855

Please sign in to comment.