Hi all,
I want to check out whether a line contains predefined keywords or not. The presence of a keyword is marked by 1, the non-presence by 0. I give you an example:
I'm eating pizza with salami.
Pizza is Italian food.
Pizza with salami is good food.
For this example I need a script that searches for the keywords (in this order!) 'pizza', 'salami' and 'food'. On the first line AWK will find the first two keywords. Keyword 'food', however, is not present in this context. Therefore, the output should be '1 1 0'. For the second line, it should be '1 0 1' and for the last line it should be '1 1 1' ('cause all three keywords are present!).
The values that AWK returns, should be saved to another file. This file (e.g. keywords.txt) should eventually look like this:
1 1 0
1 0 1
1 1 1
I hope someone can help me with this! Thanks.
I want to check out whether a line contains predefined keywords or not. The presence of a keyword is marked by 1, the non-presence by 0. I give you an example:
I'm eating pizza with salami.
Pizza is Italian food.
Pizza with salami is good food.
For this example I need a script that searches for the keywords (in this order!) 'pizza', 'salami' and 'food'. On the first line AWK will find the first two keywords. Keyword 'food', however, is not present in this context. Therefore, the output should be '1 1 0'. For the second line, it should be '1 0 1' and for the last line it should be '1 1 1' ('cause all three keywords are present!).
The values that AWK returns, should be saved to another file. This file (e.g. keywords.txt) should eventually look like this:
1 1 0
1 0 1
1 1 1
I hope someone can help me with this! Thanks.