-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
claudiu_daniel_hromei
committed
Nov 14, 2022
1 parent
ce27bb2
commit 6e55590
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
from evaluator import from_srl_string_to_obj | ||
|
||
|
||
acceptable_frames = { | ||
"MOTION": [ "GOAL", "THEME", "DIRECTION", "PATH", "MANNER", "AREA", "DISTANCE","SOURCE" ], | ||
"BRINGING": [ "THEME", "GOAL", "BENEFICIARY", "AGENT", "SOURCE", "MANNER", "AREA"], | ||
"COTHEME": [ "COTHEME", "MANNER", "GOAL", "THEME", "SPEED", "PATH", "AREA" ], | ||
"LOCATING": [ "PHENOMENON", "GROUND", "COGNIZER", "PURPOSE", "MANNER" ], | ||
"INSPECTING": [ "GROUND", "DESIRED_STATE", "INSPECTOR", "UNWANTED_ENTITY" ], | ||
"TAKING": [ "THEME", "SOURCE", "AGENT", "PURPOSE" ], | ||
"CHANGE_DIRECTION": [ "DIRECTION", "ANGLE", "THEME", "SPEED" ], | ||
"ARRIVING": [ "GOAL", "PATH", "MANNER", "THEME" ], | ||
"GIVING": [ "RECIPIENT", "THEME", "DONOR", "REASON" ], | ||
"PLACING": [ "THEME", "GOAL", "AGENT", "AREA" ], | ||
"CLOSURE": [ "CONTAINING_OBJECT", "CONTAINER_PORTAL", "AGENT", "DEGREE" ], | ||
"BEING_LOCATED": [ "THEME", "LOCATION", "PLACE" ], | ||
"CHANGE_OPERATIONAL_STATE": [ "DEVICE", "OPERATIONAL_STATE", "AGENT" ], | ||
"ATTACHING": [ "GOAL", "ITEM", "ITEMS" ], | ||
"RELEASING": [ "THEME", "GOAL" ], | ||
"PERCEPTION_ACTIVE": [ "PHENOMENON", "MANNER" ], | ||
"BEING_IN_CATEGORY": [ "ITEM", "CATEGORY" ], | ||
"MANIPULATION": [ "ENTITY" ], | ||
} | ||
|
||
# bring the book and the journal here, both are on the table | ||
# BRINGING(Goal(e1, e2), Theme("here"), Agent(r1)) & BEING_LOCATED(Place(t1)) | ||
def is_formula_well_formed(formula: str, verbose = False) -> bool: | ||
object_list = from_srl_string_to_obj(formula) | ||
|
||
for frame in object_list: | ||
if frame['name'].upper() not in acceptable_frames.keys(): | ||
if verbose: | ||
print("FRAME " + frame['name'] + " not acceptable") | ||
return False | ||
for fe in frame['frameElements']: | ||
if fe['name'].upper() not in acceptable_frames[frame['name'].upper()]: | ||
if verbose: | ||
print("FRAME ELEMENT" + fe['name'] + " not acceptable") | ||
return False | ||
|
||
return True |