For each letter used, let's say "x", there can be a corresponding macro \xxx with its color defined. This can be done with punctuation marks, for example exclamation points, via \expandafter\def\csname!!!\endcsname{...}.
The text is passed by way of macro \colorize.
EDITED for getting data from a file.
EDITED for using triple letters \lll as colorizing name, lest things like \ll confuse the algorithm.
EDITED so that non defined colorizing macros are presented in black.
Added an ADDENDUM (see bottom of this answer) to allow for an escape character to give primitive formatting ability within the \colorize macro argument.
The file sample.tex contains this data
cba def abc!
Here is my next pair of graphs!!!
Here is the file that reads and parses it.
\documentclass{article}
\usepackage{readarray}
\usepackage{xcolor}
\newcommand\colorize[1]{\expandafter\colorizepars#1\par\relax\relax}
\long\def\colorizepars#1\par#2\relax{%
\ifx#1\relax\else
\colorizewords#1 \relax\relax%
\fi%
\ifx\relax#2\else\par\colorizepars#2\relax\fi%
}
\def\colorizewords#1 #2\relax{%
\ifx#1\relax\else
\colorizeletters#1\relax\relax%
\fi%
\ifx\relax#2\else\ \colorizewords#2\relax\fi%
}
\makeatletter
\def\colorizeletters#1#2\relax{%
\@ifundefined{#1#1#1}{#1}{\csname#1#1#1\endcsname}%
\ifx\relax#2\else\colorizeletters#2\relax\fi}
\makeatother
\def\aaa{\textcolor{red}{a}}
\def\bbb{\textcolor{blue}{b}}
\def\ccc{\textcolor{green}{c}}
\def\ddd{\textcolor{cyan}{d}}
\def\eee{\textcolor{red!40}{e}}
\def\fff{\textcolor{blue!40}{f}}
\def\ggg{\textcolor{red!30!blue}{g}}
\def\hhh{\textcolor{green!40}{h}}
\def\nnn{\textcolor{yellow!40!green}{n}}
\def\ppp{\textcolor{orange}{p}}
\def\rrr{\textcolor{blue!30}{r}}
\def\ttt{\textcolor{green!40!blue}{t}}
\def\xxx{\textcolor{black!50}{x}}
\expandafter\def\csname!!!\endcsname{\textcolor{yellow}{!}}
\def\colorizeentry#1{\edef\tmp{\arrayij{mydata}{#1}{1}}\colorize{\tmp}}
\begin{document}
\colorize{%
abc def!
next paragraph Undefined letters are black.
}
Here is a way to get it from a file, if paragraphs are not needed
\readdef{sample.tex}{\x}
\colorize{\x}
If paragraphs are needed, you can place each paragraph in its own single row
of the input file and parse line by line.
\copyrecords{mydata}% USES DATA FROM MOST RECENT \readdef; ASSIGNS ROWS TO "mydata"
\colorizeentry{1}
\colorizeentry{2}
\colorizeentry{3}
\end{document}
ZOOM IN

ZOOM OUT

ADDENDUM:
If you needed some primitive formatting ability in the colorized text, you could build in an escape character (here the [) as such:
\makeatletter
\def\colorizeletters#1#2#3\relax{%
\ifx [#1\EscapeChar{#2}%
\ifx\relax#3\else\colorizeletters#3\relax\fi%
\else%
\@ifundefined{#1#1#1}{#1}{\csname#1#1#1\endcsname}%
\ifx\relax#2\else\colorizeletters#2#3\relax\relax\fi%
\fi%
}
\makeatother
\def\EscapeChar#1{%
\if 0#1\relax \textcolor{blue}{[}\else%
\if 1#1\relax \bfseries\else%
\if 2#1\relax \mdseries\else%
\if 3#1\relax \itshape\else%
\if 4#1\relax \upshape\else%
\fi\fi\fi\fi\fi%
}
Then, the following code
\colorize{%
abc def!
next [1paragraph[2 [0Undefined] [3letters[4 are black.
}
would display as

datatoolis for maniuplating databases: if we are talking free-form text there are alternative approaches. What deterimines the colour applicable to each letter? – Joseph Wright Feb 10 '15 at 10:34aabbaa=>\textcolor{red}{a}\textcolor{red}{a}\texcolor{blue}{b}...– Joseph Wright Feb 10 '15 at 10:42