Verified Owner
Top Fields Constructors Methods
org.jabref.logic.importer.fetcher

public Class SemanticScholar

extends Object
implements FulltextFetcher, PagedSearchBasedParserFetcher, EntryBasedFetcher, CustomizableKeyFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.fetcher.CustomizableKeyFetcher, org.jabref.logic.importer.WebFetcher, org.jabref.logic.importer.EntryBasedFetcher, org.jabref.logic.importer.PagedSearchBasedParserFetcher, org.jabref.logic.importer.ParserFetcher, org.jabref.logic.importer.PagedSearchBasedFetcher, org.jabref.logic.importer.SearchBasedFetcher, org.jabref.logic.importer.SearchBasedParserFetcher, org.jabref.logic.importer.FulltextFetcher
Imports
java.io.IOException, java.net.MalformedURLException, .URISyntaxException, .URL, java.util.ArrayList, .List, .Optional, java.util.stream.Collectors, .IntStream, org.jabref.logic.importer.EntryBasedFetcher, .FetcherException, .FulltextFetcher, .ImporterPreferences, .PagedSearchBasedParserFetcher, .ParseException, .Parser, org.jabref.logic.importer.fetcher.transformers.DefaultQueryTransformer, org.jabref.logic.importer.util.JsonReader, org.jabref.logic.net.URLDownload, org.jabref.logic.util.URLUtil, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.entry.identifier.ArXivIdentifier, .DOI, org.jabref.model.entry.types.StandardEntryType, org.jabref.model.search.query.BaseQueryNode, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.apache.hc.core5.net.URIBuilder, org.jsoup.Connection, .Jsoup, org.jsoup.nodes.Document, .Element, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private final ImporterPreferences
private static final Logger
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
SemanticScholar(ImporterPreferences importerPreferences)

Method Summary

Modifier and TypeMethod and Description
private URL
buildSearchURL(String query, int pageNumber)

Builds the search URL for the given query string

The query is sent as the query parameter, so raw queries bypass DefaultQueryTransformer and are passed unchanged to the catalog

public Optional<URL>

Returns:

The fulltext PDF URL Optional, if found, or an empty Optional if not found.
findFullText
(@NonNull BibEntry
The Bibtex entry
entry
)

Tries to find a fulltext URL for a given BibTex entry.

public String
getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

Returns the localized name of this fetcher.

public Parser
getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

public TrustLevel
getTrustLevel()

Implements org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Returns the level of trust for this fetcher.

pack-priv String
public URL
getURLForQuery(BaseQueryNode queryNode, int pageNumber)

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the query, size and page number.

public URL
getURLForRawQuery(String rawQuery, int pageNumber)

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForRawQuery.

Constructs a URL that sends the raw, catalog-native query verbatim to the catalog (bypassing the query transformer).

private BibEntry

Returns:

The BibEntry that corresponds to the received object
jsonItemToBibEntry
(kong.unirest.core.json.JSONObject
an entry received, needs to be parsed into a BibEntry
item
)

This is copy-paste from CrossRef, need to be checked.

public List<BibEntry>

Returns:

a list of BibEntry, which are matched by the query (may be empty)
performSearch
(@NonNull BibEntry
entry to search bibliographic information for
entry
)

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

importerPreferencesback to summary
private final ImporterPreferences importerPreferences
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

SemanticScholarback to summary
public SemanticScholar(ImporterPreferences importerPreferences)

Method Detail

buildSearchURLback to summary
private URL buildSearchURL(String query, int pageNumber) throws URISyntaxException, MalformedURLException

Builds the search URL for the given query string

The query is sent as the query parameter, so raw queries bypass DefaultQueryTransformer and are passed unchanged to the catalog

findFullTextback to summary
public Optional<URL> findFullText(@NonNull BibEntry entry) throws IOException, FetcherException

Tries to find a fulltext URL for a given BibTex entry.

Uses the DOI if present, otherwise the arXiv identifier.

Parameters
entry:@NonNull BibEntry

The Bibtex entry

Returns:Optional<URL>

The fulltext PDF URL Optional, if found, or an empty Optional if not found.

Annotations
@Override
Exceptions
IOException:
if a page could not be fetched correctly
FetcherException:
if the received page differs from what was expected
getNameback to summary
public String getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

Doc from org.jabref.logic.importer.WebFetcher.getName.

Returns the localized name of this fetcher. The title can be used to display the fetcher in the menu and in the side pane.

Todo

This name is also used for identifying the fetcher in preferences for API keys. Thus, any switch of the language will "remove" API keys.

Annotations
@Override
getParserback to summary
public Parser getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

Annotations
@Override
getTrustLevelback to summary
public TrustLevel getTrustLevel()

Implements org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Doc from org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Returns the level of trust for this fetcher. We distinguish between publishers and meta search engines for example.

Annotations
@Override
getURLBySourceback to summary
pack-priv String getURLBySource(String source) throws IOException, FetcherException
getURLForQueryback to summary
public URL getURLForQuery(BaseQueryNode queryNode, int pageNumber) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Doc from org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the query, size and page number.

Annotations
@Override
getURLForRawQueryback to summary
public URL getURLForRawQuery(String rawQuery, int pageNumber) throws URISyntaxException, MalformedURLException

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForRawQuery.

Doc from org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForRawQuery.

Constructs a URL that sends the raw, catalog-native query verbatim to the catalog (bypassing the query transformer).

Annotations
@Override
jsonItemToBibEntryback to summary
private BibEntry jsonItemToBibEntry(kong.unirest.core.json.JSONObject item) throws ParseException

This is copy-paste from CrossRef, need to be checked.

Parameters
item:kong.unirest.core.json.JSONObject

an entry received, needs to be parsed into a BibEntry

Returns:BibEntry

The BibEntry that corresponds to the received object

Exceptions
ParseException:
if the JSONObject could not be parsed
performSearchback to summary
public List<BibEntry> performSearch(@NonNull BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

Parameters
entry:@NonNull BibEntry

entry to search bibliographic information for

Returns:List<BibEntry>

a list of BibEntry, which are matched by the query (may be empty)

Annotations
@Override
Exceptions
FetcherException:
if an error linked to the Fetcher applies