in reply to Re: Splitting compound (concatenated) words )
in thread Splitting compound (concatenated) words )
can match from the beginning to the end for$s =~ /^$re2$/;
andmy $s = 'couldsomeonerecommendaworkingperlmoduletosplitconcatenatedwor +ds';
## $re2 = (recommend|someone|working|module|words|split|comme|could|.. +.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Splitting compound (concatenated) words )
by BrowserUk (Patriarch) on May 16, 2012 at 22:50 UTC | |
I do not understand how $s =~ /^$re2$/; can match from the beginning to the end for my $s = 'couldsomeonerecommendaworkingperlmoduletosplitconcatenatedwords'; and ## $re2 = (recommend|someone|working|module|words|split|comme|could|... If that's what $re2 looks like, then you are not running the code I posted! It should look like:
The way the code:
Works is:
The results will rarely be perfect, but it depending upon the source of your strings, it might form the basis for further, perhaps statistical, analysis. I'm curious as hell about the source of the data and the purpose of the exercise? With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by vit (Friar) on May 16, 2012 at 23:39 UTC | |
Thanks for your explanation. I will spend some time to understand this part in details. Looks like genius. In terms of both, Perl flexibility and your implementation. Actually it needs to print line-wise. I'm curious as hell about the source of the data and the purpose of the exercise? The dictionary is the side affect of phrases I retrieved from crawling for my applications. The purpose of the exercise is the following. I created a keyword generator which is a web application. From the logs I found that some people merge words in a seed phrase and my resulted keywords filter fails to establish similarity in these cases. So I need to split. But usually it is only a two reasonable words split so that looks like your algorithm with my dictionary works well. I can send you a link to the tool, but I am not sure it's a right way to do it through the forum. | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on May 17, 2012 at 00:24 UTC | |
I will spend some time to understand this part print for grep defined(), $s =~ /^$re2$/; Maybe this will help:
Note: I've increase the number of repetitions from 11 to 20 to allow for sentences with more words. The side effect of that is that the unmatched captures now return undef, so If I just printed out @found, I get this:
So I use grep to remove any undefined values:
Actually it needs print "$_\n" for grep defined(), $s =~ /^$re2$/; to print line-wise. If you look at the first line of the code I posted: #! perl -slw, the l in the -slw has the affect of adding "\n" to print statements automatically. Saves me having to type them all the time. I can send you a link to the tool, but I am not sure it's a right way to do it through the forum. Just post the link as text, or wrap it in brackets: [ link here ] to make it an active link. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by vit (Friar) on May 17, 2012 at 14:34 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 14:52 UTC | |