You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ma...@apache.org on 2025/12/26 17:59:29 UTC

(opennlp) branch OPENNLP-1791-Document-the-use-of-ClassPathModelProvider-in-dev-manual created (now 6cda164b)

This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a change to branch OPENNLP-1791-Document-the-use-of-ClassPathModelProvider-in-dev-manual
in repository https://gitbox.apache.org/repos/asf/opennlp.git


      at 6cda164b OPENNLP-1791: Document the use of ClassPathModelProvider in dev manual

This branch includes the following new commits:

     new 6cda164b OPENNLP-1791: Document the use of ClassPathModelProvider in dev manual

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(opennlp) 01/01: OPENNLP-1791: Document the use of ClassPathModelProvider in dev manual

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch OPENNLP-1791-Document-the-use-of-ClassPathModelProvider-in-dev-manual
in repository https://gitbox.apache.org/repos/asf/opennlp.git

commit 6cda164bea4c9f96032df35f5bedfa05708c6ae4
Author: Martin Wiesner <ma...@hs-heilbronn.de>
AuthorDate: Fri Dec 26 18:59:23 2025 +0100

    OPENNLP-1791: Document the use of ClassPathModelProvider in dev manual
---
 opennlp-docs/src/docbkx/model-loading.xml | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/opennlp-docs/src/docbkx/model-loading.xml b/opennlp-docs/src/docbkx/model-loading.xml
index aec161cd..b4e0f37a 100644
--- a/opennlp-docs/src/docbkx/model-loading.xml
+++ b/opennlp-docs/src/docbkx/model-loading.xml
@@ -95,6 +95,25 @@ for(ClassPathModelEntry entry : models) {
 }]]>
             </programlisting>
 
+          Moreover, certain OpenNLP models can be obtained via a
+          <emphasis>ClassPathModelProvider</emphasis>, such as OpenNLP's
+          built-in <emphasis>DefaultClassPathModelProvider</emphasis> class.
+          It allows direct use of models available under a certain locale, given
+          that those are present in the classpath and can be loaded.
+
+          <programlisting language="java">
+            <![CDATA[
+final ClassPathModelProvider provider = new DefaultClassPathModelProvider(finder, loader);
+// Here: SentenceModel, other model types accordingly
+final SentenceModel sm = provider.load("en", opennlp.tools.models.ModelType.SENTENCE_DETECTOR, SentenceModel.class);
+if(sm != null) {
+  // do something with the (sentence) model
+}]]>
+          </programlisting>
+
+          In the above example, the finder and loader objects can be created or re-used as shown in the
+          previous code example.
+
         </para>
 	</section>