Need your HELP:: Shell script to detect paragraph in coordinate-based code.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need your HELP:: Shell script to detect paragraph in coordinate-based code.
# 1  
Old 12-22-2008
Need your HELP:: Shell script to detect paragraph in coordinate-based code.

Hi Friends!!

I have obtained following output from a tool called pdftoxml:

<xml>
<text top="423" left="521" width="333" height="20" font="3">Although the the number of fuzzy rules of a system is </text>
<text top="441" left="500" width="355" height="20" font="3">directly dependant on these parameters. As the number of </text>
<text top="459" left="500" width="355" height="20" font="3">parameters increase, the number of fuzzy rules of the system </text>
<text top="477" left="500" width="125" height="20" font="3">grows exponentially.</text>

<text top="495" left="521" width="333" height="20" font="3">In fuzzy logic systems, there is a direct relationship </text>
<text top="513" left="500" width="355" height="20" font="3">between the number of fuzzy sets of input parameters of </text>
<text top="531" left="500" width="355" height="20" font="3">the system and the size of the fuzzy knowledge base (FKB). </text>
<text top="549" left="500" width="355" height="20" font="3">Kosko (1992) call this the "Curse of Dimensionallity." The </text>
<text top="567" left="500" width="355" height="20" font="3">"curse" in this instance is that there is exponential growth </text>
<text top="585" left="500" width="355" height="20" font="3">in the size of the fuzzy knowledge base (FKB), where <i>k</i> is </text>
<text top="603" left="500" width="355" height="20" font="3">the number of rules in the FKB, <i>m</i> is the number of fuzzy </text>
<text top="621" left="500" width="355" height="20" font="3">sets for each input and <i>n</i> is the number of inputs into the </text>
<text top="639" left="500" width="82" height="20" font="3">fuzzy system.

<text top="657" left="521" width="333" height="20" font="3">As the number of.....</text>
-----
-----
</text>
</xml>

Now, i want to write a script that detects paragraph in above code and enclose it within <P> tags.
Following condition should be used while detecting paragraphs.

"Paragraph starts when left=333 and ends as soon as it finds same value of left (i.e 333) again."

So, the FINAL OUTPUT should be as under:

<P>Although the the number of fuzzy rules of a system is directly dependant on these parameters. As the number of parameters increase, the number of fuzzy rules of the system grows exponentially.</P>

<P>In fuzzy logic systems, there is a direct relationship between the number of fuzzy sets of input parameters of the system and the size of the fuzzy knowledge base (FKB). Kosko (1992) call this the “Curse of Dimensionallity.” The “curse” in this instance is that there is exponential growth in the size of the fuzzy knowledge base (FKB), where k is the number of rules in the FKB, m is the number of fuzzy sets for each input and n is the number of inputs into the fuzzy system.</P>
------
----


Thanks a ton in advance!!!
# 2  
Old 12-22-2008
Hammer & Screwdriver Several commands, chained together...

Code:
> cat file123 | cut -d'"' -f4,11- | sed 's/521">/<\/P>~<P>/' | sed 's/500">//' | sed 's/<\/text>//' | tr -d "\n" | tr "~" "\n" | tail +2 ; echo '</P>'
<P>Although the the number of fuzzy rules of a system is directly dependant on these parameters. As the number of parameters increase, the number of fuzzy rules of the system grows exponentially.</P>
<P>In fuzzy logic systems, there is a direct relationship between the number of fuzzy sets of input parameters of the system and the size of the fuzzy knowledge base (FKB). Kosko (1992) call this the "Curse of Dimensionallity." The "curse" in this instance is that there is exponential growth in the size of the fuzzy knowledge base (FKB), where <i>k</i> is the number of rules in the FKB, <i>m</i> is the number of fuzzy sets for each input and <i>n</i> is the number of inputs into the fuzzy system.</P>

p.s. yes, that initial cat could have been replaced, it is merely the way I proceeded to solve this puzzle by slowly transforming the output. Try the command out piece by piece, and you will see how the data is slowly transformed to the requested output layout.
# 3  
Old 12-23-2008
Brilliant! Thanks Sir.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Detect current shell inside a script

I wish to print my current shell which happens to be bash in my script check.sh more check.sh echo $0 echo `ps -p $$` But instead of printing it prints check.sh i.e the name of the script for both the commands. Can you please suggest how to print the current shell i m on inside the... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

3. Shell Programming and Scripting

Retrieving a paragraph from a pdf file using shell commands

In the reference section of a research paper(in pdf form), many other paper names are cited which have been used inside the pdf at different places. If I give an input, the name of a paper which has been cited in the reference section and want to display the section (the paragraph) inside the pdf... (1 Reply)
Discussion started by: SK33
1 Replies

4. Shell Programming and Scripting

How to detect Hanged process in shell script?

I have to check daily 20 processes each day. The names are like Network1 Network2 Network3 ....... Network20. There is built in utility for doing this. Following is the command to check a single network process. check_process_status 1 If we want to check the status of Network2 then the... (6 Replies)
Discussion started by: Nakul_sh
6 Replies

5. Shell Programming and Scripting

How to detect key press in cgi shell script?

I want to detect key pressed in my .cgi web page, but it does not work even I found the code in other web site. My code is : #!/bin/sh #================================================= # PATH defination # ================================================... (2 Replies)
Discussion started by: Shuinvy
2 Replies

6. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

7. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

8. Shell Programming and Scripting

how to detect ip address based location using PHP

I am interested in finding out if there is a reliable and economical way for extracting user's location based on his ip address, using php I tried to get the job done using ip2location.com, but I am not happy how it deals with result inconsistently. (2 Replies)
Discussion started by: siftin-com
2 Replies

9. Shell Programming and Scripting

script to list out the output in one paragraph

Hi All, I want to run 5 `ps -ef | grep ` cmds in one script and i want the script to give me return code 0 if everything is OK. If it notices one of the processes is not there, it will prompt me the process name and advice me to check it. I've wrote a script that separates the output but I want... (2 Replies)
Discussion started by: fara_aris
2 Replies

10. Shell Programming and Scripting

script for a 3 line paragraph

i would like to ask how to make a script that in evry 3 lines of my paragraph(below) it would appear like this: $ cat myparagraph this is line 1 this is line 2 this is line3 this is line 4 this is 5 this 6 this is 7 this 8 ==================================================== $ cat... (2 Replies)
Discussion started by: invinzin21
2 Replies
Login or Register to Ask a Question