%% Add Named Entity Tags to Documents
% Create a tokenized document array.

str = [
    "Mary moved to Natick, Massachusetts."
    "John uses MATLAB at MathWorks."];
documents = tokenizedDocument(str);

% Add the entity details to the documents using the addEntityDetails function. This function detects the named entities in the text and adds the details to the table returned by the tokenDetails function. View the updated token details of the first few tokens.

documents = addEntityDetails(documents);
tdetails = tokenDetails(documents)

% View the words tagged with the entities "person", "location", "organization", or "other". These words are the words not tagged with "non-entity".

idx = tdetails.Entity ~= "non-entity";
tdetails.Token(idx)

% Copyright 2018 The MathWorks, Inc.