llo all,* im trying to build a simple software to modify words. from undesirable content from the internet for example : f*cking into sexual intercourse or something like that im very new into programming so any ideas would help me a lot. thanks

Recommended Answers

All 8 Replies

Well... start with which language you're using, do you have a database, or a list of words? Do you.... wait...

In this case... I'd say try this in your address bar:
"http://www.lmgtfy.com/?q=[ Write the programming language here ]+string+replace"

mm i have a small dictionary with the words im trying to replace... like i said before for example fucking with sexual intercourse or cock with penis etc or i was thinking about instead of cock i can have c*ck but i dont know the code i need to use to have this output. i was thinking i could use java --> eclipse.

e a database, or a list of words

Well for simple replacements you can maintain a hash table with keys are words to be replaced.
But for complex string systems you could research into semantic web and queries.

Cheers
http://crash1989.blogspot.com

ah ok :) java

If you have a Collection<String>, you can use a for loop, and to keep it simple, I'll just change all A,I,E,U,O,Y to a * when the word is not ok:

public String changeBadWords(String string, Collection<String> badWords) {
    for (String badWord : badWords) {
        string = changeBadWord(string, badWord);
    }
    return string;
}
private String changeBadWord(String sentence, String badWord) {
    return sentence.replace(badWord, censor(badWord));
}
private String censor(String badWord) {
    for (String vowel : Arrays.asList("A", "E", "U", "O", "I", "Y")) {
        badWord = badWord.replace(vowel, "*");
    }
    return badWord;
}

Note to others: it can be neater, but I made extra lines as he stated he was a beginner

Eclipse is you IDE ("integrated development environment", you can choose others too, but Eclipse is just fine)

hanks for the replies. it is not working though. dont know what im doing wrong. i'll just tell you briefly what my assignment is about. need to find sexually explicit content from sex stories, urban dictionaries etc and take the undesirable words or phrases and modify them. for example there are 2 ways of modyfing them with euphemisms or replace the vowel with an asterisk.
so my job is to develop a software that does that.
im new in this and tried to look up tutorials on youtube but EVERYTHING is soo confusing. probably thats why there are few girls in this field :P

Thanks,
Clara

Faggot Male Homosexual Fagot
Finger-fuck Masturbation Finger-F
ck
Fuck Sexual Intercourse Fck
Fucking Sexual Intercourse F
cking
Handjob Masturbate Handjb
Handfuck Masturbate Handf
ck
Hardcock Erection Hardcck
Jacking off Masturbate J
cking off
Jerking off Masturbate Jrking off
Jill off Masturbate J
ll off
as examples

i never used hashtable

public String changeBadWords(String string, Collection<String> badWords) {
    for (String badWord : badWords) {
        string = changeBadWord(string, badWord);
    }
    return string;
}
private String changeBadWord(String sentence, String badWord) {
    return sentence.replace(badWord, censor(badWord));
}
private String censor(String badWord) {
    for (String vowel : Arrays.asList("A", "E", "U", "O", "I", "Y")) {
        badWord = badWord.replace(vowel, "*");
    }
    return badWord;
}

@zw_jvdijk83 wrong thread.

ah ok :) java

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.