# What Machine Learning library / algorithm should I use to extract pre-defined features from email text?

I'm new to ML, so if it seems like I am making incorrect assumptions on how to go about doing something, please feel free to correct me.

I would like to be able to pass in as training data many emails as text files and the features (output) that should be extracted from those files. Most of the emails specific formatting will be very different. However, they will all contain the same basic data that I want to extract.

An example email would be of a receipt for some product or service you signed up for, saying something like "We have charged X amount to your credit card... This bill is for 8-22-17 - 9-22-17...". I would want to be able to extract the amount you were charged for, the currency, an invoice/receipt id, the plan interval for what you are paying (month, year, etc.), and plan type (basic, premium, etc.).

Is there a way with some library (preferably some Javascript/Node library or Tensor Flow) to pass in the expected output, say as a JSON object where the keys are the names of the features I would like to extract and the values are the extracted values?

For example, if the email is a receipt, I would like to be able pass in the features:

{
PRICE: 100,
CURRENCY: "USD",
}


so I'm telling the algorithm that the price is 100 and the currency is USD for that particular email.

What I would like is that the algorithm should return an object as output for a new email passed in and be capable of finding and setting on the object the price and currency.

I know I am talking very specific with JSON, so if there is another way to do it that doesn't involve JSON that is fine.

Ultimately, what library and algorithm would be appropriate to solve my problem?

Thank you!

• It sounds like what you want would require magic, or strong AI (but I repeat myself), unless the problem is less general than it sounds. – Kodiologist Aug 27 '17 at 23:38
• @Kodiologist What aspect sounds to you like it would need magic? I would always be expecting the same kind of data from all of the emails e.g. price, currency, etc. Nothing new that it hadn't trained on. If you have a moment, could you please look at this link? It's a very similar question to what I'm asking. The answer to that question references tools that I think are a little over my head at this point to use. – aryeh Aug 28 '17 at 0:03
• This question has nothing to do with machine learning. All you need is a parser for whatever format you're storing the input data. If you're using JSON, most programming languages you'd want to use have some library for reading JSON files. – Batman Aug 28 '17 at 0:12
• @Batman I'm expecting that the email formats are mostly very different but contain the same data that I want to extract. So for example, each email could have a different way of saying what the price is. I would have to write a parser for every kind of email. – aryeh Aug 28 '17 at 0:15
• It would help to have a few examples of the kinds of emails you'd like to be able to extract, and some more information about the kinds of labels you want (how many there are, etc). In ML terminology these wouldn't be called "features" (which would rather be some aspects of the emails which are directly observable) but "labels" (the things you're trying to predict), and the problem one of text classification / regression / information retrieval. – Danica Aug 28 '17 at 2:00