Please tell me if there is a way for plotting a point on a 2d graph using (x,y) coordinates by deriving (or I can say mapping) a String object into numeric values for 'x' and 'y'. Example: I have a String "abcd". This needs to be represented as a point in a Euclidean graph. Preferable language is Java.
Asked
Active
Viewed 240 times
-3
-
3This is way too vague to answer. You could map it by taking some arbitrary hash code (e.g. `text.hashCode()`) and using that as the `x` value, with y=0 for all strings. Presumably that *wouldn't* be good enough for you - but it meets every requirement you've actually *specified*. – Jon Skeet Apr 12 '12 at 15:47
-
1What are you trying to achieve? What is the underlying problem that you're trying to solve? – biziclop Apr 12 '12 at 15:50
-
1@JonSkeet Don't overcomplicate it, x=0 and y=0 for every string works just as well :) – biziclop Apr 12 '12 at 15:51
3 Answers
5
things to use for values:
- hash of the string
- length of the string
- numeric addition of all the chars
- [some mathematical function] of all the chars
Use one of them for x and the other one for y. There you go.

rnalexander
- 76
- 4
3
You could try feeding the string to a spam filter (x = spamminess) and something that gives a readability score based on lexical and grammatical complexity (y = readability). Or write something that uses the StackOverflow API to submit it as a question or answer, and plot how many upvotes it gets.
Also, try evaluating the string itself as a program - plot a 0 if it terminates, and a 1 if it doesn't (you may have to wait a while to determine this result).

Dominic Fox
- 1,039
- 11
- 8