0

I have a ruby gem that calls a Natural Language Processing API to manipulate text. In the gem we process the API response to return the text back in a formatted way. However, there are cases where we want the ability to just pattern match the text passed in to just return a canned response we know is correct.

What is an efficient data matching structure for adding pre-generated responses to my gem that bypasses the API? I envision this file or data structure getting pretty large. I could do a simple ruby hash lookup but this is a bit unwieldy as it gets larger. Ideally the structure is easy for a team member to add, such as a .txt file like:

This is
a sentence.

This is
    a second sentence.

whereby I can send in a string like This is a sentence. and it searches the file to return:

This is
a sentence.

How can I code this efficiently in Ruby?

Kelsey Hannan
  • 2,857
  • 2
  • 30
  • 46
  • what code do you have so far? – Jad May 18 '23 at 10:32
  • Without seeing more of your code and understanding why you're getting denormanized responses, it seems like you just need to normalize your inputs. No one but you knows what those rules should be, though. – Todd A. Jacobs May 19 '23 at 05:41

0 Answers0