# Can we use machine learning to generate a text output based on the input strings

Problem : Generate a text output based on input strings which will be combined using a number of rules.

Example :

       Feature1               Feature2                    O/P

Rule 1  Enum_Domain           Priority          /Enum_Domain/Priority

Rule 2 Enum_Domain.EnumData   Name              /Enum_Domain/EnumData/Name

Rule 1  Trunkgroup            Gateway            /Trunkgroup/Gateway

Rule 2  GatewayGrp.Gateway    IP                /GatewayGrp/Gateway/IP


This is a simple programming problem, but is there any machine learning algorithm that can learn these rules and generate the output based on the two inputs.

• RNN? Oct 11 '17 at 18:09
• It looks like machine learning would be an overkill since this task can be done using text edition tools like sed. Oct 12 '17 at 7:59
• Yeah.. absolutely. Just want to know how it can be done, Oct 12 '17 at 9:55

The idea in machine learning is that the algorithm to find out patterns or rules which hasn't been defined. Your example fits to experts systems definition.

But, yes you can use machine learning to generate text out put.

This is a magazine article but it fits the bill:

http://www.harrysurden.com/wordpress/archives/248

• This article mentions Random Forests. How can we implement this and get a text output ? Oct 12 '17 at 11:03

As an example, RNN with encoder-decoder archs. are used in these cases. But it does not necessarily take text input. You need to convert your text to numeric, and an embedding layer learns cont. vector representations of the converted text. So yes, several ML models can achieve this particular goal, but I believe none of them processes raw text input. Data always needs to be converted to numeric before fed to any ML model.

The below article explains converting to numeric in the case of Neural Nets. with embedding layer:

https://machinelearningmastery.com/use-word-embedding-layers-deep-learning-keras/#:~:text=The%20Embedding%20layer%20is%20defined,vocabulary%20would%20be%2011%20words