By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

how to extract the abbreviation from a given text uisng PERL

P: 12
Hi everyone,
I am a newbie in Perl.
I would like to know how to extract the abbreviation from a given text using Perl.

For example,
Dr. Alex is a very smart doctor. He is from USA.

Then my output will be
Dr.
USA

Thank you.
Mar 22 '08 #1
Share this Question
Share on Google+
4 Replies


eWish
Expert 100+
P: 971
Are you looking to capture ALL abbreviations or just certain ones? If you just have a few then you could use a regular expression or ternary operator for this.

Otherwise, I would suggest that you look at CPAN.

--Kevin
Mar 22 '08 #2

P: 12
Are you looking to capture ALL abbreviations or just certain ones? If you just have a few then you could use a regular expression or ternary operator for this.

Otherwise, I would suggest that you look at CPAN.

--Kevin
i want to get all abbreviations....
really thanx a lot...
i will take a look on CPAN
Mar 22 '08 #3

P: 12
Are you looking to capture ALL abbreviations or just certain ones? If you just have a few then you could use a regular expression or ternary operator for this.

Otherwise, I would suggest that you look at CPAN.

--Kevin
Hi,I am back.Really sorry. Even though i already took one day to look for CPAN.
I still cant figure out the solution. Can you help me a bit more?
Mar 23 '08 #4

eWish
Expert 100+
P: 971
What you are wanting to do is really an undertaking. Take this list of abbreviations for example. It would not be a simple task to build an efficient script to search your text file for a word that matched any of the ones on the list. In my opinion this is where a database would be your friend.

On the other hand if you wanted to only look for a few say 30 or so then you could use a hash. Which would be much easier.

Essentially, what you want to do is read the file and split on the whitespace and loop through each for and see if it matches any of the words of your abbreviations list. Have you written any code at this point?

--Kevin
Mar 23 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.