Inflection
Morphology Inflection
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
inflection::resources::DataRegistrationService Class Referencefinal

Provides registration capabilities for registering data for Inflection to utilize. More...

#include <DataRegistrationService.hpp>

Static Public Member Functions

static void registerDataPathForLocale (const inflection::util::ULocale &locale, const std::string &path)
 
static std::string getDataPathForLocale (const inflection::util::ULocale &locale)
 

Detailed Description

Provides registration capabilities for registering data for Inflection to utilize.

This class is used by Inflection to add paths for varying locale's data. It should be used to specify where data exists whenever necessary, for example when using Inflection on client devices (with downloaded data), or when testing with custom data.

Definition at line 17 of file DataRegistrationService.hpp.

Member Function Documentation

◆ getDataPathForLocale()

static std::string inflection::resources::DataRegistrationService::getDataPathForLocale ( const inflection::util::ULocale locale)
static

Returns the filesystem path that was previously registered for a given locale.

Parameters
localeThe locale.
Returns
The path exactly as previously registered.

◆ registerDataPathForLocale()

static void inflection::resources::DataRegistrationService::registerDataPathForLocale ( const inflection::util::ULocale locale,
const std::string &  path 
)
static

Register a path on the filesystem for Inflection to use as the backing data for a given locale. Once the path has been set, it can not be changed to any other path. If you must reload the data, you must restart the process using Inflection and set the new path. Inflection is not able to change the path of its caches for several reasons:

  1. Inflection is only tested with the version of the data that matches the version of the code. We make no guarantees that older or newer versions of the data will work with Inflection.
  2. Changing the data can change the tokenization, lemmatization and inflection behavior. So you will have to reindex anything using the old version of Inflection's data anyway.
  3. Changing the data in the caches is not thread safe while maintaining performance.
  4. It's hard to guarantee that all frameworks in your process using Inflection either directly or indirectly can adapt to the new behavior after changing the data. It's really hard to continuously ensure that all dependencies can use both the older and newer behavior in the same release. Frequently, a machine learned model is trained with a specific version of the data and code of Inflection. So if you get an untested combination of versions of dependencies, you will get undefined behavior ranging between unexpected results to a crash.
Parameters
localeThe locale to register the data for.
pathThe path on the filesystem (relative or absolute).
Exceptions
IllegalArgumentExceptionThrown when changing the path for a locale after it has already been set. This exception is not thrown if the path is already the current value or when the path is set for the first time.

The documentation for this class was generated from the following file: