Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved checks after user feedback (video) #30

Merged
merged 1 commit into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions src/core/BCS-usfm-grammar-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,38 @@ export function runBCSGrammarCheck(strictnessString, fileText, filename, givenLo
else ourErrorMessage = errorLine; // We only want the last one
}
// console.log(` ourErrorMessage: '${ourErrorMessage}' lineNumberString=${lineNumberString} characterIndex=${characterIndex} extract='${extract}'`);
// NOTE: \s5 fields are not valid USFM but we degrade the priority of those warnings
ourErrorObject = {priority:extract==='\\s5'? 294:994, message:`USFMGrammar: ${ourErrorMessage}`,

// Some of these "errors" need to be degraded in priority

let adjustedPriority = 994;
if (extract==='\\s5' // Temporarily, even though \s5 fields are not valid USFM
|| ourErrorMessage.startsWith('Expected "f*", "+"') // Might neeed a OHM schema fix?
)
adjustedPriority = 294;

ourErrorObject = {priority:adjustedPriority, message:`USFMGrammar: ${ourErrorMessage}`,
filename,
characterIndex, extract,
location:givenLocation};
if (lineNumberString && lineNumberString.length) ourErrorObject.lineNumber = Number(lineNumberString);

// Save our line number
if (lineNumberString && lineNumberString.length) {
// but we need a temporary fix for the BCS bug which doesn't include blank lines in the count
let lineNumber = Number(lineNumberString)
let notified = false;
const lines = fileText.split('\n');
for (let n = 1; n <= lines.length; n++) {
if (n >= lineNumber) break; // Gone far enough
if (!lines[n-1]) {
lineNumber += 1; // Increment error line number for each blank line
if (!notified) {
console.log("Adjusting BCS grammar error line number to account for blank lines");
notified = true;
}
}
}
ourErrorObject.lineNumber = lineNumber;
}
}

const parseWarnings = parserResult._warnings ? parserResult._warnings : ourUsfmParser.warnings;
Expand Down
6 changes: 3 additions & 3 deletions src/core/book-package-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ export async function checkBookPackage(username, languageCode, bookID, setResult
const repoLocation = ` in ${repoCode.toUpperCase()}${generalLocation}`;
const repoName = getRepoName(languageCode, repoCode);

// const fullRepoName = username + '/' + repoName;
// console.log("Let's try1", bookID, "from", fullRepoName);
// Update our "waiting" message
setResultValue(<p style={{ color: 'magenta' }}>Checking {username} {languageCode} <b>{bookID}</b> book package in <b>{repoCode}</b> (checked <b>{checkedRepoNames.length.toLocaleString()}</b>/5 repos)…</p>);

let filename;
if (repoCode === 'UHB' || repoCode === 'UGNT' || repoCode === 'ULT' || repoCode === 'UST') {
Expand Down Expand Up @@ -574,7 +574,7 @@ export async function checkBookPackage(username, languageCode, bookID, setResult
}

// Update our "waiting" message
setResultValue(<p style={{ color: 'magenta' }}>Waiting for check results for {username} {languageCode} <b>{bookID}</b> book package: checked <b>{checkedRepoNames.length.toLocaleString()}</b>/5 repos…</p>);
// setResultValue(<p style={{ color: 'magenta' }}>Waiting for check results for {username} {languageCode} <b>{bookID}</b> book package: checked <b>{checkedRepoNames.length.toLocaleString()}</b>/5 repos…</p>);
}

// Add some extra fields to our checkFileResult object
Expand Down
4 changes: 2 additions & 2 deletions src/core/quote-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getFile } from '../core/getApi';
// import { consoleLogObject } from '../core/utilities';


// const QUOTE_VALIDATOR_VERSION_STRING = '0.3.1';
// const QUOTE_VALIDATOR_VERSION_STRING = '0.3.2';

const DEFAULT_EXTRACT_LENGTH = 10;

Expand Down Expand Up @@ -272,7 +272,7 @@ async function checkOriginalLanguageQuote(fieldName, fieldText, bookID, C, V, gi
const extract = fieldText.substring(0, halfLength) + (fieldText.length > 2*halfLength? '…':'') + fieldText.substring(fieldText.length-halfLength, fieldText.length);
// console.log(`722 fieldText='${fieldText}'${extraText}`);
// console.log(`722 verseText='${verseText}'`);
addNotice6({priority:722, message:"Unable to find original language quote in verse text", extract, location:ourLocation});
addNotice6({priority:912, message:"Unable to find original language quote in verse text", extract, location:ourLocation});

}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/tn-table-row-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import checkTNLinks from './tn-links-check';
import checkOriginalLanguageQuote from './quote-check';


// const TN_TABLE_ROW_VALIDATOR_VERSION_STRING = '0.4.1';
// const TN_TABLE_ROW_VALIDATOR_VERSION_STRING = '0.4.2';

const NUM_EXPECTED_TN_TSV_FIELDS = 9; // so expects 8 tabs per line
const EXPECTED_TN_HEADING_LINE = 'Book\tChapter\tVerse\tID\tSupportReference\tOrigQuote\tOccurrence\tGLQuote\tOccurrenceNote';
Expand Down Expand Up @@ -362,9 +362,9 @@ async function checkTN_TSVDataRow(line, bookID, C, V, givenRowLocation, optional
ourCheckTextField(rowID, 'OrigQuote', origQuote, false, ourRowLocation, optionalCheckingOptions);
await ourCheckTNOriginalLanguageQuote(rowID, 'OrigQuote', origQuote, ourRowLocation, optionalCheckingOptions);
}
else // TODO: Find out if these fields are really compulsory (and when they're not, e.g., for 'intro') ???
if (V !== 'intro')
addNotice6to9({priority:276, message:"Missing OrigQuote field", rowID, location:ourRowLocation});
else // TODO: Find more details about when these fields are really compulsory (and when they're not, e.g., for 'intro') ???
if (V !== 'intro' && occurrence !== '0')
addNotice6to9({priority:913, message:"Missing OrigQuote field", rowID, location:ourRowLocation});

if (occurrence.length) { // This should usually be a digit
if (occurrence === '0') { // zero means that it doesn't occur
Expand Down
Loading