Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Trent Green

Ranch Hand
+ Follow
since Feb 17, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Trent Green

Piet Souris wrote:No, never seen that message. Can you post the relevant lines of code where that message is generated?

2 weeks ago

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.

Hmm, i just run the debugger and at the line where I send the input to the parse method and add that to an ArrayList and I got a  'The source attachment does not contain the source for the fie StreamDecoder.class' error. I googled it but haven't found anything useful yet. Any ideas what the problem can be?
2 weeks ago

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.

I've been saying that I don't think the problem is in the regexes all along... I just wish there was another way I could show you all my whole code, but I can't think of anything
2 weeks ago

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?

No. This is the actual format of the file
2 weeks ago

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.

0.000: (lorem ipsum dolor sit amet, consectetur adipiscing elit)  [0.001]
0.001: (sed do eiusmod tempor incididunt ut )  [0.001]
0.002: (labore et dolore magna aliqua. Ut enim ad minim veniam)  [0.001]
0.003: (quis nostrud exercitation ullamco laboris)  [0.001]

first regex = "^\\d+(\\.\\d{1,3})?"
second regex = "\\((.*?)\\)"
third regex = "\\[(.*?)\\]"
2 weeks ago

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.

Yes, of course we all now that's the problem. But I guess you also know that getting flagged is a big deal, so I wouldn't want to go through that, I know you'd understand. And yes, that's why I am here - I'm trying to learn while working on this, otherwise I would have found other ways to deal with it.
2 weeks ago

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.

Okay, I moved the declaration of that ArrayList to not be local.

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.

Yes, saveSubs is the list that includes all the lines that I care about(everything after Duration - from my first thread) But now I removed that ArrayList and in the while loop where I'm reading the file I just the processed line with the parse method. Nonetheless, I'm still getting the same output...

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!

I checked and with the modification I said I made above, it is supposedly doing all this(except 4 yet), but still no success. It's so frustrating, because I know that if someone looks at my whole code they'll probably spot something really stupid that I've been banging my head about all day.
2 weeks ago

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();

I find this bit a little confusing. How would those 3 methods look like? Because I have the parsing in one method, as I said, in parse(String) in the Subtitle class. Is that not okay? And do you mean this code would go where I read and process the file? Also what is regex in this case?
2 weeks ago

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

Hmm, but since I'm now I chose to implement the parse method, I'm using the regexes in my Subtitle class
And so on for the other 2.
And then using the parse method as in the code I provided. Wouldn't that work?
2 weeks ago

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?

Haha no, don't be! I was just speaking generally. And I do appreciate your help, really, and I know it's frustrating for both myself and you guys but I just keep encountering more problems - refer to my last post.
2 weeks ago

Norm Radder wrote:If the regex work for you, work on creating a class to hold the parsed data.

Yes, i am working on that. I already created my Subtitle class, but as I said in my previous post - I am having troubles with getting any data inside an object instance. I declare my local variables inside try{ like this

And then use the parse method:

But when I print a subtitle I get this:
Subtitle start time 0.0, text null, duration 0.0
2 weeks ago

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?

No spaces before the first column; : after the first column, space after : ; text inside brackets; space; number in third column might be inside []

But as I've already said that is not the problem, I'm still not sure why all of you guys are so against using my regexes if I've tested them and they work!
Also, please can somebody give their opinion on my previous post?
2 weeks ago
Okay, I think I'm pretty close to the goal, but now I included some print statements and apparently I am getting the initial values so 0.0s and nulls. Could that be because I initialised the variables inside the try statement before reading the file to 0.0, null, 0.0 so they never change, but I did that because it doesn't let me just declare them when I create a new subtitle instance inside the try statement like this And then in the for loop I showed before I do this:
Again, I'm really sorry that I'm not able to post all the code, as this is not the best way of explaining what I've done.
2 weeks ago

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.

My bad. I am still struggling writing that and I know I've said that many times in this topic, but I just feel like I'm struggling so much because of the regexes. Basically, if my file was a csv or the delimiter between columns was the same, I could just easily use split or indexOf. But since it is not, how would I split the string consistently into an array, where using indexes I would extract the first column, second column, third column? That has been my question all along.
And also I don't think in my case it'll be suitable to have that method in the Subtitle class because I'm not reading and processing my file there, but in a different class and that is where I was thinking of doing the parsing
2 weeks ago