My question is about StringCases
. When I use this function, each word is separated by a ,
. But I want some noun phrases like names of a ministry to be considered single words.
For example, I would like to count the number of words in the next two sentences.
text= "The Ministry of Infrastructure and Environment is
committed to improving quality of life,access and mobility in a
clean,safe and sustainable environment.The Ministry strives to create
an efficient network of roads,railways,waterways and
airways,effective water management to protect against flooding,and
improved air and water quality"
StringCases[text, WordCharacter ..]
The result of this function is:
{"The", "Ministry", "of", "Infrastructure", "and", "Environment",
"is", "committed", "to", "improving", "quality", "of", "life",
"access", "and", "mobility", "in", "a", "clean", "safe", "and",
"sustainable", "environment", "The", "Ministry", "strives", "to",
"create", "an", "efficient", "network", "of", "roads", "railways",
"waterways", "and", "airways", "effective", "water", "management",
"to", "protect", "against", "flooding", "and", "improved", "air",
"and", "water", "quality"}
Each word is separated by a ','. When I count the number of words I get 50, but there are four noun phrases I want to be considered single words:
"Ministry of Infrastructure and Environment"
"quality of life"
"network of roads"
"water management"
So the word count I would like to get is 41. I can create a reference table with all possible combinations of words. Is there a solution for this problem?