-
-
Notifications
You must be signed in to change notification settings - Fork 17
Validate usfm versification #353
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
Conversation
|
Still need to add tests. |
7ff60f6 to
b8a9089
Compare
|
Tests have been added. I'm really excited to get this in 🎉. |
ddaspit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddaspit reviewed 16 of 22 files at r1, 2 of 3 files at r2, 7 of 10 files at r3, 3 of 4 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Enkidu93)
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 108 at r4 (raw file):
if ( Type == UsfmVersificationMismatchType.MissingVerseSegment && VerseRef.TryParse(
Why are you using TryParse here and not the constructor?
src/SIL.Machine/Corpora/IParatextProjectFileHandler.cs line 5 at r1 (raw file):
namespace SIL.Machine.Corpora { public interface IParatextProjectFileHandler
Shouldn't we also use this interface in ParatextProjectSettingsParserBase?
src/SIL.Machine/Corpora/ParatextProjectVersificationMismatchDetector.cs line 8 at r1 (raw file):
namespace SIL.Machine.Corpora { public abstract class ParatextProjectVersificationMismatchDetector
By convention, ABCs are suffixed with Base.
src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs line 299 at r1 (raw file):
} private Stream Open(string fileName) => _paratextProjectFileHandler.Open(fileName);
This indirection is unnecessary. I would just call _paratextProjectFileHandler directly.
Enkidu93
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 9 of 32 files reviewed, 4 unresolved discussions (waiting on @ddaspit)
src/SIL.Machine/Corpora/IParatextProjectFileHandler.cs line 5 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
Shouldn't we also use this interface in
ParatextProjectSettingsParserBase?
We could. I pushed a change with this update. It felt a little awkward to me since 1) they're doing slightly different things and 2) we end up having to match the right classes in all the constructors as well as pass both an IParatextProjectFileHandler and a class which itself has a IParatextProjectFileHandler. There might be a better way, but this is better than it was before!
src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs line 299 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
This indirection is unnecessary. I would just call
_paratextProjectFileHandlerdirectly.
OK, done.
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 108 at r4 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
Why are you using
TryParsehere and not the constructor?
I don't trust the constructor and would rather not throw an exception (see sillsdev/serval#796). My thinking was that if it fails to parse the verse ref string, that probably indicates that there is an issue at that ref and we could still indicate where the issue is. I guess this thinking ought to extend to
VerseRef defaultVerseRef = new VerseRef(_bookNum, _expectedChapter, _expectedVerse);
as well then.
src/SIL.Machine/Corpora/ParatextProjectVersificationMismatchDetector.cs line 8 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
By convention, ABCs are suffixed with
Base.
Oh right - thank you - done.
ddaspit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddaspit reviewed 23 of 23 files at r6, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Enkidu93)
src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs line 299 at r1 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
OK, done.
I think you forgot to remove these methods.
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 108 at r4 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
I don't trust the constructor and would rather not throw an exception (see sillsdev/serval#796). My thinking was that if it fails to parse the verse ref string, that probably indicates that there is an issue at that ref and we could still indicate where the issue is. I guess this thinking ought to extend to
VerseRef defaultVerseRef = new VerseRef(_bookNum, _expectedChapter, _expectedVerse);as well then.
I would add a comment to indicate that we don't want to throw an exception here, so we aren't using the constructor.
src/SIL.Machine/Corpora/FileParatextProjectTextUpdater.cs line 8 at r6 (raw file):
: base( new FileParatextProjectFileHandler(projectDir), new FileParatextProjectSettingsParser(projectDir).Parse()
It might be nice to add a static Parse method to FileParatextProjectSettingsParser, i.e.
FileParatextProjectSettingsParser.Parse(projectDir)src/SIL.Machine/Corpora/IParatextProjectFileHandler.cs line 12 at r6 (raw file):
UsfmStylesheet CreateStylesheet(string fileName); // ParatextProjectSettings GetSettings();
Don't forget to remove this commented out line of code.
Enkidu93
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ddaspit)
src/SIL.Machine/Corpora/FileParatextProjectTextUpdater.cs line 8 at r6 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
It might be nice to add a static
Parsemethod toFileParatextProjectSettingsParser, i.e.FileParatextProjectSettingsParser.Parse(projectDir)
OK, I added one for the zip implementation too.
src/SIL.Machine/Corpora/IParatextProjectFileHandler.cs line 12 at r6 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
Don't forget to remove this commented out line of code.
Yes, thank you! Done.
src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs line 299 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
I think you forgot to remove these methods.
Done.
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 108 at r4 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
I would add a comment to indicate that we don't want to throw an exception here, so we aren't using the constructor.
Done. Let me know if you'd prefer different wording.
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 18 at r6 (raw file):
} public class UsfmVersificationMismatch
What do you think of these class names, @ddaspit? Would it be better to use a more generic name like UsfmVersificationError since we're now also covering invalid verses that aren't necessarily 'mismatches'?
ddaspit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddaspit reviewed 12 of 12 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Enkidu93)
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 18 at r6 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
What do you think of these class names, @ddaspit? Would it be better to use a more generic name like
UsfmVersificationErrorsince we're now also covering invalid verses that aren't necessarily 'mismatches'?
Yes, I think a more generic name would be better.
Enkidu93
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 25 of 32 files reviewed, 1 unresolved discussion (waiting on @ddaspit)
src/SIL.Machine/Corpora/UsfmVersificationMismatchDetector.cs line 18 at r6 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
Yes, I think a more generic name would be better.
Cool, done.
ddaspit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddaspit reviewed 7 of 7 files at r8, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)
Fix unused imports Fix import sorting Address reviewr comments Add parameter types Use isort
Fixes #318
Partially addresses sillsdev/serval#768
This change is