Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Added Fetcher for ISIDORE #10518
Added Fetcher for ISIDORE #10518
Changes from 15 commits
fb2222e
7d65239
0f87aed
6d02f06
25e4985
060b388
3037d9a
ea6988e
403bf06
6d286fe
e50b370
39496eb
664a933
bcd405c
c08beb0
38b9d33
48def73
b246a0d
86e4ba4
ca69df7
81c2172
8f45b03
e15a3aa
0ca60b9
4dacce8
065c4cf
db4a9ad
620f719
0553443
80e1088
4702d14
1e3f3a3
ae49b38
fdf40fd
b3e7d59
5c09c36
cd6d630
8e3eb37
50e4205
d00eeb1
e96cfef
b8c8f68
92cf060
87f17bc
5b04053
d4d08e0
b71ef06
baa4038
42bac2b
a0dfb2d
247ec3e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
You should also implement
PagedSearchBasedParserFetcher
to allow searching for a term. That makes more sense as the vast majority of users won't have an ISIDORE reference id.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.
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.
Is this suggestion OK for you or do you see any issues?
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.
Unfortunately some of the Author nodes are a bit weird. Sometimes they contain a string of numbers and a dash after the name and then repeat the name again for no apparent reason e.g. (Patrick Bonnel becomes Patrick Bonnel 0766-05442 Patrick). So to solve this I simply removed everything after the first number.
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.
This is OK. You can even put that as JavaDoc comment and as test case.
What I meant: Your lines 155 to 160 can be dine with a one-line RegEx.
Using
string.replaceFirst("\\d.*", "")
is a concise and efficient way to achieve the same result. This regular expression will replace the first digit and everything that follows it with an empty string, effectively removing the numbers and everything after them.Here's the
removeNumbers
method usingreplaceFirst
:In the regex:
\\d
matches the first digit encountered..*
matches everything after the digit.The
replaceFirst
method will then replace this matched portion with an empty string. If no match is found (i.e., if there are no digits), the original string remains unchanged. This is a clean and efficient way to achieve the desired behavior.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.
I have a second ChatGPT suggestion, but I don't know about performance gains. I tend to keep the above suggestion and optimize if there are performance issues
Given your context, the method you've provided returns the portion of the string before the first number. Using a regular expression, we can accomplish the same task more concisely.
Here's a refactored version of the
removeNumbers
method using regex:The regular expression
^[^\\d]*
can be interpreted as:^
asserts position at the start of a string.[^\\d]*
matches zero or more non-digit characters.The method works by matching as many non-digit characters as possible from the beginning of the string until it encounters a digit (or the end of the string). If a match is found, it returns that match; otherwise, it simply returns the original string.
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.
The second option is good, if
Pattern.compile(....)
is moved to a class constant.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.
the interface has a default method, so if you don't to anything extra, you can remove the. method
the same applies to the method below