Skip to content

Commit

Permalink
separated out business logic to word-aligner-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotoNomad0 committed Oct 7, 2024
1 parent 5e732ee commit d08ee9b
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 2,119 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "word-aligner-rcl",
"version": "1.1.3",
"version": "1.1.4-beta",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"repository": "https://github.com/unfoldingWord/word-aligner-rcl.git",
Expand Down Expand Up @@ -61,6 +61,7 @@
"string-punctuation-tokenizer": "2.2.0",
"usfm-js": "3.4.3",
"word-aligner": "1.0.2",
"word-aligner-lib": "0.9.1-beta",
"wordmap-lexer": "^0.3.6"
},
"resolutions": {
Expand Down
246 changes: 0 additions & 246 deletions src/__tests__/testUpdateAlignments.test.js

This file was deleted.

69 changes: 0 additions & 69 deletions src/__tests__/verseSpan.test.js

This file was deleted.

20 changes: 8 additions & 12 deletions src/components/WordAligner.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ Word Aligner Example:
```js
import React, {useState} from 'react';
import {
addAlignmentsToVerseUSFM,
areAlgnmentsComplete,
parseUsfmToWordAlignerData,
resetAlignments,
} from "../utils/alignmentHelpers";
import {convertVerseDataToUSFM} from "../utils/UsfmFileConversionHelpers";
AlignmentHelpers
} from "word-aligner-lib";
import {NT_ORIG_LANG} from "../common/constants";

// a fully aligned example
Expand All @@ -29,9 +25,9 @@ const translate = (key) => {
const targetVerseUSFM = alignedVerseJson.usfm;
const sourceVerseUSFM = originalVerseJson.usfm;

const {targetWords: targetWords_, verseAlignments: verseAlignments_} = parseUsfmToWordAlignerData(targetVerseUSFM, sourceVerseUSFM);
const {targetWords: targetWords_, verseAlignments: verseAlignments_} = AlignmentHelpers.parseUsfmToWordAlignerData(targetVerseUSFM, sourceVerseUSFM);

const alignmentComplete = areAlgnmentsComplete(targetWords_, verseAlignments_);
const alignmentComplete = AlignmentHelpers.areAlgnmentsComplete(targetWords_, verseAlignments_);
console.log(`Alignments are ${alignmentComplete ? 'COMPLETE!' : 'incomplete'}`);

const App = () => {
Expand Down Expand Up @@ -66,15 +62,15 @@ const App = () => {
function onChange(results) {
console.log(`WordAligner() - alignment changed, results`, results);// merge alignments into target verse and convert to USFM
const {targetWords, verseAlignments} = results;
const verseUsfm = addAlignmentsToVerseUSFM(targetWords, verseAlignments, targetVerseUSFM);
const verseUsfm = AlignmentHelpers.addAlignmentsToVerseUSFM(targetWords, verseAlignments, targetVerseUSFM);
console.log(verseUsfm);
const alignmentComplete = areAlgnmentsComplete(targetWords, verseAlignments);
const alignmentComplete = AlignmentHelpers.areAlgnmentsComplete(targetWords, verseAlignments);
console.log(`Alignments are ${alignmentComplete ? 'COMPLETE!' : 'incomplete'}`);
}

function onReset() {
console.log("WordAligner() - reset Alignments")
const alignmentData = resetAlignments(verseAlignments, targetWords)
const alignmentData = AlignmentHelpers.resetAlignments(verseAlignments, targetWords)
setState({
verseAlignments: alignmentData.verseAlignments,
targetWords: alignmentData.targetWords,
Expand Down Expand Up @@ -105,7 +101,7 @@ const App = () => {
loadLexiconEntry={loadLexiconEntry}
onChange={onChange}
getLexiconData={getLexiconData_}
resetAlignments={resetAlignments}
resetAlignments={AlignmentHelpers.resetAlignments}
/>
</div>
</>
Expand Down
Loading

0 comments on commit d08ee9b

Please sign in to comment.