Solved

fussy search or match a sentence within a list of sentences

Posted on 2002-04-22
5
347 Views
Last Modified: 2008-01-09
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
Comment
Question by:crest
5 Comments
 
LVL 1

Expert Comment

by:bluprint
ID: 6960685
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
 
LVL 84

Expert Comment

by:ozo
ID: 6960806
use String::Approx 'amatch';
0
 

Author Comment

by:crest
ID: 6961864
ozo, String::Approx looks very promising.  I read the documentation in CPAN.  could you recommend any place for serious example?
0
 
LVL 8

Expert Comment

by:inq123
ID: 9491199
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
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 9537650
PAQed, with points refunded (200)

Netminder
EE Admin
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now