<p>To map a word to a number, you should probably just use an <a href="http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/natlog/util/Index.html" rel="nofollow noreferrer">index</a>. Using hashcodes is just asking for trouble, since completely unrelated words could end up using the same value.</p>

<p>There are a number of ways to get a numerical measure of how semantically related words are, such as <a href="http://en.wikipedia.org/wiki/Latent_semantic_analysis" rel="nofollow noreferrer">latent semantic analysis (LSA)</a> or using some measure of relatedness within a lexical resource like  <a href="http://wordnet.princeton.edu/" rel="nofollow noreferrer">WordNet</a> (e.g. <a href="http://webdocs.cs.ualberta.ca/~lindek/papers/sim.pdf" rel="nofollow noreferrer">Lin</a>, <a href="http://www.cs.cmu.edu/afs/cs/project/jair/pub/volume11/resnik99a.pdf" rel="nofollow noreferrer">Resnik</a>, or <a href="http://arxiv.org/PS_cache/cmp-lg/pdf/9709/9709008v1.pdf" rel="nofollow noreferrer">Jiang-Conrath</a>).</p>

<p>To get what you're calling lexical categories, you'll need to use <a href="http://nlp.stanford.edu/software/tagger.shtml" rel="nofollow noreferrer">a part-of-speech (POS) tagger</a>. The POS tags will also give you tense information (e.g., VBP means the word is a past tense verb). </p>

<p>To assign words to topics, you could make use of <a href="http://en.wikipedia.org/wiki/Hypernym" rel="nofollow noreferrer">hypernym information</a> from WordNet. This will give you stuff like 'red' is a 'color'. Or, you could make use of <a href="http://en.wikipedia.org/wiki/Latent_Dirichlet_allocation" rel="nofollow noreferrer">Latent Dirichlet allocation (LDA)</a>, if you would like to have a softer assignment of words to topics such that each word can be assigned to numerous topics to varying degrees. </p>
Mapping words to numbers with respect to definition
<p>As part of a larger project, I need to read in text and represent each word as a number. For example, if the program reads in "<em>Every good boy deserves fruit</em>", then I would get a table that converts '<strong><em>every</em></strong>' to '<strong>1742</strong>', '<strong><em>good</em></strong>' to '<strong>977513</strong>', etc. </p>

<p>Now, obviously I can just use a hashing algorithm to get these numbers. However, it would be more useful if words with similar meanings had numerical values close to each other, so that '<strong><em>good</em></strong>' becomes '<strong>6827</strong>' and '<strong><em>great</em></strong>' becomes '<strong>6835</strong>', etc. </p>

<p>As another option, instead of a simple integer representing each number, it would be even better to have a vector made up of multiple numbers, eg (<i>lexical_category</i>, <em>tense</em>, <em>classification</em>, <i>specific_word</i>) where <i>lexical_category</i> is noun/verb/adjective/etc, <em>tense</em> is future/past/present, <em>classification</em> defines a wide set of general topics and <i>specific_word</i> is much the same as described in the previous paragraph.</p>



<p>Does any such an algorithm exist? If not, can you give me any tips on how to get started on developing one myself? I code in C++.</p>