Piet Souris wrote:Yes, but it is not so that we don't believe you, it is just that we believe ourselves more...
So, two possible culprits left: somewhere in the parse method, or somewhere else in the Subtitle class, there is something wrong, or there where you send the input line to the parse method, something goes wrong, perhaps in the part where you receive the new Subtitle Instance. Put as many println's in your code, so that can follow everything that the code is doing, and if you have a debugger with a single stepper (most IDE's have one) that would also be ideal.
Piet Souris wrote:Hmm... the three regexes worked for me as they should. In the Subtitle class, I used
and in the parse method
Note that for the duration to work, I had to remove the square brackets.
Liutauras Vilda wrote:Wait.
You said lines differ in terms of structure/layout. You weren't precise when you said that back then, or you didn't reflect these in the examples you showed us now?
Piet Souris wrote:Don't worry. Norm is busy interrogating your regexes, maybe these are not as working as you thought they would be. So, after all the wise words from Liutauras and me, help Norm answering his questions. But to help him with that, and to fullfill our last 200 replies requests: show us some real input lines, with faked input fields if you like, together with the regexes you use now? It would help us enormously.
Liutauras Vilda wrote:These were just dummy ideas to visualise concept.
It can be confusing, and probably it is, but that is because we talk about the things we don't see. I'm talking about the things what's in my head only, you are talking about the things which are in your head only, and we don't share any indirectly tangible asset (code).
So yeah, you are talking about the shoes, I'm about the barrels That's the joke, to give visual imagination how difficult sometimes can be to discuss about the things on forums.
Trent, buddy, we are not going to get anywhere with this. Your concern is Turnitin, that's understandable, but then you need to work out yourself somehow.
If I were you, and would know that I need to catch up with my course material, I'd just share my code, I'd do my best to take advices in order to finish project, UNDERSTAND IT, and wouldn't worry about the submission - that's because you have a backlog of understanding (reasons are known for you probably).
Point is to LEARN and UNDERSTAND. Not to get the MARK. Mark is the result of the mentioned first two. If you look for a job, much more important is UNDERSTAND. So is your call what you want to achieve here.
Piet Souris wrote:Of course that will work, but what troubles me is that from the code you supplied I'm afraid there is something wrong with the order in which you let things happen.
You are creating subtitle as an instance of Subtitle, as I said in my previous reply, that is oke. But on the next line, you create an ArrayList that is supposed to hold all these Subtitle instances! Normally, this list should be there before creating any sublist at all.
Piet Souris wrote:What is 'saveSubs'? I assume it is the list of inputlines-to-be-split, but the code we supplied was meant to send each inputline directly to the parse-method of the Subtitle class. And next: the parse method is a static method of the Subtitle class. What you are now doing is invoke the parse method via the subtitle instance. Although that should also work, it requires that you have this instance in the first place.
Piet Souris wrote:You see, your code should work in principle, but it is presented in snippets and so it is hard for us to judge if the order of things are correct. Now, we know you don't want to publish your full code, for good reasons, but it means that you yourself must look very carefull if your code indeed does what it should do. So, to sum up:
1) read an inputline
2) if that line is after the line containing 'Duration'(see topic 1) send that line to the parse method of the Subtitle class, using your working regexes there to get the reuired fields
3) save the returned Subtitle instance to you Subtitle-list
4) and, what has not yet come up, use your list to get the subtitles to show up in time!
Liutauras Vilda wrote:
Now what you need to do is to create an instance of the Subtitle class.
I'll use strings for example:
String start = regex.giveMeFirstThing();
String middle = regex.giveMeWhatIsInBetweenParentheses();
String end = regex.giveMeLastThing();
Piet Souris wrote:.
But what you next must do:
1) split the line you just read into the three parts, say start2, text2, duration2, using your regexes
2) then put these values into your just created subtitle instance: subtitle.setStart(start2); subtitle.setText(text2) et cetera
3) add subtitle to your list
Piet Souris wrote:[
Now I feel offended! In my direct reply I advised to stick to these regexes!
All Liutauras and I did was telling how and where to apply the three parts of the input lines, either directly create a Subtitle instance, there where you process the input lines, or via the parse-method of the Subtitle class. What more should we tell?
Norm Radder wrote:If the regex work for you, work on creating a class to hold the parsed data.
Norm Radder wrote:
You need to describe what Strings delimit each of the three fields.
Can there be spaces before the first field?
Can there be spaces after the last field?
Stephan van Hulst wrote:"To parse" means something like "to assign meaning to symbols". A string is just a bunch of symbols without meaning. When you parse a string, you interpret parts of the string and create an object that encapsulates the interpreted meaning.
In the previous topic you posted, I posted a Subtitle class that encapsulates the meaning of a line of your input. You should add a static Subtitle parse(String) method to it that converts a line of input to an instance of Subtitle. Show us your implementation of that method, nothing more, nothing less. Then we can continue with the next step.