Solving a Program to Break Words into Chunks

In summary: Array = new Array();myArray.push("In summary, ");for (var i = 0; i < myArray.length; ++i){myArray[i] = myArray[i].replace(" ", " ");}myArray.push("I am having trouble with this program.");myArray.push("I would not need a complete code.. but instead just some words that would point me in the correct direction.. or how you would go about solving it.");myArray.push(". ");myArray.push("Show us what you have so far.");myArray
  • #1
newyorkNYC
1
0

Homework Statement



Hello, I am having trouble with this program. I would not need a complete code.. but instead just some words that would point me in the correct direction.. or how you would go about solving it.

This is the problem.

The file contains lines like the following.

ABCThese are some words that must
ABCbe broken down into smaller chuncks.
XYZMore words
XYZthat must be put into chunks.
123Ya

So basically output file look like:
ABC01These are
ABC02some words
ABC03 etc
XYZ01

etc. so each one consists of ten characters.

Any pointers?
 
Physics news on Phys.org
  • #3
Kind of stumped actually. Everything I've tried seems to fail.

Ill post when I got something valuable.
 
  • #4
It seems you would read in the file input as strings and devise your own simple way to parse those strings.
Also your problem you have provided is lacking some detail, all your telling us is you need to read in some file data and put them into "chunks", by chunks you could have meant two things judging from what your output file is supposed to be like, chunks being each string you've read in parsed into new variable or chunks of array, from your post of output file seems to be an array it seems like you can benefit from using a simple array of structs, where your struct contains two variables string word, int wordCount; once again judging from your posts here is some pseudo code to possible help you

Code:
//Declare your struct here

//In main 
{
 //Declare your array of struct objects
//You choosing to be dynamic, or static if you know the amount of input coming in
//Open file
//Go through file placing new strings into array
//Inside of reading the data in, iterate through the current array elements
//If your current item read in already exists in the array, do not add it and increment the count of how many items that item was in the input //file

Or
//Place all items into the array with no checking
//After data has been  read in, iterate through the array checking if an array element has a duplicate else where in the array if so increment //duplicate count

//Close input file
//Write output to wilte
 
Last edited:

Related to Solving a Program to Break Words into Chunks

1. How does the program break words into chunks?

The program breaks words into smaller chunks by first analyzing the word and identifying patterns or syllables. It then divides the word based on these patterns to create chunks.

2. Can the program handle different languages or only English?

The program can be designed to handle different languages by incorporating language-specific rules and patterns. However, the default program may be designed to only break English words into chunks.

3. How accurate is the program in breaking words into chunks?

The accuracy of the program depends on the complexity of the word and the rules/patterns it is designed to follow. It may have a high accuracy for simpler words, but may struggle with more complex words.

4. Can the program handle words with multiple pronunciations?

Yes, the program can handle words with multiple pronunciations by following the appropriate rules and patterns for each pronunciation. However, it may not be able to accurately break down all variations of a word.

5. Is there a limit to the number of chunks the program can create for a word?

The program may have a set limit for the number of chunks it can create for a word, depending on its design. This limit may also vary depending on the complexity of the word being analyzed.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
22
Views
981
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
Back
Top