• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing an algorithm using counters

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 = "\\[(.*?)\\]"
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a problem making a short section of code with a String, some regexes and some print statements to show how you are able to parse the three fields from the input Strings?
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, never seen that message. Can you post the relevant lines of code where that message is generated?
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


Sure.
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you are using the instance 'subtitle' to invoke the parse method, and that should work. I tested it, and indeed it worked. Also, making the parse method non-static worked, so I was unable to reproduce that error. Let's wait if someone else knows what is going on, at least what that message means.
 
Trent Green
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No other ideas anyone?
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I googled around for the message: the source attachment does not contain the source for the file xxxxx.class

found some info at StackOverflow. It looks like the StreamDecoder.class can't be found. On my harddisk, I found the StreamDecoder.class here:

C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar\sun\nio\cs\

Can you ckeck that?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the debugger can't find the source code for a class in the standard API, then I wouldn't call that a "problem". You wouldn't learn anything by stepping through that source code anyway. Just click on the "step out of this method" button and carry on.
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The idea behnd the debugger was to find out what error there might be and where it originated. But the question remains what that error (if it is one) means. And so far I still don't know. Maybe you can elaborarte a little?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was that directed at me? Okay... The debugger is designed to show you source code and step through it as your code executes. Naturally your source code is available when you're doing this, at least it is available when you're doing it in an IDE. However the source code of the standard API may or may not be available. It's possible to get the Java code for the standard API, it's usually in src.zip in your downloaded JVM. And usually it's necessary to configure the IDE to tell it that, at least it is in Eclipse. However not all of the standard API is Java code. There's native code in there as well, written in C or some such language, and you can't step through that in your debugger no matter what.

Anyway if the debugger finds that it doesn't have Java source code for some compiled Java statement it tries to run, it tells you that. (The message under discussion.) So it's not an "error" message. It's just the debugger telling you it doesn't have source code to show you. Nothing to do with any error which may occur or have occurred in your code.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should also mention that it's possible to compile Java code with debugging information turned off. (This produces a smaller .class file, which used to be important when passing 6-megabyte jar files around was a problem.) You'll sometimes find that people have done that if they don't want you to see your source code, but the Oracle JVM I'm using includes debugging information. Anyway, your debugger won't be able to step through code which has been compiled that way either.
 
Piet Souris
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Paul, that makes a lot of sense.

So, that is not the problem.

@Trent
Without insight into your code, I have no idea what else I can do. Any ideas?
 
reply
    Bookmark Topic Watch Topic
  • New Topic