I want to be able to input a block of text and then have it guess a string within a predefined range (i.e. a string that starts with three letters and ends with five numbers like "XXX12345", etc). Ideally, the string it will be guessing will be somewhere in the block of text, but sometimes it won't be.

I have been struggling where to begin on this or if I am even going in the right direction for considering Machine/Deep learning to try to do this.


  • 1
    Sounds like a statistics problem. But sounds like you could use recurrent neural networks – Andreas Storvik Strauman Apr 10 at 19:04
  • 1
    Is the block of text variable in size? Can you add an example of how the input would look like? – Andreas Storvik Strauman Apr 10 at 19:53
  • 1
    Yeah the block of text would be variable in size. An example would be something like: hello my name is richard cheese. XXX12345 12345 Fake Street Faketown, FakeState USA or XXX12345 is my handle. my interests are posting on stackoverflow and drinking myself into a coma. look forward to hearing from you! ...basically want a neural network to pick out the "handle" from any block of text that is given to it. – TreHoffman Apr 10 at 19:58
  • 1
    Sounds like you want to parse it, and not learn it. You could take a look at regular expressions. Here is an example. – Andreas Storvik Strauman Apr 10 at 20:06
  • 2
    Honestly, I don't know. I do suspect that there are better ways of doing this with more accuracy. It would heavily depend on the training data, and what misspellings you teach the algorithm. If you really want to use DL, I still stand by RNNs being your best choice here, since they can pick up "context". Check out colah's blog for more info on RNNs. – Andreas Storvik Strauman Apr 10 at 20:12

you should definitely check about recurrent-neural networks trained on character level language data. but it make sure you have a relevant dataset.

I would also suggest character level Recurrent neural nets but with Normal Char level RNN we can only predict next chars based on previous chars so you should consider it to be bidirectional RNN because say we have text "xxx12345" basically if we feed this to our model our model should predict first three places based on last places ( in DL they call it as going back through time) and this is possible only by Bidirectional RNN.

  • Can you point me to an example of such an implementation that I can base my work around? – TreHoffman Oct 19 at 17:18

I would suggest you use a sequence to sequence model with character level features. It is an easy task, provided you have data.

  • Can you provide more details in your answer....the answer is too short and can be written as a comment also – DuttaA Aug 10 at 12:44
  • Can you point me to an example of such an implementation that I can base my work around? – TreHoffman Oct 19 at 17:17

As Andreas has commented this is a problem of statistical language model (a probability distribution over a sequence of words). The important thing you need is a hash table mapping fixed-length to the expected ending chains of words in your dictionary.
Things that can make your prediction better:

  • Add better and more words to your dictionary.
  • Use text expansion.

What you are looking for will require a pinch of Reinforcement Learning too. You need to figure out a way to penalize and award the predictions and then use the result in future. Your case also requires you to build your own corpus, which is the hardest part. If your corpus is good, it will give better results.
This is the research paper that will help you a lot.

  • Can you point me to an example of such an implementation that I can base my work around? – TreHoffman Oct 19 at 17:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.