|
|
#1 |
|
New Member
Join Date: May 07
Posts: 2
![]() |
[2005] Parsing a textfile by Delimiters of Capital Words.
Hey Guys,
I was hoping someone could help me solve a problem I'm having using vb2005 to parse a text file. I'm trying to parse the text file by Sentences that start with Words that are all Captial. Such as, IVORY is a type of Plant. The idea is parse a sentence at a time that starts with a Word in Full CAPs and place it in a collection. Such as "IVORY IS A PLANT" would be item 1 in collection "SOMEBODY help me" would be item 2 in the collection. the way the text file is its one solid block of sentences, with random carriage returns. So I need the program to parse based off setences that start with word in full caps and ends before The next word with full caps. Since the document does not contain periods just commas that are using to complient the sentence not end it. I've managed to write code that would place delimited values into collections using comma as the limiter. So that I could get the rest of the logic complete. I've tried using the built in commands to do this, however they seemt o only take fixed characters rather then muitiple ones. Is there a way to check each word, and they when its found place the sentence in. example: myreader.textfieldtype= fileio.fieldtype.delimited myreader.setdelimiters( string like [A-Z]) Any help you guys could offer would be great. Thx The Code I'm using is. using myreader as new microsoft.visualbasic.fileio.textfieldparser(".\star.txt") myreader.textfieldtype = fileio.feildtype.delimited myreader.setdelimiters(" ") dim currentrow as string() while not myreader.endofdata try current row=myreader.readfields() dim currentfield as string for each current field in currentrow a=a+1 b.add(currentfield, a.tostring) next end try end using An example of the text file is. DOBERMAN A BIG handsome boy! 1 year, trained & clean, loves kids! Reg’d, intact ENGLISH Bulldog pups for sale home-raised or visit: www.affordablebullieswer.com ENGLISH Bulldog pups, vet 4, shots, dewormed, parents on site, ready to go $1700 |
|
|
|
|
|
#2 |
|
Frenzied Member
Join Date: Jun 06
Location: UK
Posts: 1,745
![]() ![]() ![]() |
Re: [2005] Parsing a textfile by Delimiters of Capital Words.
I'm not sure I understood all that so this is probably not right. I simply went by the rule that: IF the first word of the current sentence is totally in capital letters, then that entire sentence would be wanted for the final collection. So from the list you posted at the end, this would be in a collection you could output:
DOBERMAN A BIG handsome ENGLISH Bulldog pups for sale ENGLISH Bulldog pups, vet 4, Place a listbox on the form and place this code in a button click event or something. 2 Code:
Last edited by stimbo; May 22nd, 2007 at 02:27 PM. Reason: clarfying routine |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 07
Posts: 2
![]() |
Re: [2005] Parsing a textfile by Delimiters of Capital Words.
Sorry for the late reply.
The problem I'm having has to do with a text file that format for each sentence only has one thing in common, they all begin with words that are in solid capitals. An example of this file would be: THE world is round and round THERE is nothing like being home SOMETIME I want to sleep. THIS is a good day to stay in bed and sleep all day long. NO body loves me. This is an example of the text file. This also includes the spaces. between lines. I tried to write a program that counted the amount of capital letters in the word and if it was more then 2 it would place that in a string, and by using a flag and string builder put together a string, that would stop as soon as detected 2+ capital was detected. However I was not able to get this to work, the program would just do line by line, and would place in the container blank lines as well. Hopefully you guys have some insight as to how I can do this. Thank you. |
|
|
|
|
|
#4 |
|
Hyperactive Member
Join Date: Jul 05
Posts: 392
![]() |
Re: [2005] Parsing a textfile by Delimiters of Capital Words.
It will be easier to help if you post your code.
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|