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

Update tokenizer #205

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f4ccac6
Updated the regex
VisLab Oct 11, 2024
769aa3b
Updated the splitter
VisLab Oct 11, 2024
9b2bb73
Merge branch 'master' of https://github.com/hed-standard/hed-javascri…
VisLab Oct 11, 2024
550cdb2
Merge branch 'master' of https://github.com/hed-standard/hed-javascri…
VisLab Oct 16, 2024
5127943
Updating to start tokenizer
VisLab Oct 16, 2024
01ecd6a
Updated the test of tokenizer
VisLab Oct 16, 2024
7b72f78
First pass at testing tokenizer
VisLab Oct 17, 2024
0758bfe
Updated the tokenizer
VisLab Oct 17, 2024
906bdbc
More experiments with the tokenizer
VisLab Oct 18, 2024
2d8a51f
First pass at rewritten tokenizer
VisLab Oct 19, 2024
bd73724
Working on slash handling
VisLab Oct 19, 2024
a918907
Updated the tokenizer to handle empty tags
VisLab Oct 19, 2024
f9b659d
Basic tests are running
VisLab Oct 19, 2024
1d3307a
Initial implementation of the new tokenizer
VisLab Oct 20, 2024
c427407
stringParser tests now past with new tokenizer
VisLab Oct 21, 2024
c397a12
Worked on the other tests
VisLab Oct 21, 2024
6ef9400
Separated the tests on the original tokenizer temporarily
VisLab Oct 22, 2024
62f5a2b
Corrected the error message on curly brace recursion
VisLab Oct 22, 2024
cf03a72
Removed temporary test
VisLab Oct 22, 2024
cd53a2c
Skipped tests on old tokenizer
VisLab Oct 22, 2024
f6034df
bidsTests just started
VisLab Oct 23, 2024
3473342
Updated bids tests to include a valid and invalid case
VisLab Oct 24, 2024
1c2f686
Continued reorganizing the bids spec tests
VisLab Oct 25, 2024
31e3229
Updated the tests
VisLab Oct 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Download dependencies
run: npm ci
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v8.0.0
uses: paambaati/codeclimate-action@v9.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist/
spec_tests/*.txt
spec_tests/temp*.json
spec_tests/temp.spec.js
tests/temp.spec.js

# Unit test / coverage reports
htmlcov/
Expand Down
33 changes: 20 additions & 13 deletions bids/validator/bidsHedTsvValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export class BidsHedTsvValidator {
* @private
*/
_validateHedColumn() {
if (this.tsvFile.hedColumnHedStrings.length === 0) {
// no HED column strings to validate
return []
}
return this.tsvFile.hedColumnHedStrings.flatMap((hedString, rowIndexMinusTwo) =>
this._validateHedColumnString(hedString, rowIndexMinusTwo + 2),
)
Expand Down Expand Up @@ -230,13 +234,14 @@ export class BidsHedTsvParser {
*/
_parseHedRows(tsvHedRows) {
const hedStrings = []

tsvHedRows.forEach((row, index) => {
const hedString = this._parseHedRow(row, index + 2)
if (hedString !== null) {
hedStrings.push(hedString)
}
})
if (tsvHedRows.size > 0) {
tsvHedRows.forEach((row, index) => {
const hedString = this._parseHedRow(row, index + 2)
if (hedString !== null) {
hedStrings.push(hedString)
}
})
}
return hedStrings
}

Expand All @@ -248,13 +253,15 @@ export class BidsHedTsvParser {
* @private
*/
_mergeEventRows(rowStrings) {
const groupedTsvRows = groupBy(rowStrings, (rowString) => rowString.onset)
const sortedOnsetTimes = Array.from(groupedTsvRows.keys()).sort((a, b) => a - b)
const eventStrings = []
for (const onset of sortedOnsetTimes) {
const onsetRows = groupedTsvRows.get(onset)
const onsetEventString = new BidsTsvEvent(this.tsvFile, onsetRows)
eventStrings.push(onsetEventString)
if (rowStrings.length > 0) {
const groupedTsvRows = groupBy(rowStrings, (rowString) => rowString.onset)
const sortedOnsetTimes = Array.from(groupedTsvRows.keys()).sort((a, b) => a - b)
for (const onset of sortedOnsetTimes) {
const onsetRows = groupedTsvRows.get(onset)
const onsetEventString = new BidsTsvEvent(this.tsvFile, onsetRows)
eventStrings.push(onsetEventString)
}
}
return eventStrings
}
Expand Down
15 changes: 15 additions & 0 deletions common/issues/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,26 @@ export default {
level: 'error',
message: stringTemplate`Invalid tag - "${'tag'}".`,
},
extraSlash: {
hedCode: 'TAG_INVALID',
level: 'error',
message: stringTemplate`Tag has extra slash at index ${'index'} of string "${'string'}".`,
},
extraBlank: {
hedCode: 'TAG_INVALID',
level: 'error',
message: stringTemplate`Tag has extra blank at index ${'index'} of string "${'string'}".`,
},
extraCommaOrInvalid: {
hedCode: 'TAG_INVALID',
level: 'error',
message: stringTemplate`Either "${'previousTag'}" contains a comma when it should not or "${'tag'}" is not a valid tag.`,
},
invalidTagPrefix: {
hedCode: 'TAG_NAMESPACE_PREFIX_INVALID',
level: 'error',
message: stringTemplate`Either tag prefix at index ${'index'} contains non-alphabetic characters or does not have an associated schema.`,
},
multipleUniqueTags: {
hedCode: 'TAG_NOT_UNIQUE',
level: 'error',
Expand Down
Loading
Loading