grammar AgencyCompany
rule expression
find_agency / find_company
end
rule find_agency
agency space that space concrete_company space work_with
end
rule find_company
company space that concrete_agency space work_with
end
rule work_with
("has" / "have") space ("partnered" / "partner" / "worked" / "work") space "with"
end
rule that
"that" / "which"
end
rule company
"companies" / "vendors" / "company" / "vendor"
end
rule agency
"agency" / "agencies"
end
rule my_company
"my company"
end
rule concrete_company
entity_name
end
rule concrete_agency
entity_name
end
rule entity_name
(word (space word)?)+ / word
end
rule word
[a-zA-Z]+
end
rule space
[\s]+
end
end
(Treetop.load "./lib/bgov_brain/queries/agency_company.treetop").new.parse("agency that locked martin has worked with") #=> Works
(Treetop.load "./lib/bgov_brain/queries/agency_company.treetop").new.parse("agency that locked martin abc has worked with") #=> Not Works
(Treetop.load "./lib/bgov_brain/queries/agency_company.treetop").new.parse("agency that locked has worked with") #=> Not Works
(Treetop.load "./lib/bgov_brain/queries/agency_company.treetop").new.parse("company that dod has worked with") #=> Not Works
(Treetop.load "./lib/bgov_brain/queries/agency_company.treetop").new.parse("company that department of education has worked with") #=> Not Works
I feel I have a missing concept to understand.