• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with this type of programa (manipulating text)  RSS feed

 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.lavenderblush{background-color:lavenderblush}
.green{background-color:green}
.
.

<div class="lavenderblush"></div>
<div class="green"></div>
.
.


I have to repeat this with 200 colors.... I'd like to make this faster, with a program with an text input: red ENTER lavenderblush ENTER .....
and with an text output, ready for copy and paste.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so what have you tried?
 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:Ok, so what have you tried?




"azure", "...... enter colors like this is so hard as the original one.

[Edit - added code tags - see UseCodeTags for details]
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won’t compile; case is a keyword.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Garrido wrote:... with a program with an text input: red ENTER lavenderblush ENTER .....

The program you posted above doesn't ask the user to input the colors like this.

I would make a program that reads the color names from a file. With a text editor, make a file with the name of a color on each line:

Then make a program that reads the file line by line (you can use a BufferedReader to do that) and print out the CSS.
 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:
Martin Garrido wrote:... with a program with an text input: red ENTER lavenderblush ENTER .....

The program you posted above doesn't ask the user to input the colors like this.

I would make a program that reads the color names from a file. With a text editor, make a file with the name of a color on each line:

Then make a program that reads the file line by line (you can use a BufferedReader to do that) and print out the CSS.


thank you.

How could I fill out this file just from my Java program instead of creating a txt file from blocnotes?

 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely you know how to read and write from files. There is a whole section in the Java tutorials.
 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is OK... but next more difficult. I'd like my program give user the option to choose the target string (instead of have to edit ""." + l + "{background-color:" + l + "}"" and recompile).

Something like this: "please, user, introduce the target string (use the word VAR each time you want to introduce the key word): "

(and use introduce for example: "I like color VAR. "

"Thank you. Now introduce the list of valors (introduce QUIT to quit):"

(green
red
QUIT)



OUTPUT:
I like color green
I like color red




How to do this?
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure I understand. Do you want full-blown parsing, or do you simply want replacement of VAR by the next available colour name. The latter should be easy; you can set an index to pick the colour name out of an array.
 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Not sure I understand. Do you want full-blown parsing, or do you simply want replacement of VAR by the next available colour name. The latter should be easy; you can set an index to pick the colour name out of an array.


I think not as simple as you say.

The user can introduce "I like VAR" or ".VAR {color: VAR}" or whatever the user want.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like a free grammar. That is impossible to parse with standard techniques. You would have to try natural language processing if you allow “whatever the user” asks for.
 
Martin Garrido
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That sounds like a free grammar. That is impossible to parse with standard techniques. You would have to try natural language processing if you allow “whatever the user” asks for.


what's a pity... what are the programming languages that make possible this?

natural language processing?

 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Natural language processing is a very high-level subfield of artificial intelligence. You could get a PhD investigating how to process “whatever the user asks for”.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earlier, I wrote:“whatever the user asks for”
I meant processing those five words is worth a PhD
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Garrido wrote:what's a pity... what are the programming languages that make possible this?

natural language processing?

Before you start worrying about PhD theses, my suggestion would be to back up a bit.
Exactly what do you want this program to do? I understand that you want it to accept colour names, but precisely how?

Do you want them validated? Or can the user type:
I like the color £$%%" ?

If you want validation, you'll need some kind of dictionary. Can the user modify it?
For example if s/he types:
I like the color PUCE
and 'PUCE' isn't in your dictionary, what do you want to happen?

My suggestion: write down in detail precisely what you want your program to do before you write another line of code.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!