Class DownloadUtil.DownloadParser
java.lang.Object
opennlp.tools.util.DownloadUtil.DownloadParser
- Enclosing class:
DownloadUtil
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDownloadParser(URL indexUrl) Initializes a parser that keeps no copy of the index page.DownloadParser(URL indexUrl, Path localIndex) Initializes a parser that keeps a copy of the index page. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidextractLinks(String page) private StringReads the index page from its URL, joining its lines.Lists the models of the index page.private StringReads the local copy of the index page.private voidstoreLocalIndex(String page) Stores the index page as the local copy.
-
Field Details
-
LINK_PATTERN
-
indexUrl
-
localIndex
-
-
Constructor Details
-
DownloadParser
DownloadParser(URL indexUrl) Initializes a parser that keeps no copy of the index page.- Parameters:
indexUrl- The index page.- Throws:
NullPointerException- Thrown ifindexUrlisnull.
-
DownloadParser
Initializes a parser that keeps a copy of the index page.- Parameters:
indexUrl- The index page.localIndex- The file that keeps a copy of the index page, ornullto keep no copy.- Throws:
NullPointerException- Thrown ifindexUrlisnull.
-
-
Method Details
-
getAvailableModels
Lists the models of the index page. If the page lists models, it is stored as the local copy. Otherwise, for example if the page cannot be read, the local copy is used.- Returns:
- The model URLs per language and
ModelType. Empty if neither the page nor the local copy lists models.
-
extractLinks
-
readLocalIndex
Reads the local copy of the index page.- Returns:
- The page content, or
nullif there is no readable copy.
-
storeLocalIndex
Stores the index page as the local copy. The page is written to a temporary file that then replaces the copy, so a reader never sees a partly written copy. A failure is only logged.- Parameters:
page- The page content.
-
toMap
-
addModel
-
fetchPageIndex
Reads the index page from its URL, joining its lines.- Returns:
- The page content, or
nullif the page could not be read completely.
-