How do i find a pattern that can define a set of strings? For example if I have these strings
my @single = (
"Hello World my name is Alice",
"Hello World my name is Bob",
"Hello World my name is Charlie"
);
my @multi = (
"That Building is very small",
"That Ladder is very tall"
);
What i currently have tried is to separate the sentences into groups with the exact amount of words. Then build a tree where the nodes are the words, if a node has many branches they will be replaced by a *. But this only works if the * is at the end (@single) but it won't work when the * is not at the end (@multi)
Basically What I want is to output a pattern where the input are an array of strings. How can i generate these patterns below given the strings above?
my $single_pattern = "Hello World my name is *"
my $multi_pattern = "That * is very *"
"is"? Do you mean find the subject of the sentence? Do you mean find the last noun in the sentence? Do you mean find the first word that is different from all the others in the sentence? In any event, this sounds like a natural language processing task. Please clarify what you're trying to accomplish, exactly. Thanks.