You can follow the below code format to generate a summary table in MATLAB and save it as an Excel sheet.
The code assumes that you have the prediction results stored in a structured format (for example, in MATLAB structures, cell arrays, or tables) and that you can iterate over them to check for the presence of 'Person', 'Location', and 'Organization' entities.
summaryTable = {'Files name', 'Person', 'Location', 'Organization'};
folderPath = 'path_to_your_files';
files = dir(fullfile(folderPath, '*.txt'));
fileName = files(i).name;
nerResults = load(fullfile(folderPath, fileName));
hasPerson = ~isempty(nerResults.person);
hasLocation = ~isempty(nerResults.location);
hasOrganization = ~isempty(nerResults.organization);
person = ifelse(hasPerson, 'Yes', 'No');
location = ifelse(hasLocation, 'Yes', 'No');
organization = ifelse(hasOrganization, 'Yes', 'No');
summaryTable(end+1, :) = {fileName, person, location, organization};
summaryTable = cell2table(summaryTable(2:end, :), 'VariableNames', summaryTable(1, :));
excelFileName = 'NER_Summary.xlsx';
writetable(summaryTable, excelFileName);
function result = ifelse(condition, trueValue, falseValue)
You can modify this script by replacing "path_to_your_files" and the logic for determining the presence of 'Person', 'Location', and 'Organization' based on how your NER results are structured and stored.