[ 
https://issues.apache.org/jira/browse/TIKA-490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jan Høydahl updated TIKA-490:
-----------------------------

    Attachment: TIKA-490.janhoy.092010.patch

Updated patch which adds ability to load your own map of LanguageProfile-s 
programmatically. I chose to do that not via a constructor, but rather a new 
signature for for initProfiles(), which will replace the profiles map with the 
one provided.

The public API after this patch will be:
    // Existing
    public LanguageIdentifier(LanguageProfile profile)
    public LanguageIdentifier(String content)
    public String getLanguage()
    public boolean isReasonablyCertain()
    public String toString()

    // New from patch
    public static void initProfiles()
    public static void initProfiles(Map<String, LanguageProfile> profilesMap)
    public static void clearProfiles()
    public static void addProfile(String language, LanguageProfile profile)
    public static Set<String> getSupportedLanguages()
    public static boolean hasErrors()
    public static String getErrors()

None of the original signatures are changed.
You can now initialize language profiles in these ways:
A) Loading tika.language.properties and profiles from jar file (default, 
equivalent to v0.7)
B) Loading tika.language.override.properties from classpath and profiles from 
classpath (nice for integrators)
C) Dynamic from client code, using addProfile and/or initProfiles(Map<String, 
LanguageProfile>)

PS: I removed the getDistance() method again, since it's exposing internal 
value. Already available through toString() for those who need it. Also removed 
the "force" parameter to initProfiles() as it's not needed - we always want to 
init from scratch.

> Support for adding language profiles dynamically
> ------------------------------------------------
>
>                 Key: TIKA-490
>                 URL: https://issues.apache.org/jira/browse/TIKA-490
>             Project: Tika
>          Issue Type: Improvement
>          Components: languageidentifier
>    Affects Versions: 0.7
>            Reporter: Jan Høydahl
>            Assignee: Chris A. Mattmann
>             Fix For: 0.8
>
>         Attachments: TIKA-490.janhoy.082310.patch, 
> TIKA-490.janhoy.082310.patch, TIKA-490.janhoy.092010.patch, 
> TIKA-490.Mattmann.082210.2.patch.txt, TIKA-490.Mattmann.082210.patch.txt, 
> TIKA-490.patch, TIKA-490.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Currently the Tika LanguageIdentifier loads language profiles thorugh a 
> hardcoded static block in the java code.
> It would be better to make this configurable, so you could add your own 
> languages without recompiling.
> Suggested approach:
> Remove the static code block loading all languages. Instead look for a 
> tika.languageidentification.properties file on classpath.
> Now the user can simply make his/her own (additional) language profile files, 
> put them on the classpath together with a properties file and off you go!
> Also, once you make it configurable, there might be an issue of having the 
> profiles as static members, as you will force the same behaviour for the 
> whole VM. A static Map of Maps could solve this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to