Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-05-2004, 06:20 AM Grab and Abbreviate
Novice Talker

Posts: 11
Trades: 0
Hi all.
some help on this would be greatly appreciated....

ok, i have file, the content of which is more or less like below..


IDN25900
TOP PRIORITY FOR IMMEDIATE BROADCAST
SYDNEY SEVERE THUNDERSTORM WARNING
BUREAU OF METEOROLOGY
NEW SOUTH WALES REGIONAL OFFICE Issued at 1703 on Saturday the 1st of
September 2001
This warning affects people in the following Local Government Area:

Wyong

This warning is current from 5:05pm until 6pm.

Storms are currently located to northwest of Wyong and are moving towards
the southeast. Locations that may be affected in the next hour include the
Wyong and The Entrance

Large hailstones, damaging winds and very heavy rainfall are possible.

The STATE EMERGENCY SERVICE advises that as storms approach people should:
* put vehicles under cover
* move indoors away from windows

During and after the storm people should:
* beware of fallen trees and power lines
* keep away from creeks and drains as you may be swept away

The RTA recommends motorists switch their lights & wipers on & slow down in
the wet.

If your house is damaged contact the State Emergency Service on 132 500 for
emergency assistance. Do not use the telephone during the storm.

TV CRAWL: Severe Thunderstorm Warning current for the Wyong Local
Government Area

MEDIA PLEASE NOTE: This warning will be updated within the next hour. The
Bureau and SES would appreciate it being broadcast regularly during this
period.


Now, i need to abbreviate that to 160 characters, and my current script that does it, is "clunky". It grabs the whole file, and abbreviates/deletes words etc etc.

I figure the has to be a better way, and such though it would be easier to say, parse the file for ceratin keywords, such as

"SYDNEY SEVERE THUNDERSTORM WARNING","Issued at 1703" ,"Saturday the 1st of September 2001", "Local Government Area: Wyong
"
etc etc, and these keywords would be the basis of the abbreviation. and out put would look something like

NSW 1703 1/09/ Svr TS Warning for Wyong

How can i achieve this quickly and effeciently, presently the code i do have, doesn't do a great job, and is growing by the day...


SiMmAh

Last edited by |-SiM-|; 08-05-2004 at 07:08 AM.. Reason: removed 2nd Q
|-SiM-| is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-05-2004, 09:34 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
I would read in the entire contents of the file into a string. Then use the substr() function to find the keyword segments that you are looking for.

If the format of the file is always the same, then you could base your parsing on line position. For example, the example you gave put the most relevant information on lines 3 and 5. If that format holds constant, you could read in those lines and create your "headline" abbreviation.

As for shortening the length, you can check the string length.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to Help with 2 things.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30157 seconds with 12 queries