Closed cahuja1992 closed 5 years ago
Hi @cahuja1992, Using custom resources is possible but not well documented yet, it will be improved and documented in the coming months.
In the meantime, here is the process that you can follow to use your own resources in english:
.tar.gz
archive) on this page (https://github.com/snipsco/snips-nlu-language-resources/releases)snips_nlu_en
) to your own custom resource name (for instance snips_nlu_custom_en
) in the following places:
"name"
attribute in the metadata.json
file"word_clusters"
list attribute of the metadata file. This should be the filename without the extension..txt
) in the word_clusters
directorypip install <path/to/resources_dir>
, pointing to the resources directory that you customizedsnips-nlu link <custom_resource_name> en --force
. This will make the default english resources point to your customized versionAt this point, your custom english resources are setup and you can reference your new word clusters in the nlu engine configuration (cf https://snips-nlu.readthedocs.io/en/latest/tutorial.html#the-snips-nlu-engine)
I hope this helps, Cheers
Another way to use custom resources consists in manually loading resources, updating them, and then pass the customized resources to SnipsNLUEngine()
:
from snips_nlu import SnipsNLUEngine
from snips_nlu.resources import load_resources
from snips_nlu.default_configs.config_en import CONFIG
resources = load_resources("en")
custom_clusters_name = "my_custom_clusters"
resources["metadata"]["word_clusters"].append(custom_clusters_name)
resources["word_clusters"][custom_clusters_name] = {
"hello": "word_cluster1",
"world": "word_cluster2"
}
config = CONFIG
# ... Update the config to leverage the new word clusters
engine = SnipsNLUEngine(config=config, resources=resources)
Thanks, it works.
Brown clusters are shipped as a part of resources. How can we use custom cluster