forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Predatory journal checker (JabRef#10592)
* add PredatoryJournalRepository class * Refactor PredatoryJournalRepository to match JournalAbbreviationRepository design * Add PredatoryJournalChecker and PredatoryJournalLoader classes * Add Integrity Message for en Resources * Integrate PredatoryJournalChecker into IntegrityCheck * Initialize PredatoryJournalRepository on Launch * Add PredatoryJournalCheckerTest and more logging * Refactor PredatoryJournalLoader to switch from temp dir to user's app data * Add MV file generation for predatory journal lists * update CHANGELOG.md * Refactor and create own record class for journal information move to own gradle task and file * checkstyle, rename methods in gradle * run rewrite * fix test * fix duplicate handling * fix gradle task fix zwsp in name * more exception handling * Make serializable to fix mvstore Just use simpler levenstein distance should be enough add javadoc * checkstyle * fuck you checkstyle * checkstyle * refactor test * use same copy behavior as for journal abbrevs * make link elemens non static fix checkstyle * fix static vars * Split loader into crawler and "real" loader * Checkstyle * Fix variable type --------- Co-authored-by: Siedlerchr <[email protected]> Co-authored-by: Oliver Kopp <[email protected]>
- Loading branch information
1 parent
67e25a0
commit d03a43c
Showing
19 changed files
with
467 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/org/jabref/cli/PredatoryJournalsMvGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.jabref.cli; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jabref.logic.journals.predatory.PredatoryJournalInformation; | ||
import org.jabref.logic.journals.predatory.PredatoryJournalListCrawler; | ||
|
||
import org.h2.mvstore.MVMap; | ||
import org.h2.mvstore.MVStore; | ||
|
||
public class PredatoryJournalsMvGenerator { | ||
public static void main(String[] args) throws IOException { | ||
boolean verbose = (args.length == 1) && ("--verbose".equals(args[0])); | ||
|
||
Path predatoryJournalsMvFile = Path.of("build", "resources", "main", "journals", "predatory-journals.mv"); | ||
Files.createDirectories(predatoryJournalsMvFile.getParent()); | ||
|
||
try (MVStore store = new MVStore.Builder() | ||
.fileName(predatoryJournalsMvFile.toString()) | ||
.compressHigh() | ||
.backgroundExceptionHandler((t, e) -> { | ||
System.err.println("Exception occurred in Thread " + t + "with exception " + e); | ||
e.printStackTrace(); | ||
}) | ||
.open()) { | ||
MVMap<String, PredatoryJournalInformation> predatoryJournalsMap = store.openMap("PredatoryJournals"); | ||
|
||
PredatoryJournalListCrawler loader = new PredatoryJournalListCrawler(); | ||
Set<PredatoryJournalInformation> predatoryJournals = loader.loadFromOnlineSources(); | ||
|
||
var resultMap = predatoryJournals.stream().collect(Collectors.toMap(PredatoryJournalInformation::name, Function.identity(), | ||
(predatoryJournalInformation, predatoryJournalInformation2) -> { | ||
if (verbose) { | ||
System.out.println("Double entry " + predatoryJournalInformation.name()); | ||
} | ||
return predatoryJournalInformation2; | ||
})); | ||
|
||
predatoryJournalsMap.putAll(resultMap); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/jabref/logic/integrity/PredatoryJournalChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jabref.logic.integrity; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.jabref.logic.journals.predatory.PredatoryJournalRepository; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.Field; | ||
|
||
public class PredatoryJournalChecker implements EntryChecker { | ||
|
||
private final PredatoryJournalRepository predatoryJournalRepository; | ||
private final List<Field> fieldNames; | ||
|
||
public PredatoryJournalChecker(PredatoryJournalRepository predatoryJournalRepository, List<Field> fieldsToCheck) { | ||
this.predatoryJournalRepository = Objects.requireNonNull(predatoryJournalRepository); | ||
this.fieldNames = fieldsToCheck; | ||
} | ||
|
||
@Override | ||
public List<IntegrityMessage> check(BibEntry entry) { | ||
return entry.getFieldMap().entrySet().stream() | ||
.filter(field -> fieldNames.contains(field.getKey())) | ||
.filter(field -> predatoryJournalRepository.isKnownName(field.getValue())) | ||
.map(field -> new IntegrityMessage(Localization.lang("Predatory journal %0 found", field.getValue()), entry, field.getKey())) | ||
.toList(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/jabref/logic/journals/predatory/PredatoryJournalInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jabref.logic.journals.predatory; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Represents predatory journal information | ||
* | ||
* @param name The full journal name | ||
* @param abbr Abbreviation, if any | ||
* @param url Url of the journal | ||
*/ | ||
public record PredatoryJournalInformation( | ||
String name, | ||
String abbr, | ||
String url) implements Serializable { // must implement @Serializable otherwise MVStore fails | ||
} |
Oops, something went wrong.