Skip to content

Commit

Permalink
Find more errors in sound changes. Fix bug breaking system after fixi…
Browse files Browse the repository at this point in the history
…ng errors
  • Loading branch information
nai888 committed Dec 31, 2018
1 parent 023c1ba commit b2f16f3
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/routes/Morph/MorphService.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,38 @@ class MorphService {
changeFrom: split[0],
changeTo: split[1]
}
if (split[2]) thisRule.context = split[2]
if (split[3]) thisRule.exception = split[3]
if (split[2]) {
thisRule.context = split[2]
if (!/_/.test(split[2])) {
errors.push(
`The context in the sound change ${
changes[i]
} is missing an _ sign.`
)
} else if (/_/.exec(split[2]).length > 2) {
errors.push(
`The context in the sound change ${
changes[i]
} has too many _ signs.`
)
}
}
if (split[3]) {
thisRule.exception = split[3]
if (!/_/.test(split[3])) {
errors.push(
`The exception in the sound change ${
changes[i]
} is missing an _ sign.`
)
} else if (/_/.exec(split[3]).length > 2) {
errors.push(
`The exception in the sound change ${
changes[i]
} has too many _ signs.`
)
}
}
splitChanges.push(thisRule)
}
}
Expand All @@ -225,7 +255,11 @@ class MorphService {
idChanged (data, results) {
const newResults = JSON.parse(JSON.stringify(results))

if (data.results !== undefined) {
if (
data.results !== undefined &&
data.results.length &&
typeof data.results[0] !== 'string'
) {
for (let i = 0; i < newResults.length; i++) {
newResults[i].changed =
newResults[i].input !== data.results[i].input &&
Expand Down

0 comments on commit b2f16f3

Please sign in to comment.