Enum ResourceType

    • Enum Constant Detail

      • LEXICON

        public static final ResourceType LEXICON
        Lexicon Resources (supports in-memory via json files and on-disk)
      • MODEL

        public static final ResourceType MODEL
        Machine Learning Model resources
      • CADUCEUS

        public static final ResourceType CADUCEUS
        Caduceus programs
      • MORPHOLOGY_RULES

        public static final ResourceType MORPHOLOGY_RULES
    • Method Detail

      • values

        public static ResourceType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ResourceType c : ResourceType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ResourceType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • createCache

        public <M> Cache<Language,​M> createCache​(int size,
                                                       @NonNull
                                                       @NonNull String configKey,
                                                       @NonNull
                                                       @NonNull String resourceName)
        Creates a Language-keyed cache for this resource type that loads the resource based on the given configKey and resourceName
        Type Parameters:
        M - the resource type parameter
        Parameters:
        size - the maximum size of the cache
        configKey - the configuration key to use when looking for the location in Config
        resourceName - the resource name
        Returns:
        the cache
      • createCache

        public <M> Cache<Language,​M> createCache​(@NonNull
                                                       @NonNull String configKey,
                                                       @NonNull
                                                       @NonNull String resourceName)
        Creates a Language-keyed cache for this resource type that loads the resource based on the given configKey and resourceName
        Type Parameters:
        M - the resource type parameter
        Parameters:
        configKey - the configuration key to use when looking for the location in Config
        resourceName - the resource name
        Returns:
        the cache
      • getConfigValue

        public Optional<String> getConfigValue​(@NonNull
                                               @NonNull String resourceName,
                                               @NonNull
                                               @NonNull Language language)

        Gets the config value, if any, for the this resource type with the given name and language.

        The method will look for the following configuration keys:

        1. [resourceName].[language].[type]
        2. [resourceName].[language]
        3. [resourceName].[type]
        4. [resourceName]

        Parameters:
        resourceName - the resource name
        language - the language
        Returns:
        the config value
      • load

        public <T> T load​(@NonNull
                          @NonNull String resourceName,
                          @NonNull
                          @NonNull Language language)
        Loads a resource of this type by finding the resource with the given resource name and language. Will throw a runtime exception if the resources is not located or there is a problem loading it.
        Type Parameters:
        T - the type of resource returned
        Parameters:
        resourceName - the resource name
        language - the language version of the resource to load
        Returns:
        the loaded resource
      • load

        public abstract <T> T load​(@NonNull
                                   @NonNull String configKey,
                                   @NonNull
                                   @NonNull String resourceName,
                                   @NonNull
                                   @NonNull Language language)
        Loads a resource of this type by finding the resource with the given configuration key, resource name, and language. Will throw a runtime exception if the resources is not located or there is a problem loading it.
        Type Parameters:
        T - the type of resource returned
        Parameters:
        configKey - the configuration key to use when looking for the location in Config
        resourceName - the resource name
        language - the language version of the resource to load
        Returns:
        the loaded resource
      • locate

        public Optional<Resource> locate​(@NonNull
                                         @NonNull String resourceName,
                                         @NonNull
                                         @NonNull Language language)

        Common method for finding a resource of a given type. {@see ResourceType.findResource(String, String, Language)}** for details. This method uses the name also as the config property

        Parameters:
        resourceName - the resource name
        language - the language of the model
        Returns:
        the resource location or null
      • locate

        public Optional<Resource> locate​(@NonNull
                                         @NonNull String configKey,
                                         @NonNull
                                         @NonNull String resourceName,
                                         @NonNull
                                         @NonNull Language language)

        Common method for finding a resource of a given type

        The method will look in the following locations:

        1. [configKey].[language].[type]
        2. [hermes.resources.dir]/[language]/[type]/[resourceName]
        3. classpath:com/gengoai/hermes/[language]/[type]/[resourceName]
        4. configKey.[language]
        5. configKey
        6. configKey.[type]
        7. [hermes.resources.dir]/default/[type]/[resourceName]
        8. classpath:com/gengoai/hermes/default/[type]/[resourceName]
        where language is the two-letter (lowercased) language code.

        Parameters:
        configKey - the config key to use for locating the model
        resourceName - the resource resourceName
        language - the language of the model
        Returns:
        the resource location or null