Skip to content

Commit

Permalink
Merge branch 'main' into use-jdk21u1
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Oct 20, 2023
2 parents 2222b14 + 3670ef6 commit c63857b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
import org.jooq.lambda.Unchecked;
import org.jooq.lambda.UncheckedException;
import org.jsoup.HttpStatusException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -70,12 +71,17 @@ public String getName() {
@Override
public List<BibEntry> performSearch(String searchQuery) throws FetcherException {
List<BibEntry> collect;
collect = Arrays.stream(searchQuery.split("\\r\\r+|\\n\\n+|\\r\\n(\\r\\n)+"))
.map(String::trim)
.filter(str -> !str.isBlank())
.map(Unchecked.function(this::parseUsingGrobid))
.flatMap(Optional::stream)
.collect(Collectors.toList());
try {
collect = Arrays.stream(searchQuery.split("\\r\\r+|\\n\\n+|\\r\\n(\\r\\n)+"))
.map(String::trim)
.filter(str -> !str.isBlank())
.map(Unchecked.function(this::parseUsingGrobid))
.flatMap(Optional::stream)
.collect(Collectors.toList());
} catch (UncheckedException e) {
// This "undoes" Unchecked.function(this::parseUsingGrobid))
throw (FetcherException) e.getCause();
}
return collect;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Optional<BibEntry> processCitation(String rawCitation, ImportFormatPrefer
.data("consolidateCitations", String.valueOf(consolidateCitations.getCode()))
.method(Connection.Method.POST)
.ignoreContentType(true)
.timeout(20000)
.timeout(100_000)
.execute();
String httpResponse = response.body();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import static org.mockito.Mockito.when;

@FetcherTest
@Disabled
public class CollectionOfComputerScienceBibliographiesParserTest {

@Test
public void parseEntriesReturnsEmptyListIfXmlHasNoResults() throws Exception {
parseXmlAndCheckResults("collection_of_computer_science_bibliographies_empty_result.xml", Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ public class GrobidCitationFetcherTest {
.withField(StandardField.AUTHOR, "Thomas, H")
.withField(StandardField.TITLE, "Training strategies for improving listeners' comprehension of foreign-accented speech (Doctoral dissertation)")
.withField(StandardField.DATE, "2004")
.withField(StandardField.PUBLISHER, "University of Colorado")
.withField(StandardField.YEAR, "2004")
.withField(StandardField.ADDRESS, "Boulder");

static String example3 = "Turk, J., Graham, P., & Verhulst, F. (2007). Child and adolescent psychiatry : A developmental approach. Oxford, England: Oxford University Press.";
static BibEntry example3AsBibEntry = new BibEntry(BibEntry.DEFAULT_TYPE).withCitationKey("-1")
static BibEntry example3AsBibEntry = new BibEntry(StandardEntryType.InBook).withCitationKey("-1")
.withField(StandardField.AUTHOR, "Turk, Jeremy and Graham, Philip and Verhulst, Frank")
.withField(StandardField.TITLE, "Child and Adolescent Psychiatry")
.withField(StandardField.TITLE, "Developmental psychopathology")
.withField(StandardField.BOOKTITLE, "Child and Adolescent Psychiatry")
.withField(StandardField.PUBLISHER, "Oxford University Press")
.withField(StandardField.DATE, "2007-02")
.withField(StandardField.YEAR, "2007")
.withField(StandardField.MONTH, "2")
.withField(StandardField.DOI, "10.1093/med/9780199216697.001.0001")
.withField(StandardField.PAGES, "191-264")
.withField(StandardField.DOI, "10.1093/med/9780199216697.003.0004")
.withField(StandardField.ADDRESS, "Oxford, England");

static String example4 = "Carr, I., & Kidner, R. (2003). Statutes and conventions on international trade law (4th ed.). London, England: Cavendish.";
Expand All @@ -78,6 +81,7 @@ public class GrobidCitationFetcherTest {
.withField(StandardField.PUBLISHER, "Cavendish")
.withField(StandardField.DATE, "2003")
.withField(StandardField.YEAR, "2003")
.withField(StandardField.NUMBER, "4")
.withField(StandardField.ADDRESS, "London, England");

public static Stream<Arguments> provideExamplesForCorrectResultTest() {
Expand All @@ -91,7 +95,7 @@ public static Stream<Arguments> provideExamplesForCorrectResultTest() {

public static Stream<Arguments> provideInvalidInput() {
return Stream.of(
Arguments.of("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx________________________________"),
Arguments.of("😋😋😋"),
Arguments.of("¦@#¦@#¦@#¦@#¦@#¦@#¦@°#¦@¦°¦@°")
);
}
Expand Down

0 comments on commit c63857b

Please sign in to comment.