Skip to content

Commit

Permalink
DEV: Restructure files
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Nov 18, 2023
1 parent 9e3c4cf commit 74ff10a
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 61 deletions.
11 changes: 3 additions & 8 deletions src/parseUtterance/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import getLineType from '../utilities/getLineType.js'
import mergeTranscriptions from '../utilities/mergeTranscriptions.js'
import parseCustom from './parseCustom.js'
import parseDuration from './parseDuration.js'
import parseLiteral from './parseLiteral.js'
Expand All @@ -13,11 +13,6 @@ import parseTranscription from './parseTranscription.js'
import parseTranslation from './parseTranslation.js'
import parseWords from './parseWords.js'

import {
getLineType,
mergeTranscriptions,
} from '../utilities/index.js'

/**
* Parses an individual utterance as a string and returns it as a DLx Utterance object
* @param {String} rawLines An array of utterance lines to parse
Expand Down Expand Up @@ -67,7 +62,7 @@ export default function parseUtterance(rawLines, schema, codesHash, options) {
const data = (match ? match.groups.lineData : line).trim()

// replace a sequence of white space with a single space

hash[code] = data.replace(whiteSpaceRegExp, ` `)

return hash
Expand Down
2 changes: 1 addition & 1 deletion src/parseUtterance/parseCustom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLineType } from '../utilities/index.js'
import getLineType from '../utilities/getLineType.js'

/**
* Extracts any unspecified lines from the lines hash and returns them in an object
Expand Down
8 changes: 3 additions & 5 deletions src/parseUtterance/parseLiteral.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
groupLines,
removeBrackets,
removeEmphasis,
} from '../utilities/index.js'
import groupLines from '../utilities/groupLines.js'
import removeBrackets from '../utilities/removeBrackets.js'
import removeEmphasis from '../utilities/removeEmphasis.js'

/**
* Parses, validates, and cleans the literal translation lines
Expand Down
14 changes: 6 additions & 8 deletions src/parseUtterance/parseMorphemes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import getDuplicateMorphemes from './getDuplicateMorphemes.js'
import separateInfix from './separateInfix.js'
import zip from '../../utilities/js/zip.js'

import {
getLines,
groupLines,
mergeTranscriptions,
removeBrackets,
validateNumItems,
} from '../../utilities/index.js'
import getLines from '../../utilities/getLines.js'
import groupLines from '../../utilities/groupLines.js'
import mergeTranscriptions from '../../utilities/mergeTranscriptions.js'
import removeBrackets from '../../utilities/removeBrackets.js'
import validateNumItems from '../../utilities/validateNumItems.js'

/**
* Creates a morphemes hash of line codes and an array of morphemes based on the word lines
Expand All @@ -18,7 +16,7 @@ import {
function createMorphemesHash(wordLines) {
return Object.entries(wordLines)
.reduce((hash, [code, data]) => {
hash[code] = tokenizeWord(data)
hash[code] = tokenizeWord(data)
return hash
}, {})
}
Expand Down
6 changes: 3 additions & 3 deletions src/parseUtterance/parseMorphemes/separateInfix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLineType } from '../../utilities/index.js'
import getLineType from '../../utilities/getLineType.js'

/**
* Checks a Morpheme object for infixes, and returns an array of two morphemes if one is present
Expand Down Expand Up @@ -27,10 +27,10 @@ export default function separateInfix(glossLineCode, morpheme) {

const { infix, pre, post } = data.match(infixRegExp).groups


i[code] = infix
m[code] = `${ pre }${ post }`


return [i, m]

Expand Down
2 changes: 1 addition & 1 deletion src/parseUtterance/parseNotes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLines } from '../utilities/index.js'
import getLines from '../utilities/getLines.js'
import { isLanguageTag } from '../utilities/types/index.js'

/**
Expand Down
6 changes: 2 additions & 4 deletions src/parseUtterance/parsePhonetic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
removeBrackets,
removeEmphasis,
} from '../utilities/index.js'
import removeBrackets from '../utilities/removeBrackets.js'
import removeEmphasis from '../utilities/removeEmphasis.js'

/**
* Cleans and validates the phonetic line
Expand Down
2 changes: 1 addition & 1 deletion src/parseUtterance/parseTranscript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { groupLines } from '../utilities/index.js'
import groupLines from '../utilities/groupLines.js'

/**
* Extracts, validates, and cleans the transcript lines from the lines hash
Expand Down
8 changes: 3 additions & 5 deletions src/parseUtterance/parseTranscription.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
groupLines,
removeBrackets,
removeEmphasis,
} from '../utilities/index.js'
import groupLines from '../utilities/groupLines.js'
import removeBrackets from '../utilities/removeBrackets.js'
import removeEmphasis from '../utilities/removeEmphasis.js'

/**
* Extracts, validates, and cleans the transcription lines from the lines hash
Expand Down
8 changes: 3 additions & 5 deletions src/parseUtterance/parseTranslation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
groupLines,
removeBrackets,
removeEmphasis,
} from '../utilities/index.js'
import groupLines from '../utilities/groupLines.js'
import removeBrackets from '../utilities/removeBrackets.js'
import removeEmphasis from '../utilities/removeEmphasis.js'

/**
* Extracts, validates, and cleans the translation lines from the lines hash
Expand Down
19 changes: 8 additions & 11 deletions src/parseUtterance/parseWords.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import parseMorphemes from './parseMorphemes/index.js'
import { wordTypes } from '../utilities/constants/index.js'
import zip from '../utilities/js/zip.js'

import {
getLines,
groupLines,
removeEmphasis,
validateNumItems,
} from '../utilities/index.js'
import getLines from '../utilities/getLines.js'
import groupLines from '../utilities/groupLines.js'
import parseMorphemes from './parseMorphemes/index.js'
import removeEmphasis from '../utilities/removeEmphasis.js'
import validateNumItems from '../utilities/validateNumItems.js'
import { wordTypes } from '../utilities/constants/index.js'
import zip from '../utilities/js/zip.js'

/**
* Parses the word hash into a DLx Word object
Expand Down Expand Up @@ -70,7 +67,7 @@ export default function parseWords(codesHash, lines, orthography) {
// tokenizes the words in each line
const wordsHash = Object.entries(wordLines)
.reduce((hash, [code, data]) => {
hash[code] = tokenizeLine(data)
hash[code] = tokenizeLine(data)
return hash
}, {})

Expand Down
2 changes: 1 addition & 1 deletion src/parseUtterances.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSchema } from './utilities/index.js'
import getSchema from './utilities/getSchema.js'
import parseUtterance from './parseUtterance/index.js'

function splitUtterance(rawUtterance) {
Expand Down
8 changes: 0 additions & 8 deletions src/utilities/index.js

This file was deleted.

0 comments on commit 74ff10a

Please sign in to comment.