public static string ReadInformation(DomainInformation info) { var words = info.Components .OrderBy(component => component.Location) .Select(component => component.Content); return(string.Join(" ", words)); }
public static string MapTypeToMessage(Category type) => type.ToString(); // todo : swap to descriptions of type // For information where components have gaps between them // Useful for address where the street name might not be a component public static string ReadInformationFromInput(IList <IList <Cell> > input, DomainInformation info) { var locationsWithinCell = info.Components.Select(component => component.Location).ToList(); var startLocationWithinCell = locationsWithinCell.Min(); var endLocationWithinCell = locationsWithinCell.Max(); var location = MapToLocation(info.Components.First().CellLocation); var cell = input[(int)location.Row][(int)location.Column]; var words = cell.Words .OrderBy(word => word.Location) .Where(word => word.Location >= startLocationWithinCell) .Where(word => word.Location <= endLocationWithinCell) .Select(word => word.Content); return(string.Join(" ", words)); }
public static Error MapToError(DomainInformation info, IList <IList <Cell> > input) { var message = info.Type == Category.Address ? ReadInformationFromInput(input, info) : ReadInformation(info); return(new Error { Code = info.Type.ToString(), Item = new Item { Location = MapToLocation(info.Components.First().CellLocation), ItemType = MapTypeToCode(info.Type) // bit meaningless? }, Message = message }); }