atilika / kuromoji

Kuromoji is a self-contained and very easy to use Japanese morphological analyzer designed for search
Apache License 2.0
950 stars 131 forks source link

Builder method to configure custom ResourceResolver #124

Open logogin opened 6 years ago

logogin commented 6 years ago

This small change adds ability to set custom ResourceResolver via Builder. Custom resolver will allow loading dictionaries from locations other than Java classpath.

logogin commented 6 years ago

Any chance to get this merged?

cmoen commented 6 years ago

Could you elaborate a bit on the use-case of when you'd load custom dictionaries from locations other than the Java classpath? Just trying to understand the underlying use-case. Thanks.

logogin commented 6 years ago

Thanks for the response! The are couple of use-cases:

  1. You need to update/recompile dictionaries without code change. In this case dictionaries may be stored separately from the library.
  2. Dictionary/model files may have licence different from one used for the source code. There could be internal policies which may prohibit to deploy software with mixed or special types of licences.
  3. You have a special central model storage, i.e. S3 where all models maintained.

It is also, in general, a very trivial change which is backwards-compatible and does not affect library API. The ResourceResolver interface is already there, it is just hardcoded to resolve always from classpath.