• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

fussy search or match a sentence within a list of sentences

i've got a bunch of mp3 files, say 100, in a directory and there is a directory with around 40000 lyrics.  so here is my question.  i want to get a copy of all the lyrics files corresponding to the mp3 dir.

/home/mydir/mp3: ls > mp3.list
/home/mydir/lyrics: ls > lyrics.list

in either case, the naming is as following:
artist - songtitle.mp3       for song
or
artist - songtitle.txt       for lyrics

i've written a perl program to match and extract the filename from the lyrics.list.

the only problem, not all lyrics are matched due to small different in the naming convention.  such as "aren't" and "arent" and other sutle differences.

is there any way i can get around this and at use a more fussy logic to do the matching.

any help will be appreciated.
0
crest
Asked:
crest
1 Solution
 
bluprintCommented:
Well, you could remove all single quotes from both lines before matching.

$song_name =~ s/'//g;
$lyric_name =~ s/'//g;

Also, you could do this with other things that you see giving you problems....maybe, for example, replace any multiple spaces (or any other whitespace) with a single space.

$song_name =~ s/\s+/ /g;
$lyric_name =~ s/\s+/ /g;

I guess this doesn't exactly change your search, but instead standardizes what you are searching through.
0
 
ozoCommented:
use String::Approx 'amatch';
0
 
crestAuthor Commented:
ozo, String::Approx looks very promising.  I read the documentation in CPAN.  could you recommend any place for serious example?
0
 
inq123Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund (the participating Experts have abandoned the question)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

inq123
EE Cleanup Volunteer
0
 
NetminderCommented:
PAQed, with points refunded (200)

Netminder
EE Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now