Question: I am using Asp.net mvc4 web-api.

I got an error 404 method not found, i am calling DelteMenu Method using jquery ajax. I am pssing argument Using data : of Jquery ajax. if i am passing Model parameter it is working fine but for other parameters like Guid, String throwing exception : 404 method nod found.please let me know if you have any idea why it is throwing 404 error.

```
//api method
public HttpResponseMessage DeleteMenu(Guid MenuId)
        {
            try
            {
                MenuDA.DeleteMenu(objMenuModel.MenuId);

                return this.Request.CreateResponse(
                                HttpStatusCode.OK,
                                new
                                {
                                    Success = true
                                });

            }
            catch (Exception ex)
            {
                ErrorLogDA.LogException(ex);
                throw ex;
            }

        }

//Jquery ajax function

function performdeletemenu(MenuId)
{

    if (confirm('Are you sure you want to delete this menu?'))
    {
        $.ajax({
            type: 'DELETE',
            url: '/api/MenuWebApi/DeleteMenu/',
            data: "MenuId=" + MenuId,
            success: function (data)
            {
                if (data.Success == true)
                {
                    GetMenuList();
                }
            },
            error: function (xhr, textStatus, errorThrown)
            {
                //window.location = JsErrorAction;
            },
            dataType: "json",
            headers:
            {
                'RequestVerificationToken': JsTokenHeaderValue
            }

        });
    }

    return false;
}

```

Regards

Answer: 
Use a `collections.Counter()` object and split your words on whitespace. You probably want to lowercase your words as well, and remove punctuation:

```
from collections import Counter

counts = Counter()

for sentence in sequence_of_sentences:
    counts.update(word.strip('.,?!"\'').lower() for word in sentence.split())

```

or perhaps use a regular expression that only matches word characters:

```
from collections import Counter
import re

counts = Counter()
words = re.compile(r'\w+')

for sentence in sequence_of_sentences:
    counts.update(words.findall(sentence.lower()))

```

Now you have a `counts` dictionary with per-word counts.

Demo:

```
>>> sequence_of_sentences = ['This is a sentence', 'This is another sentence']
>>> from collections import Counter
>>> counts = Counter()
>>> for sentence in sequence_of_sentences:
...     counts.update(word.strip('.,?!"\'').lower() for word in sentence.split())
... 
>>> counts
Counter({'this': 2, 'is': 2, 'sentence': 2, 'a': 1, 'another': 1})
>>> counts['sentence']
2

```
You could do what you want pretty easily with a little regex and a dictionary.

```
import re

dict = {}
sentence_list = ['This is a sentence', 'This is a sentence']
for sentence in sentence_list:
    for word in re.split('\s', sentence): # split with whitespace
        try:
            dict[word] += 1
        except KeyError:
            dict[word] = 1
print dict

```