![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2007
Posts: 2
Rep Power: 0
![]() |
Please i need help with this Assignment!!!!
Write a filter that divides the input text into sentences.
Remarks: Each sentence sends with one of the following characters: '.", '?', or '!'. Use a special function isSentEnd to detect characters ending a sentence. The isSentEnd function has the following prototype: bool isSentEnd(int c); The ending character must be included in the sentence. The new line character '\n' follows immediately. Spaces, tabulation and new line characters separating sentences must be omitted. The maximum allowed length of a sentence is 200 characters. Sentences exceeding the limit must be cut into separate parts. The sequences of white space characters (new line '\n' and tabulation '\t' and a regular space ' ' ) inside a sentence should be replaced by a single space. Test the program using the redirection of standard input and the test.txt file. How many sentences have the string xxxx inside? |
|
|
|
|
#2 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5
![]() |
Re: Please i need help with this Assignment!!!!
We're not going to do your homework for you. Show us some effort on your part first, and we'll be willing to help (in other words, post some code, explain why it's not working, and we'll take a look).
That said, I have a question for you. How is the isSentEnd() function supposed to work? You pass it an int, but does this int represent the character you're testing (ie, it will return true for '.', '!', and '?', and false for everything else), or is it an index that specifies which character to test? If the former, why isn't it char instead of int? If it's the latter, you might consider using an unsigned type instead.Now, because I'm nice, I'm going to offer a few suggestions as to how you can approach this, but I'm not posting code for it until you do. First, you need a buffer (array of char) to hold your characters; size it appropriately (hint: don't forget the terminator). Then you want to loop while there is still data to be read, and read in a character each time; you can use various approaches to detect the end-of-file. For each character read, you test it, and add it to the buffer (you'll need to track the current buffer index) as long as there is room, and it's not a whitespace character. If it's a whitespace character, you add a space character to the buffer, unless the previously-read character was also whitespace; in this case, you add nothing to the buffer. If it is an end-of-sentence marker or you have filled up the buffer, you do whatever you need to do with the buffer (I'm assuming print it to the screen, but you didn't say), reset your buffer index, and continue. If you lay this out on paper first, you'll see it's not very complicated at all. It's even easier if you modularize it by breaking it into multiple functions that you can call from the loop.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
#3 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4
![]() |
Re: Please i need help with this Assignment!!!!
closed because cross-post at DaniWeb (twice I might add).
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flow chart and pseudocode assignment | JimR | Other Programming Languages | 15 | Jun 9th, 2008 4:20 AM |
| Pascal assignment help | AlexN | Delphi | 4 | Nov 20th, 2007 10:30 AM |
| AP CS Assignment : Could someone look it over for me? | iSamurai | Java | 12 | Oct 13th, 2006 1:29 AM |
| assignment question | b1g4L | Java | 10 | Mar 19th, 2006 10:50 AM |
| Assignment, asking for help | JimR | Visual Basic .NET | 25 | Jan 20th, 2006 11:28 AM |