Skip to content

Commit

Permalink
NEW: Literal Translation (#42)
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
dwhieb committed Oct 27, 2023
1 parent cf24ddd commit 6229f28
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/data/Nuuchahnulth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ They had children.
ʔuḥ m̓aːm̓i·qsu ~
being.he elder.brother ~
being.he elder.brother ~
The oldest son was Wi\l\liam Swan,
The oldest son was William Swan,
8 changes: 8 additions & 0 deletions samples/html/Algonquian.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,29 @@ <h1>Algonquian</h1>
<p class=ex-header>Menominee</p>

<p class=txn data-ortho='default'>pemētaehkipew</p>


<p class=ex-source>(Bloomfield 1975: 208)</p>
</li><li class='igl'>
<p class=ex-header>SW Ojibwe</p>

<p class=txn data-ortho='default'>ozhaashisagaa</p>


<p class=ex-source>(Nichols 2015)</p>
</li><li class='igl'>
<p class=ex-header>Delaware</p>

<p class=txn data-ortho='default'>kwənaskwat</p>


<p class=ex-source>(O'Meara 1990: 250)</p>
</li><li class='igl'>
<p class=ex-header>Blackfoot</p>

<p class=txn data-ortho='default'>sisáápittakit</p>


<p class=ex-source>(Frantz & Genee 2015)</p>
</li></ul>
</body>
Expand Down
6 changes: 6 additions & 0 deletions samples/html/Chitimacha-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ <h1>Chitimacha-text</h1>
<p class=trs data-ortho='Modern'>Wetkx hus naancaakamankx wetk hi hokmiqi.</p><p class=trs data-ortho='Swadesh'>wetkšˊ husˊ na·nča·kamankšˊ wetkˊ hi hokmiʔiˊ.</p>
<p class=txn data-ortho='default'></p>



</li><li class='igl'>

<p class=trs data-ortho='Modern'>Kun cuugx cuugx, xeenink hup hi nicwiqi.</p><p class=trs data-ortho='Swadesh'>kunˊ ču·gšˊ ču·gšˊ, še·nink hupˊ hi ničwiʔiˊ.</p>
<p class=txn data-ortho='default'></p>



</li><li class='igl'>

<p class=trs data-ortho='Modern'>Wetkx we xeenink hi nicminkix, weyk hi kixutiqi.</p><p class=trs data-ortho='Swadesh'>wetkšˊ we še·ninkˊ hi ničwinkišˊ, weykˊ hi kišutiʔiˊ.</p>
<p class=txn data-ortho='default'></p>



</li></ul>
</body>
</html>
2 changes: 2 additions & 0 deletions samples/html/Chitimacha.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ <h1>Chitimacha</h1>

<p class=txn data-ortho='default'>waxdungu qasi</p>



</li></ul>
</body>
</html>
6 changes: 6 additions & 0 deletions samples/html/Mohawk.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ <h1>Mohawk</h1>
<p class=ex-header>Causative-Reversive</p>
<p class=trs data-ortho='default'>Satia’tawi’táhsi!</p>
<p class=txn data-ortho='default'></p>

<p class=lit lang=en>un-cause your body to be covered, uncover your body</p>
<p class=ex-source>CP (Mithun f.c.)</p>
</li><li class='igl'>
<p class=ex-header>Causative-Reversive-Benefactive</p>
<p class=trs data-ortho='default'>Takhnenna’taienthókwa’s!</p>
<p class=txn data-ortho='default'></p>

<p class=lit lang=en>un-cause potatoes to lie for me</p>
<p class=ex-source>AKJ (Mithun f.c.)</p>
</li><li class='igl'>

<p class=trs data-ortho='default'>Wa’kheiatia’tawi’tsheronnianión:hahse’.</p>
<p class=txn data-ortho='default'></p>

<p class=lit lang=en>for them I variously made body covers</p>
<p class=ex-source>LJ (Mithun f.c.)</p>
</li></ul>
</body>
Expand Down
8 changes: 8 additions & 0 deletions samples/html/Nuuchahnulth.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@ <h1>Nuuchahnulth</h1>

<p class=txn data-ortho='default'>ʔuckʷiis kinḥuuɬ.</p>



</li><li class='igl'>
<p class=ex-header>002</p>

<p class=txn data-ortho='default'>ʔuckʷiis kinḥuuɬ, ʔukčiiɬ kʷaatya, yaqukʷitii ɬuucma, kʷaatya ʔukɬaa.</p>



</li><li class='igl'>
<p class=ex-header>003</p>

<p class=txn data-ortho='default'>ʔunaakʔaɬ t̓aatn̓a.</p>



</li><li class='igl'>
<p class=ex-header>004</p>

<p class=txn data-ortho='default'>ʔuḥ m̓aam̓iiqsu, [William Swan],</p>



</li></ul>
</body>
</html>
2 changes: 2 additions & 0 deletions samples/html/OldLatin.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ <h1>OldLatin</h1>
<p class=trs data-ortho='prac'>iovesatdeivosqoimedmitatneitedendocosmisuircosied</p><p class=trs data-ortho='lat'>𐌉𐌏𐌅𐌄𐌔𐌀𐌕𐌃𐌄𐌉𐌅𐌏𐌔𐌒𐌏𐌉𐌌𐌄𐌃𐌌𐌉𐌕𐌀𐌕𐌍𐌄𐌉𐌕𐌄𐌃𐌄𐌍𐌃𐌏𐌂𐌏𐌔𐌌𐌉𐌔V𐌉𐌓𐌂𐌏𐌔𐌉𐌄𐌃</p>
<p class=txn data-ortho='default'></p>



</li></ul>
</body>
</html>
2 changes: 2 additions & 0 deletions samples/html/Swahili.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ <h1>Swahili</h1>

<p class=txn data-ortho='default'>ninaenda</p>



</li></ul>
</body>
</html>
16 changes: 16 additions & 0 deletions src/lines/literal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default function createLiteral(data) {

let html = ``

if (typeof data === `string`) {
return `<p class=lit lang=en>${ data }</p>`
}

for (const lang in data) {
const lit = data[lang]
html += `<p class=lit lang='${ lang }'>${ lit }</p>`
}

return html

}
7 changes: 5 additions & 2 deletions src/utterance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import createHeader from './lines/metadata.js'
import createLiteral from './lines/literal.js'
import createPhonetic from './lines/phonetic.js'
import createSource from './lines/source.js'
import createTranscript from './lines/transcript.js'
Expand All @@ -8,16 +9,18 @@ export default function convertUtterance(u, { classes, tag }) {

const classString = classes.join(` `)
const header = createHeader(u.metadata)
const transcript = createTranscript(u.transcript)
const transcription = createTranscription(u.transcription)
const literal = createLiteral(u.literal)
const phonetic = createPhonetic(u.phonetic)
const source = createSource(u.speaker, u.source)
const transcript = createTranscript(u.transcript)
const transcription = createTranscription(u.transcription)

return `<${ tag } class='${ classString }'>
${ header }
${ transcript }
${ transcription }
${ phonetic }
${ literal }
${ source }
</${ tag }>`

Expand Down
31 changes: 31 additions & 0 deletions test/lines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ import { ChitimachaText, Swahili } from '../samples/data/data.js'

describe(`lines`, function() {

it.only(`literal translation`, function() {

const scription = `
\\txn xaa qapx guxna
\\m xaq qapx guxt-na
\\gl mouth recip eat-nf.pl
\\tln they kissed each other
\\lit-en they ate each other's mouths
\\lit-sp se comen sus bocas
`

const { dom } = parse(scription)
const literal = findElementsByClass(dom, `lit`)

expect(literal).to.have.length(2)

const [eng, spa] = literal

expect(getAttribute(eng, `lang`)).to.equal(`en`)
expect(getAttribute(spa, `lang`)).to.equal(`sp`)
expect(getTextContent(eng)).to.equal(`they ate each other's mouths`)
expect(getTextContent(spa)).to.equal(`se comen sus bocas`)

})

describe(`metadata`, function() {

it(`is not present when there is no data`, function() {
Expand Down Expand Up @@ -45,6 +70,7 @@ describe(`lines`, function() {
const { dom } = parse(scription)
const el = findElementByClass(dom, `phon`)

// has .phon class
expect(getTextContent(el)).to.equal(phonetic)

})
Expand Down Expand Up @@ -73,6 +99,7 @@ describe(`lines`, function() {
expect(getAttribute(mod, `data-ortho`)).to.equal(`mod`)
expect(getAttribute(swad, `data-ortho`)).to.equal(`swad`)
expect(getAttribute(apa, `data-ortho`)).to.equal(`apa`)
// have correct text

})

Expand Down Expand Up @@ -104,6 +131,7 @@ describe(`lines`, function() {
const text = getTextContent(source)

expect(text).to.equal(`Hamisi`)
// has correct CSS class

})

Expand All @@ -122,6 +150,7 @@ describe(`lines`, function() {
const text = getTextContent(source)

expect(text).to.equal(`(Hieber 2018: 1)`)
// has correct CSS class

})

Expand All @@ -141,6 +170,7 @@ describe(`lines`, function() {
const text = getTextContent(source)

expect(text).to.equal(`Hamisi (Hieber 2018: 1)`)
// has correct CSS class

})

Expand All @@ -160,6 +190,7 @@ describe(`lines`, function() {

expect(getAttribute(mod, `data-ortho`)).to.equal(`Modern`)
expect(getAttribute(swad, `data-ortho`)).to.equal(`Swadesh`)
// has correct text

})

Expand Down

0 comments on commit 6229f28

Please sign in to comment.