Given a document and a word, determining wherape that word is in the document and how many times it appears

So assuming we let D be a document consisting of words d1,…dn, which are separated by single spaces. Words can appear several times in D. I need to write a function WordIndex(D) which would return the following cell array C C{k,1}= d C{k,2}=The set of all locations where d appears in D
By location of d we mean index of the first character of d in the string D. For example let D=‘this is just just the very very simple test’ Then C{3,1}=’just’ C{3,2}= {9,14}

1 Comment

You have accidentally left out the question that you wish to ask us. What specifically would you like assistance with?

Answers (0)

This question is closed.

Products

Asked:

on 30 Mar 2011

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!