Solved

Separate Words, and Assign Accession Number

Posted on 2000-02-16
17
157 Views
Last Modified: 2010-03-05
Input:

ACCESSION NUMBER             : 354588
DATE OF OCCURRENCE           : 9612
REPORTED BY                  : FLC; ; ;
PERSONS  FUNCTIONS           : FLC,PIC.CAPT; FLC,FO; TWR,GC;
FLIGHT CONDITIONS            : VMC
REFERENCE FACILITY ID        : MLU
FACILITY STATE               : LA
FACILITY TYPE                : ARPT; TWR;
FACILITY IDENTIFIER          : MLU; MLU;
AIRCRAFT TYPE                : MLG;
ANOMALY DESCRIPTIONS         : RWY TRANSGRESS/OTHER; NON ADHERENCE LEGAL RQMT/CLNC;
ANOMALY DETECTOR             : ATC/CTLR;
ANOMALY RESOLUTION           : CTLR INTERVENED;
ANOMALY CONSEQUENCES         : NONE;
NARRATIVE                    : ACFT WAS PUSHED BACK FROM GATE AT MLU ON TO TXWY G
APPROX 30 YARDS FROM THE INTXN OF TXWY C. GND CTL CLRED US TO TAXI TO RWY 22 ON TXWY
C, HOLD SHORT OF RWY 18. WE ACKNOWLEDGE THE CLRNC. AS WE TURNED ONTO TXWY C I
NOTICED THE RED SIGNAGE AHEAD THAT I THOUGHT DESIGNATES RWY 18. IT WAS OBSERVED BY
THE WINDOW POST DURING THE TURN AND I DID NOT NOTICE THAT IT WAS FOR RWY 14/32. AT
NO TIME DID I RECOGNIZE ANY STANDARD SIGNAGE FOR RWY 18 NOR DID I DETECT A HOLD
LINE. (TXWY MARKINGS ARE FAINT AND DIFFICULT TO SEE AT MLU). THE GND CTLR ISSUE A
'STOP' COMMAND TO US AS WE TAXIED ON TXWY C. THE ACFT WAS BROUGHT TO A STOP AS
QUICKLY AS POSSIBLE. THE FO AND I DIDN'T UNDERSTAND THE REASON FOR HIS XMISSION,
BELIEVING RWY 18 TO BE UP AHEAD. QUICKLY CHKING OUR POS WE REALIZE WE WERE ABOUT TO
CROSS THE RWY 18. CONTRIBUTING FACTORS: TXWY MARKINGS, WORN AND FAINT POSSIBLY
OBSCURING THE HOLD SHORT POS. THE SHORT DISTANCE OF TXWY C FROM TXWY G TO RWY 18. AT
MOST ACR ARPTS OUR HABITUAL ROUTINE IS TO POS THE ACFT ON A TXWY ON WHICH IT FITS,
NOSE TO TAIL. I KEPT FIGHTING ALL DAY TRYING TO RID THE NOTION OF BEING AT BATON
ROUGE WHERE THE HOLD SHORT POS IS THE SAME AS RWY 14/32. CALLBACK CONVERSATION WITH
RPTR REVEALED THE FOLLOWING INFO: THE RPTR RARELY FLIES INTO THIS ARPT. HE MENTALLY
ASSOCIATES THIS FIELD WITH ANOTHER AND AT TIMES, FINDS IT CONFUSING. HE FOUND THE
RWY SIGNAGE GOOD ON A SUBSEQUENT VISIT TO THE FIELD. HE FEELS THE HOLD LINE COULD BE
MORE DEFINITE. IT APPEARED FAINT AND FADED TO HIM IN HIS RECOLLECTION.
SYNOPSIS                     : MD88 HAS A RWY INCURSION AT MONROE, LA.
REFERENCE FACILITY ID        : MLU
FACILITY STATE               : LA
DISTANCE & BEARING FROM REF. : 0
AGL ALTITUDE              


ACCESSION NUMBER             : 355163

DATE OF OCCURRENCE           REPORTED BY                  : FLC; ; ; ; ;

PERSONS  FUNCTIONS           : FLC,FO; FLC,PIC.CAPT; FLC,PLT; TWR,LC; TWR,GC;
FLIGHT CONDITIONS            : VMC
REFERENCE FACILITY ID        : ATL
FACILITY STATE               : GA
FACILITY TYPE                : TWR; ARPT;
FACILITY IDENTIFIER          : ATL; ATL;
AIRCRAFT TYPE                : MLG; ;
ANOMALY DESCRIPTIONS         : RWY TRANSGRESS/OTHER; NON ADHERENCE LEGAL
RQMT/PUBLISHED PROC;
ANOMALY DETECTOR             : ATC/CTLR;
ANOMALY RESOLUTION           : CTLR INTERVENED; CTLR ISSUED NEW CLNC; NOT
RESOLVED/DETECTED AFTER-THE-FACT;
ANOMALY CONSEQUENCES         : NONE;


NARRATIVE                    : ON TKOF RWY 8R, WE RECEIVED TKOF CLRNC FROM TWR CTLR
AND IT APPEARED AN ACFT RECEIVED A CLRNC TO CROSS THE RWY FROM GND CTLR DOWNFIELD.
THE ACFT DOWNFIELD REVERSED COURSE TO CLR THE RWY AT ABOUT THE TIME I NOTICED THE
INCURSION. THE ACFT (LIGHT TWIN) WAS VERY AGGRESSIVE IN PREVENTING THE SIT FROM
DEVELOPING FURTHER. TWR CTLR MISSTATED OUR CALL SIGN WHEN HE NOTICED THE PROB,
ADDING TO CONFUSION OVER WHO WAS CLRED FOR WHAT!
SYNOPSIS                     : A LIGHT TWIN ENG ACFT STARTS TO CROSS AN ACTIVE RWY
WITHOUT CLRNC AS AN ACR IS ROLLING. THE LIGHT TWIN REVERSED COURSE AND CLRED THE
RWY.


Woul like out put

Accession Number           Word in Narrative          Sequence
354588                           ACFT                              1
354588                           WAS                               2
354588                           PUSHED                          3
354588                           BACK                              4
354588                           FROM                             5
              continue on until all words from narrative
                 printed then next accession number
355163                          ON                                  1
355163                          TK                                   2
355163                          OF                                  3
355163                          RWY                               4
355163                          8R                                  5


Any help aprreciated thanks
0
Comment
Question by:tomatocans
17 Comments
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2529229
Put this in a file and chmod it for execution:

#!/usr/bin/perl

$/='ACCESSION NUMBER             : ';
printf("%20s %20s %s\n",
     "Accession Number",
     "Word in Narrative",
     "Sequence");
while(<>){
  my ($an)= /(\d+)/g;
  my @words=/(\w+)/g;
  my $i=0;
  for my $word (@words){
     $i++;
     printf(("%20s %20s %d\n",
       $an,$word,$i);
  }
}


You'll need to pipe the data into this script(e.g. cat /the/files | myscript). Also, change /usr/bin/perl as necessary.

Hope this does it.
Rob
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2529268
Sorry, but the above doesn't work right, after all.  Even after removing the extra ( after printf, the script returns all of the words; not just the NARRATIVE.
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2529275
This one should do it:

#!/usr/bin/perl

$/='ACCESSION NUMBER             : ';
printf("%20s %20s %s\n",
     "Accession Number",
     "Word in Narrative",
     "Sequence");
while(<>){
  my ($an)= /(\d+)/g;
  my @words;
  ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
  @words=/(\w+)(?!\n\w+\s:)/gs;
  my $i=0;
  for my $word (@words){
     $i++;
     printf("%20s %20s %d\n",
       $an,$word,$i);
  }
}
0
 
LVL 84

Expert Comment

by:ozo
ID: 2529314
Why the /g on /(\d+)/?
You may also have wanted (.+?) instead of (.+)
0
 

Author Comment

by:tomatocans
ID: 2529407
If the file name is  one.txt and it is in the directory /home/tmclaugh how would you put in the command line to produce an output file?
0
 

Author Comment

by:tomatocans
ID: 2529456

               #!/usr/bin/perl

                 $/='ACCESSION NUMBER             : ';
                 printf("%20s %20s %s\n",
                      "Accession Number",
                      "Word in Narrative",
                      "Sequence");
                 while(<>){
                   my ($an)= /(\d+)/g;
                   my @words;
                   ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
                   @words=/(\w+)(?!\n\w+\s:)/gs;
                   my $i=0;
                   for my $word (@words){
                      $i++;
                      printf("%20s %20s %d\n",
                        $an,$word,$i);
                   }



will not open file or print to out.
                 }
0
 

Author Comment

by:tomatocans
ID: 2529461
#!/usr/bin/perl

                                  $/='ACCESSION NUMBER             : ';
                                  printf("%20s %20s %s\n",
                                       "Accession Number",
                                       "Word in Narrative",
                                       "Sequence");
                                  while(<>){
                                    my ($an)= /(\d+)/g;
                                    my @words;
                                    ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
                                    @words=/(\w+)(?!\n\w+\s:)/gs;
                                    my $i=0;
                                    for my $word (@words){
                                       $i++;
                                       printf("%20s %20s %d\n",
                                         $an,$word,$i);
                                    }
}

will not open file or print out
0
 

Author Comment

by:tomatocans
ID: 2529464
#!/usr/bin/perl

open(IN,"</home/tmclaugh/list/text.txt") || die "cannot open file>:!";
open(OUT,">/home/tmclaugh/list/zinger1.txt") || die "Cannot open file>:!";

$/='ACCESSION NUMBER             : ';
printf("%20s %20s %s\n",
     "Accession Number",
     "Word in Narrative",
     "Sequence");
while(<IN>){
     my ($an)= /(\d+)/g;
     my @words;
     ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
     @words=/(\w+)(?!\n\w+\s:)/gs;
     my $i=0;
     for my $word (@words){
     $i++;
     printf("%20s %20s %d\n",
     $an,$word,$i);
     }
}
close(IN);
close(OUT);


will not open or print to OUT
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:tomatocans
ID: 2529486
changed to usr/local/bin/perl got output for header to screen nothing else on screen or in output file.

0
 

Author Comment

by:tomatocans
ID: 2529498
Rob I am not getting any output from the new script


Thanks


Tom
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2530008
Sorry, I'm just now getting back to this.  

ozo,  the /g isn't necessary.  Not sure why I put it in there, frankly.  I cranked this out in about 10 minutes, because I had to leave for awhile.

Tom,
In the line:
  @words=/(\w+)(?!\n\w+\s:)/gs;
the (?!\n\w+\s:) is unecessary.

Also, all of the prints need to print to OUT.  So, for example,

printf OUT ("%20s %20s %s\n",

Hope that does it.  Sorry so sloppy.  Leaving again.  I'll check back morrow.

Rob
0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2530267
You also need to delete the 'my'in
   "for my $word (@words){ "
to make the syntax checker happy.

Optionally add the line
   my $word;
near the top of the file to keep everything kosher.


I tested the latest script above plus RobWMartin's latest adjustments (and the 'my' removed), and it works fine.      

(Note: I am not expecting any credit for this.  Rob did all the work.)
0
 

Author Comment

by:tomatocans
ID: 2531653
#!/usr/local/bin/perl -w

open(IN,"</home/tmclaugh/list/list.txt") || die "cannot open file>:$!";
open(OUT,">/home/tmclaugh/list/text.out") || die "cannot open file>:$!";
$/='ACCESSION NUMBER             :';
while(<IN>){
     my ($an)= /(\d+)/g;
     my $word;
     my @words;
     ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
     @words=/(\w+)/gs;
     my $i=0;
     for $word(@words){
     $i++;
     printf OUT("%20s %20s %d\n", $an,$word,$i);
     }
}
close(IN);
close(OUT);


This is how I interpreted the code and I am gettin chunk errors from /NARRATIVE/ line and print OUT line.
0
 

Author Comment

by:tomatocans
ID: 2531759
Adjusted points to 15
0
 
LVL 3

Accepted Solution

by:
RobWMartin earned 10 total points
ID: 2531872
Hope this one will do it:


#!/usr/local/bin/perl -w

open(IN,"</home/tmclaugh/list/list.txt") || die "cannot open file>:$!";
open(OUT,">/home/tmclaugh/list/text.out") || die "cannot open file>:$!";
$/='ACCESSION NUMBER';
<IN>;  # mitigates a perl warning for the first (emptyish) record
while(<IN>){
     my ($an)= /(\d+)/;
     my $word;
     my @words;
     ($_)=/NARRATIVE\s+:(.+?)\n\w+\s+:/gs;
     @words=/(\w+)/gs;
     my $i=0;
     for $word(@words){
     $i++;
     printf OUT +("%20s %20s %d\n", $an,$word,$i);
     }
}
close(IN);
close(OUT);


Key changes were to shorten the input record separator and to ungreedy the narrative finder.

Rob

0
 

Author Comment

by:tomatocans
ID: 2538404
Thanks Rob when I ran it against other files that included a Make_Model Field and another field inbetween the Narrative and Synopsis fields it continued to parse those fields until it reached the Synopsis field. How would u alter the code just parse the narrative field and nothing else.

Thanks
0
 

Author Comment

by:tomatocans
ID: 2538623
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

20 Experts available now in Live!

Get 1:1 Help Now