Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-01-2005, 03:32 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
Talking paragraph it!

have you ever come across a very very long post where the author didn't press enter once? it is just one huge block off code? i was reading a huge post over at another forum today and a few people refused to read it. i thought about it a little and came up with a solution. i wrote a script that parses the text and creates line breaks so it is readable. it is pretty simple but it was fun none the less. it basically takes a string into a character array. then it looks for periods. when it finds a period, it increases a variable to determine when the next paragraph should start. at first i had it starting a new paragraph after every other period, but then i was talking with a co-worker and we thought that it would probably feel more human if it varied. i then just used the ternary operator to alternate the max number of periods in the paragraph. for now it only alters between 2 and 3, but i'm sure a more robust version could be made. i then decided that maybe it would look nice if each sentence was capitolized, so i set the first character after each period to upper case. once it was all said and done and i had posted it on the forum that the inspirational block post came from, i started writing this block of text here. as i wrote the first couple sentences i noticed that i had not thought about other end-of-sentence punctuation such as the quesiton marks in my first couple sentences. i then modified the script to handle those. hopefully you haven't read this whole thing without paragraphing it, so here is the link if you want a more comfortable read pAraGRaPh-iT
__________________
Mike
sde is offline   Reply With Quote
Old 02-01-2005, 04:21 PM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
Heaven help it should it ever have to interpret a post of mine . . .

Now, for version 2, you think it could correct capitalization?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-01-2005, 04:31 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
hehe, oh no. i don't think i'll be spending much more time on this one.
__________________
Mike
sde is offline   Reply With Quote
Old 02-01-2005, 05:46 PM   #4 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
That's funny...and it brings back old memories. I wrote a Perl script once upon a time to extract DDL from an Oracle export file. It would also change the storage parameters (i.e. extent size, tablespace name, etc.), but that's beside the point. Well, the first snag I hit using this thing was that Oracle stores the DDL (SQL for creating the object) as a single line. Tables with lots of columns and/or lots of long column names would occasionally produce a string that was too long for SQL*Plus to process.

So, I modified the script to create lines that were a maximum of 10 words long. Nothing fancy; no punctuation to worry about. I still dig the script out and tweak it every couple of years.
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote
Old 02-01-2005, 06:02 PM   #5 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
I like it!
__________________
while(1) fork();
ender is offline   Reply With Quote
Old 02-01-2005, 06:54 PM   #6 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
I think I need this for work when people email a crappy paragraph glob and need help.
idx is offline   Reply With Quote
Old 02-02-2005, 07:21 AM   #7 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
everyforumneedsthistypeofthing.ireallyhatewhenpeop ledontuseparagraphs!italsosuckswhentheydonthitthes pacebarwhentheyaretypingabunchofstuffaboutyourorig inalpost.hehe.thisisthelongestsinglelineintheoworl d.bye.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 02-02-2005, 07:26 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
uh .. i think i need to write sPaCE iT now
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 10:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting