Re: [Catalyst] create search engine friendly uri from string

2009-01-19 Thread Brad Bowman
Robin Berjon wrote: On Dec 15, 2008, at 21:53 , Johannes Plunien wrote: My not very elegant, but working solution: my $str = " Beta Launch Invites: Kwyno Brings The Web Into Your IM And (Soon) SMS Inboxes "; $str =~ s/^\s+|\s+$//g; $str =~ s/\W/ /g; $str =~ s/\s{1,}/ /g; $str =~ s/\s/-/g; $

Re: [Catalyst] create search engine friendly uri from string

2008-12-17 Thread Octavian Rasnita
From: "Oliver Charles" At $work we use Text::Unaccent for this - http://search.cpan.org/~ldachary/Text-Unaccent-1.08/Unaccent.pm Unless I've missed your point, but I hadn't seen it mentioned in this thread so far Yes it is also helpful because it allows to specify the encoding of the source

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Oliver Charles
At $work we use Text::Unaccent for this - http://search.cpan.org/~ldachary/Text-Unaccent-1.08/Unaccent.pm Unless I've missed your point, but I hadn't seen it mentioned in this thread so far On Tue, Dec 16, 2008 at 4:14 PM, Octavian Rasnita wrote: > From: "Peter Karman" >> >> or Search::Tools::T

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Peter Karman
Octavian Rasnita wrote on 12/16/08 1:33 PM: > Just as a feedback, here is a short comparison I've made between these 2 > modules: > > Text::Unidecode is 5 or 6 times faster than S::T::T. > Interesting. I had never compared times since STT was always "fast enough" for my purposes. I just refact

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Octavian Rasnita
From: "Moritz Onken" I want to print ai instead of âî and AI instead of ÂÎ. Am I using $tr->ebit correctly? The latest 4 chars are 4 new UTF-8 chars in romanian language (U +0218, U+0219, U+021A, U+021B). Can they be transliterated? They are şŞţŢ but with a comma below, and not with a sedila.

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Octavian Rasnita
From: "Peter Karman" no. you must set ebit in new(), not after instantiation. I've added a note to the docs to emphasize that. my $tr = Search::Tools::Transliterate->new( ebit => 0 ); Thanks. This way it works fine. The latest 4 chars are 4 new UTF-8 chars in romanian language (U+0218, U+021

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Peter Karman
Octavian Rasnita wrote on 12/16/2008 10:14 AM: > From: "Peter Karman" >> or Search::Tools::Transliterate > > I have tried: > > use strict; > use Search::Tools::Transliterate; > use utf8; > > my $tr = Search::Tools::Transliterate->new; > $tr->ebit(0); > print $tr->convert("ăşţâîĂŞŢÂÎ"); > >

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Moritz Onken
I have tried: use strict; use Search::Tools::Transliterate; use utf8; my $tr = Search::Tools::Transliterate->new; $tr->ebit(0); print $tr->convert("ăşţâîĂŞŢÂÎ"); #It prints: astâîASTÂÎ I want to print ai instead of âî and AI instead of ÂÎ. Am I using $tr->ebit correctly? The lates

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Octavian Rasnita
From: "Peter Karman" or Search::Tools::Transliterate I have tried: use strict; use Search::Tools::Transliterate; use utf8; my $tr = Search::Tools::Transliterate->new; $tr->ebit(0); print $tr->convert("ăşţâîĂŞŢÂÎ"); #It prints: astâîASTÂÎ I want to print ai instead of âî and AI inst

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Peter Karman
Octavian Rasnita wrote on 12/16/2008 06:16 AM: > From: >> Ptyhon can convert an utf8 string to an ascii string and replaces >> characters like "ä" with the most equivalent character "a". Is there such >> a thing for perl? > > Maybe Text::Unidecode could be helpful... > or Search::Tools::Transli

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Octavian Rasnita
From: > Ptyhon can convert an utf8 string to an ascii string and replaces > characters like "ä" with the most equivalent character "a". Is there such > a thing for perl? Maybe Text::Unidecode could be helpful... Octavian ___ List: Catalyst@lists.scsy

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Robin Berjon
On Dec 16, 2008, at 12:20 , > wrote: On Tue, 16 Dec 2008 11:51:28 +0100, Robin Berjon wrote: Before putting that into a module though you might want to think about what should happen to characters outside the [a-z0-9] range as \W will match differently based on locale. I'm not sure what th

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread onken
On Tue, 16 Dec 2008 11:51:28 +0100, Robin Berjon wrote: > > Before putting that into a module though you might want to think about > what should happen to characters outside the [a-z0-9] range as \W will > match differently based on locale. I'm not sure what the recommended > behaviour is

Re: [Catalyst] create search engine friendly uri from string

2008-12-16 Thread Robin Berjon
On Dec 15, 2008, at 21:53 , Johannes Plunien wrote: My not very elegant, but working solution: my $str = " Beta Launch Invites: Kwyno Brings The Web Into Your IM And (Soon) SMS Inboxes "; $str =~ s/^\s+|\s+$//g; $str =~ s/\W/ /g; $str =~ s/\s{1,}/ /g; $str =~ s/\s/-/g; $str = lc($str); pri

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread onken
On Mon, 15 Dec 2008 18:28:03 -0800, Ashley wrote: > Just a caveat that should be in the doc you end up with if not > possible in the code. URIs are supposed to be unique to a resource. > Titles of articles and pages are not (necessarily). The end user/dev > will have to check for duplicate

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Ashley
On Dec 15, 2008, at 1:23 PM, Moritz Onken wrote: Am 15.12.2008 um 21:53 schrieb Johannes Plunien: On 15.12.2008, at 21:22, Jim Spath wrote: You might also want to add these two to the end: =~ s/--+/-/g; =~ s/-$//g; Scott McWhirter wrote: $str =~ s{\W}{}g; $str = lc($str); $str =~ s{\s+}{-

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Chisel Wright
On Mon, Dec 15, 2008 at 02:14:16PM -0800, J. Shirley wrote: > I've been meaning to, for use with DBIx::Class::Tokenize ... but > better to have something like Text::Filter::URI and then a Template > Toolkit Filter that simply uses that underlying module. I agree. I initially wrote Template::Plugin

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread J. Shirley
On Mon, Dec 15, 2008 at 1:23 PM, Moritz Onken wrote: > > Am 15.12.2008 um 21:53 schrieb Johannes Plunien: > >>> On 15.12.2008, at 21:22, Jim Spath wrote: >>> You might also want to add these two to the end: =~ s/--+/-/g; =~ s/-$//g; Scott McWhirter wrote: > >

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Moritz Onken
Am 15.12.2008 um 21:53 schrieb Johannes Plunien: On 15.12.2008, at 21:22, Jim Spath wrote: You might also want to add these two to the end: =~ s/--+/-/g; =~ s/-$//g; Scott McWhirter wrote: $str =~ s{\W}{}g; $str = lc($str); $str =~ s{\s+}{-}g; My not very elegant, but working solution:

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Johannes Plunien
On 15.12.2008, at 21:22, Jim Spath wrote: You might also want to add these two to the end: =~ s/--+/-/g; =~ s/-$//g; Scott McWhirter wrote: $str =~ s{\W}{}g; $str = lc($str); $str =~ s{\s+}{-}g; My not very elegant, but working solution: my $str = " Beta Launch Invites: Kwyno Brings The W

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Jim Spath
You might also want to add these two to the end: =~ s/--+/-/g; =~ s/-$//g; Scott McWhirter wrote: $str =~ s{\W}{}g; $str = lc($str); $str =~ s{\s+}{-}g; -- -Scott McWhirter- | -konobi- On Mon, Dec 15, 2008 at 12:10, Moritz Onken > wrote: Hi, I was wo

[Catalyst] create search engine friendly uri from string

2008-12-15 Thread Moritz Onken
Hi, I was wondering if anyone has a nice regex or module which modifies a string to look good in an url. You know this behaviour from blogs which make urls from the blog title Example: "Beta Launch Invites: Kwyno Brings The Web Into Your IM And (Soon) SMS Inboxes" -> http://www.techcrunch.c

Re: [Catalyst] create search engine friendly uri from string

2008-12-15 Thread Scott McWhirter
$str =~ s{\W}{}g; $str = lc($str); $str =~ s{\s+}{-}g; -- -Scott McWhirter- | -konobi- On Mon, Dec 15, 2008 at 12:10, Moritz Onken wrote: > Hi, > > I was wondering if anyone has a nice regex or module which modifies a > string to look good in an url. > You know this behaviour from blogs which