• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to delete duplicate characters

 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey so big test tomorrow, worth like 15% of final grade and I was doing some study on past papers and one of the questions asks to convert all words into stem words. A stem word is produced from a suspect word by first removing all characters except for consonants. Then all duplicate letter sequences are removed. The Stem word for "Viagra" would be "vgr and the stem word for "vla-grrra" is also "vgr".
This is what I'v done so far


Any help would be great
 
Praful Thakare
Ranch Hand
Posts: 642
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what has it to do with webservices?
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praful Thakare wrote:what has it to do with webservices?

Sorry had no idea its meant to be a java question, I just joined
 
Paul Clapham
Sheriff
Pie
Posts: 20206
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I moved the thread to "Beginning Java".
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I moved the thread to "Beginning Java".

Thanks!
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12022
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sara Lyons wrote:
//this loop doesnt really work and I don't know what to do after the if statement
//im trying to delete duplicate characters in this loop and if statement but not really sure how to go about it
...Any help would be great

Before you even write a line of code, you need to stop and think about how you do things.

Think about it in English - not Java. If I gave you a piece of paper with a string of characters on it, how would YOU remove duplicate characters?
 
Sai Hegde
security forum advocate
Ranch Hand
Posts: 205
1
Android Flex Google App Engine
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
Sara Lyons wrote:
//this loop doesnt really work and I don't know what to do after the if statement
//im trying to delete duplicate characters in this loop and if statement but not really sure how to go about it
...Any help would be great

Before you even write a line of code, you need to stop and think about how you do things.

Think about it in English - not Java. If I gave you a piece of paper with a string of characters on it, how would YOU remove duplicate characters?

Emm I'd cross them off the paper?? I'm so bad at java epic fail tomorrow .
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai Hegde wrote:


THANK YOU SO MUCH!
 
Paul Clapham
Sheriff
Pie
Posts: 20206
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.


No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sara Lyons wrote:
Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.


No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".



Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Sara Lyons wrote:
Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.


No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".



Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry

Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12022
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sara Lyons wrote:Emm I'd cross them off the paper?? I'm so bad at java epic fail tomorrow .

And how would you know/decide which to cross off? What if you couldn't write on the original piece of paper, but only on a NEW piece of paper?
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sara Lyons wrote:
Henry Wong wrote:
Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry

Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it


Not sure if I understand what you are trying to say. Are you saying... "you figured it out using loops -- you solved it. And everything is all good"? Or are you saying ... "you just found out that you need to do it using loops -- and you can't use the previously provided solution that you don't understand"?

Henry
 
Sara Lyons
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Sara Lyons wrote:
Henry Wong wrote:
Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry

Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it


Not sure if I understand what you are trying to say. Are you saying... "you figured it out using loops -- you solved it. And everything is all good"? Or are you saying ... "you just found out that you need to do it using loops -- and you can't use the previously provided solution that you don't understand"?

Henry

No i figured out how to just check for duplicates using a loop. But anyway just had my test and that kind of question never came up
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic