How to filter sentences??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to filter sentences??
# 1  
Old 02-06-2009
How to filter sentences??

Hi,

I have few sentences here.

Code:
$a1="Division of Hematology-Oncology, and Stem cell transplantation, Schneider Childrens Hospital, Albert Einstein College of Medicine, New Hyde Park, New York. ";


$a2="Department of Cell Biology and Anatomy, College of Medicine, National Cheng Kung University, #1 University Road, Tainan, 701, Taiwan, Republic of China. bumiin@mail.ncku.edu.tw";

$a3="Department of Cell Biology and Cancer Center, University of Massachusetts Medical School, Worcester, Massachusetts.";

$a4="erl was introduced in 1987 (4 years before Linux itself), when the author, Larry Wall, released version 1.000 of it. The reason for its creation was that Wall was unhappy by the functionality that sed, C, awk and the Bourne Shell offered him. He looked for a language that will combine all of their best features, while having as few disadvantages of its own.
Since then, perl has seen several versions, each adding additional functionality. perl version 5, which was released in 1994, was a complete re-write of the perl interpreter, and introduced such things as hard references, modules, objects and lexical scoping. Several minor versions of perl appeared since then, and the most up-to-date stable version (as of October 2005) is 5.8.x. ";

$a5="From the Department of Immunology, Allergology and Immunotoxicology,* Fraunhofer Institute of Toxicology and Experimental Medicine, Hannover, Germany; the Shemyakin and Ovchinnikov Institute of Bioorganic Chemistry, Moscow, Russia; the Institute for Anatomy and Cell Biology and University of Giessen Lung Centre, Justus Liebig University, Giessen, Germany; and the Department of Functional and Applied Anatomy, Medical School of Hannover, Hannover, Germany";

$a6="1Department of Neurosurgery, Sungkyunkwan University School of Medicine, Seoul, Korea [2] 2Cancer Stem Cell Research Center, Samsung Medical Center and Samsung Biomedical Research Institute, Sungkyunkwan University School of Medicine, Seoul, Korea.";

$a7="Probably the major killing factor was that compiler for PL/1 was too complex for many organizations to reimplement (it is probably close to similar to C++ compilers in complexity). No free compiler existed although Cornell University managed to implemented PL/C -- a pretty full teaching subset of PL/1 and successfully use it for a number of years.";

$a8="Centre for Infectious Disease, Institute of Cell and Molecular Science, Barts and the London, Queen Marys School of Medicine and Dentistry, London E12AT, UK; First Department of Medicine, Fondazione IRCCS Policlinico S. Matteo, Centro per lo Studio e la Cura della Malattia Celiaca, University of Pavia, Pavia 27100, Italy.";

$a9="Department of Physiology and Pathophysiology, School of Basic Medical Sciences, Peking University, Beijing, Peoples Republic of China; Key Laboratory of Molecular Cardiovascular Science, Ministry of Education, Beijing, Peoples Republic of China; Department of Cardiology, China-Japan Friendship Hospital, Beijing, Peoples Republic of China; Department of Orthopaedic Surgery and Department of Cell Biology, New York University School of Medicine; and Cardiovascular Division, The James Black Centre, Kings College London, United Kingdom";

$a10="Brazilian Germ Cell Tumour Study Group of the Sociedade Brasileira de Oncologia Pediatrica, Centro de Tratamento e Pesquisa Hospital do Cancer; Instituto de Oncologia Pediatrica, Universidade Federal de Sao Paulo; Hospital Santa Marcelina; Hospital do Servidor Publico Estadual; and Instituto da Crianca, Universidade de Sao Paulo, Sao Paulo; Grupo de Pediatria Oncologica, Sao Jose dos Campos; Centro Infantil Boldrini, Campinas; Hospital de Base do Distrito Federal, Brasilia; and Clinica Onco, Salvador, Brazil; Departement of Oncology, St Jude Childrens Research Hospital, Memphis, TN; and Clinic of Pediatrics, Dortmund, Germany.";

$a11="Perl is a high-level, dynamic, general purpose and interpreted programming language that was originally develop, in 1987, by Larry Wall who; a linguist working at NASA. According to the developer; Larry Wall, Perl has got two important slogans";

I want to retrieve the complete sentences.

I tried with taking length of each string!!!!

Code:
$len1=length($a1);
$len2=length($a2);
$len3=length($a3);
$len4=length($a4);
$len5=length($a5);
$len6=length($a6);
$len7=length($a7);
$len8=length($a8);
$len9=length($a9);
$len10=length($a10);

#I tried like this

if($len1>300 || $len2>300 || $len3>300 || $len4>300 ) so on
{
   print "<br> $a1 $a2 $a3 so on <br>";

}

But problem here is it is not picking the right sentence and i am unable to decide based on the length. If i do length > 300 or length > 500 some of the sentences might be missed.

I want the output like this:

OUTPUT:

Code:
"erl was introduced in 1987 (4 years before Linux itself), when the author, Larry Wall, released version 1.000 of it. The reason for its creation was that Wall was unhappy by the functionality that sed, C, awk and the Bourne Shell offered him. He looked for a language that will combine all of their best features, while having as few disadvantages of its own.
Since then, perl has seen several versions, each adding additional functionality. perl version 5, which was released in 1994, was a complete re-write of the perl interpreter, and introduced such things as hard references, modules, objects and lexical scoping. Several minor versions of perl appeared since then, and the most up-to-date stable version (as of October 2005) is 5.8.x. ";

"Probably the major killing factor was that compiler for PL/1 was too complex for many organizations to reimplement (it is probably close to similar to C++ compilers in complexity). No free compiler existed although Cornell University managed to implemented PL/C -- a pretty full teaching subset of PL/1 and successfully use it for a number of years.";

"Perl is a high-level, dynamic, general purpose and interpreted programming language that was originally develop, in 1987, by Larry Wall who; a linguist working at NASA. According to the developer; Larry Wall, Perl has got two important slogans";

I just want to filter out the departments, centers and all and i want the above output!!

How can i get the complete sentences???

How to solve this problem?

Any suggestions!!!

Regards
Vanitha
# 2  
Old 02-09-2009
Why not just use vi to edit this information.

why does this need to be programmically?? Seems very odd.

Also, it is bad practice to set all these sentences equal to variables of different names.

Better to put them all in an array, or a file.

Perhaps you could start with a description of the original problem.
# 3  
Old 02-09-2009
Question Try again explaining what you are trying to accomplish...

You are storing ten sentences into variables. You then store ten more varaiables as the length of each original variable.
Then if ANY - you have OR logic - are more than 300 characters, you print out lines.

But then what do you mean by:
Quote:
I just want to filter out the departments, centers and all and i want the above output!!
How can i get the complete sentences???
# 4  
Old 02-10-2009
Filtering the sentences

hi vanitham,

I have tried the below program with kornshell script. It was working fine..
Kindly check it.

#!/bin/ksh
IFS=""
<your declaration of sentences>
#set -A num 0 1 2 3 4 5 6 7 8 9
set -A alist $a0 $a1 $a2 $a3 $a4 $a5 $a6 $a7 $a8 $a9 $a10
for i in 0 1 2 3 4 5 6 7 8 9 10
do
if [[ ${#alist[$i]} -gt 300 ]]; then
echo "a[$i] = ${alist[$i]}\n"
fi
done
exit 0
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use $variable in conditional sentences?

Hello all I am doing a Makefile but I can't return the value of $var to use it in conditional sentences: #!/bin/sh GO=$(shell) go GOPATH=$(GO) env GOPATH make: @$(GOPATH) @if ; then mkdir -p "$(GOPATH)/bin" ; fi When I type "make", @$GOPATH returns /home/icvallejo/go... (5 Replies)
Discussion started by: icvallejo
5 Replies

2. Shell Programming and Scripting

Extract all the sentences that matched two patterns

Hi I have two lists of patterns named A and B consisting of around 200 entries in each and I want to extract all the sentences from a big text file which match atleast one pattern from both A and B. For example, pattern list A consists of : ama ani ahum mari ... ... and pattern... (1 Reply)
Discussion started by: my_Perl
1 Replies

3. Shell Programming and Scripting

Using awk to find sentences.

I am trying to print out sentences that meets a regular expression in awk (I’m open to using other tools, too). I got the regular expression I want to use, "(\+ \{4\})" from user ripat in a grep forum. Unfortunately with grep I couldn't print only the sentence. While searching for awk... (8 Replies)
Discussion started by: danbroz
8 Replies

4. Shell Programming and Scripting

extracting sentences that only contain a word

Hi guys Need your help how do I extract sentences with only a word i.e. today is hot hot very humid humid2 Sample output hot (6 Replies)
Discussion started by: jamestan
6 Replies

5. UNIX for Dummies Questions & Answers

extracting sentences that only contain a word

Hi guys Need your help how do I extract sentences with only a word i.e. today is hot hot very humid humid2 Sample output hot very (0 Replies)
Discussion started by: jamestan
0 Replies

6. Programming

compile a program in C with teradata sentences using cc

hi, I want to compile a program in C. It have a multiple calls to teradata. I have no idea how to compile in Aix. The compiler that I should be use is cc. I tried cc -G -KPIC tdsfbd0358.c this generates a tdsfbd0358.i and after I have no Idea what I have to make, a link? how?... (3 Replies)
Discussion started by: kajum
3 Replies

7. Shell Programming and Scripting

comparing sentences

Hi, I have a file and that file contains the following sentences. Here we show that a virus-encoded transcription factor, viral mRNA, cellular RNA-binding protein heterodimer G3BP/Caprin-1 (p137), translation initiation factors eIF4E and eIF4G, and ribosomal proteins are concentrated in the... (4 Replies)
Discussion started by: vanitham
4 Replies

8. Shell Programming and Scripting

How to get exact match sentences?

Hi, I have sentences like this: $sent= Protein modeling studies reveal that the RG-rich region is part of a three to four strand antiparallel beta-sheet, which in other RNA binding protein functions as a platform for nucleic acid interactions. Heterogeneous nuclear ribonucleoparticle... (19 Replies)
Discussion started by: vanitham
19 Replies

9. Shell Programming and Scripting

How to identify sentences from a text?

Hi, I have to identify sentences from this text. If i split these statements by this way: @sentence= split(/\.\W*/,$text); I will get these following things also in the output along with proper sentences. Biol Reprod. 2002 Mar;66(3):785-95. Egydio de Carvalho C, Tanaka H,... (2 Replies)
Discussion started by: vanitham
2 Replies

10. UNIX for Dummies Questions & Answers

spliting up sentences

hello, i'm looking to split up text into a list of words but can't figure it out, any help would be great. thanks steven (2 Replies)
Discussion started by: stevox
2 Replies
Login or Register to Ask a Question