artifactWordIndex method

int artifactWordIndex(
  1. int soraId,
  2. int ayaId,
  3. int dbWordIndex
)

Maps the database word index to the corresponding index in the artifact phoneme word list.

Implementation

int artifactWordIndex(int soraId, int ayaId, int dbWordIndex) {
  final key = artifactKey(soraId, ayaId);
  final exception = _exceptions[key];
  if (exception == null) {
    return dbWordIndex;
  }

  if (exception.dropLeadingDbWords > 0) {
    final adjusted = dbWordIndex - exception.dropLeadingDbWords;
    return adjusted < 0 ? 0 : adjusted;
  }

  return dbWordIndex;
}