Lookup tables configuration problem

Hi! According to this post, you’d need to present your lookup format in a .yml format, so it would have to look something like this:

fruits.yml:

version: "2.0"
nlu:
  - lookup: language
    examples: |
      - english
      - telugu
      - hindi

You would then need to put this file in the nlu folder. Additionally, you would need to add either RegexEntityExtractor or FlashTextEntityExtractor (which works with lookups only) in your config pipeline.

I’m not sure if there is a way for rasa to work with pure .txt files, but I do have a Python script which converts a .txt file (or any plaintext file) into a .yml file with the appropriate format, which you can modify based on your needs. Here it is if anyone is interested:

# Insert normal .txt/.csv path here
file = open(r"C:\Users\User\Desktop\Cities in the World.csv", "r")

# Splits each row
lines = file.read().splitlines()
n = 0

# Insert target output path here
file2 = open(r"C:\Users\User\Desktop\cities.yml", "w")

# Writes the headers(?), remember to change the lookup name
file2.write("version: \"2.0\"\nnlu:\n  - lookup: city  \n    examples: |\n")

# Adds indent and dash to each line
for line in lines:
    file2.write("      - " + str(line) + "\n")

# Closes the files
file.close()
file2.close()

I hope this helps!

3 Likes