Need a script done as follows:
I need to have a keyword file with random modifiers added, or random words removed from it.
Input, 2 text files:
File A consists of keywords/phrases, one per line.
File B consists of modifiers, one per line.
Output, 1 text file:
A modified version of file A. Every time this script is run, the output should be different.
Files A and B do not necessarily have the same amount of lines. What I would like is to have an output file based on file A with some alterations explained below.
For each line in file A, do ONE of the following, chosen at random:
1. Insert one random word from file B at a random position in the line. Only insert this word at the beginning, at the end, or between two words. DO NOT insert right in the middle of a word.
For example, if the current line is "blue TV widgets" and the random word grabbed from file B is "cheap", then the possible outcomes are:
cheap blue TV widgets
blue cheap TV widgets
blue TV cheap widgets
blue TV widgets cheap
Remember to grab a new random word from file B _for every line_ in file A. That is, don't just pick the random word once and keep using the same one for all the lines in file A. Words from file B that were used previously are okay, they just need to be random.
2. Delete one random word in the current line. Choose this option only if the current line has MORE THAN ONE word.
For example, if the current line is "blue TV widgets", then the possible outcomes are:
Only one of the possible outcomes should be written to output. The output file should have _exactly_ the same number of lines as file A.
See attached files ([url removed, login to view], [url removed, login to view], [url removed, login to view]) for an example run.
See [url removed, login to view] for an explanation of the output.