Analysis and spelling correction of SMS text using python
<p>For example, I have a sentence:</p>

<blockquote>
  <p>hav bin reali happy since tlkin 2 u</p>
</blockquote>

<p>With a python script, I want to edit above line so that it becomes:</p>

<blockquote>
  <p>have been really happy since talking to you[sic]</p>
</blockquote>

<p>How can I read each and every character and either replace or edit, or remove letter from words?
And can I/must I store the whole correct sentence in a different variable?</p>

<pre><code>replacements = {
  'hav': 'have',
  'bin': 'been',
  'reali': 'really',
  'u': 'you',
  'tlkin': 'talking',
  '2': 'to'
}

sms = 'hav bin reali happy since tlkin 2 u'

original = ' '.join([replacements.get(w, w) for w in sms.split()])
print(original)
</code></pre>

python text-analysis