-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix for issue 5804: Rewrite ACM fetcher #7733
Conversation
update jabref
update jabref
2. Added Modified ACMPortalFetcherTest and ACMPortalParserTest.
|
||
private StandardEntryType typeStrToEnum(String typeStr) { | ||
StandardEntryType type; | ||
typeStr = typeStr.toLowerCase(Locale.ENGLISH).replace("_", ""); |
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 think you can simplify this whole EntryType stuff, if you want too look up an enum key by the string value:
StandardEntryType.valueOf(...)
Or alternatively, use the guava equivalent https://guava.dev/releases/19.0/api/docs/index.html?com/google/common/base/Enums.html
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 problem here is that the entry of StandardEntryType uses big camelcase nomenclature, I can't directly use StandardEntryType.valueOf(...), or I need to find a good way from JabRef to deal with big camelcase format and all-caps dashed separation format conversion.
And some types of naming do not match exactly. For example, the API returns PAPER_CONFERENCE corresponding to the CONFERENCE of StandardEntryType.
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.
Ah I understand, however, you can directly operate on the Enum, there is the possibility to use an EnumSet and you have an Optional to check for the type.
This approach is simpler and you don't need to create a new Map with the keys and values
Optional<StandardEntryType> foundType = EnumSet.allOf(StandardEntryType.class).stream().filter(type-> type.getDisplayName().equals(strType)).findAny();
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.
Optional<StandardEntryType> foundType = EnumSet.allOf(StandardEntryType.class).stream().filter(type-> type.getDisplayName().equals(strType)).findAny();
This is invalid if the input string is ARTICLE
New version~
private StandardEntryType typeStrToEnum(String typeStr) {
StandardEntryType type;
if ("PAPER_CONFERENCE".equals(typeStr)) {
type = StandardEntryType.Conference;
} else {
String upperUnderscoreTyeStr = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, typeStr);
type = Enums.getIfPresent(StandardEntryType.class, upperUnderscoreTyeStr).or(StandardEntryType.Article);
}
return type;
}
src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
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.
Overall this looks already good to me, just some mimor changes/improvements
2. Fix some minor problems. 3. Merged the new content of the branch main.
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.
Good job!
Thank you for creating tests!
Small comments on the tests itself.
@@ -93,7 +94,7 @@ private WebFetchers() { | |||
set.add(new MathSciNet(importFormatPreferences)); | |||
set.add(new ZbMATH(importFormatPreferences)); | |||
// see https://github.com/JabRef/jabref/issues/5804 | |||
// set.add(new ACMPortalFetcher(importFormatPreferences)); |
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.
Just remove the disabled lines
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.
fixed.
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.
May I ask whether you committed that change?
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 deleted these two lines
// see https://github.com/JabRef/jabref/issues/5804
// set.add(new ACMPortalFetcher(importFormatPreferences));
do you mean I still need to delete this line?
// set.add(new GoogleScholar(importFormatPreferences));
But this is another Fetcher
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.
Sorry, was too late. Everything allright! 🎉
src/main/java/org/jabref/logic/importer/fetcher/ACMPortalFetcher.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/ACMPortalParserTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jabref/logic/importer/fetcher/ACMPortalFetcherTest.java
Outdated
Show resolved
Hide resolved
2. Updated the test case 3. Updated JavaDoc
@Siedlerchr @koppor Thank you very much for your help and suggestions. |
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.
Thank you for the quick follow-up.
Some small nitpicks remain 😇
@@ -93,7 +94,7 @@ private WebFetchers() { | |||
set.add(new MathSciNet(importFormatPreferences)); | |||
set.add(new ZbMATH(importFormatPreferences)); | |||
// see https://github.com/JabRef/jabref/issues/5804 | |||
// set.add(new ACMPortalFetcher(importFormatPreferences)); |
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.
May I ask whether you committed that change?
src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java
Outdated
Show resolved
Hide resolved
Thank you for working on it! This brings JabRef a step forward! |
Fixes #5804
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)From issue #5804, ACM Fetcher needs to be rewritten, because of ACM website changes.
One solution is to get the DOI from the HTML results of the search page, then use the export interface to get the JSON format data, and finally parse them.
Search API: https://dl.acm.org/action/doSearch?AllField=<query_string>
Export API: https://dl.acm.org/action/exportCiteProcCitation?targetFile=custom-bibtex&format=bibTex&dois=<doi>,<doi>,...
What did I do:
Successfully get data from AMC Fetcher: