task1 person Name and their Phone Number Extraction

Phone.aql

— TODO: Add AQL content here
create view phone as
extract regexes /(\()?\d{3,4}(\)|-)\d{3,4}(-)\d{4}/ on d.text as num
from Document d;

person.aql

— TODO: Add AQL content here
create view FirstName as
extract dictionaries ‘strictFirst.dict’ on D.text as first
from Document D
having MatchesRegex(/\p{Lu}\p{M}*.{1,20}/,first);

create view LastName as
extract dictionaries ‘strictLast.dict’ on D.text as last
from Document D
having MatchesRegex(/((\p{Lu}\p{M})+\s+)?\p{Lu}\p{M}*.{1,20}/,last);
create view FirstLast as
select CombineSpans(FN.first,LN.last) as name
from FirstName FN, LastName LN
where FollowsTok(FN.first,LN.last,0,0);

create view person as
(select p.first as person from FirstName p)
union all
(select p.last as person from LastName p)
union all
(select p.name as person from FirstLast p);

create view PersonFinal as
select p.person as person from person p
consolidate on p.person using ‘LeftToRight’;
create view PersonPhone as
select CombineSpans(FN.person,LN.num) as name
from PersonFinal FN, phone LN
where FollowsTok(FN.person,LN.num,0,0);

main.aql

— TODO: Add AQL content here
include ‘aql/Phone.aql’;
include ‘aql/person.aql’;

output view phone;
–output view FirstName;
–output view LastName;
output view PersonPhone;