|
-
Dec 5th, 2003, 01:40 PM
#1
Thread Starter
Member
paragraph and sentence count
how would I count the number of paragraphs and sentences of a text file in a text box?
-
Dec 5th, 2003, 04:49 PM
#2
Frenzied Member
What do you mean by a sentence?! If you mean anything that is ended by a '.' , '!' or '?' and combinations like "?!!!" is a sentence then you might apply a method to count them and thats easy. And for paragraphs, again you have to define it. if you define a paragraph where "Enter' is pressed and you go to another line you may get the line numbers of the text file, that is ReadLine of streamreader till you are at the end of file, or count the number of Linefeed/Carriage Return characters.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Dec 5th, 2003, 06:04 PM
#3
Thread Starter
Member
sentence and paragraph
I want to count sentences ending with a period, question mark, or exclamation mark. And for paragraphs I guess I would count every enter or double enter as a paragraph. Im not really sure how to count the paragraphs. I dont know what the code should look like.
-
Dec 6th, 2003, 06:30 AM
#4
Frenzied Member
You may use RegEx to count them.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Dec 10th, 2003, 04:32 PM
#5
Thread Starter
Member
regex
I was going to use the regex method. But my reacher told me it was to high a level of a function. I almost have my paragraph count working the only fault in it is that if i have 3 paragraphs in the textbox it only counts 2 should I automatically add 1 to the paragraph variable at the end or should I add some other line of code here is what I have so far. I am counting 2 carriage returns as a paragraph.
Dim sr As IO.StreamReader = IO.File.OpenText(filename)
Dim theline As String
TextBox2.Clear()
TextBox2.Multiline = True
Do While sr.Peek <> -1
theline = sr.ReadLine
If theline.Length = 0 Then
paragraph = paragraph + 1
End If
TextBox2.Text = TextBox2.Text + theline + vbCrLf
Loop
sr.Close()
TextBox1.Text = filename
End Sub
-
Dec 10th, 2003, 04:33 PM
#6
Thread Starter
Member
forgot
I forgot to tell you that I am counting the paragraphs as they are put into the textbox with the streamreader.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|