-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary of Changes Added support for: - Generalized AMR linking. - Resolving AMR type automatically - Expanding the pdf annotation endpoint to link to an amr when provided one as input ### Related issues Resolves #837
- Loading branch information
Showing
11 changed files
with
1,285 additions
and
38 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
skema/metal/model_linker/skema_model_linker/linkers/generalizer_amr_linker.py
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,30 @@ | ||
from collections import defaultdict | ||
from typing import Iterable, Dict, List, Any | ||
|
||
from . import heuristics, AMRLinker | ||
from ..walkers import JsonDictWalker, JsonNode | ||
from ..walkers import GeneralizedAMRWalker | ||
|
||
|
||
class GeneralizedAMRLinker(AMRLinker): | ||
|
||
def _generate_linking_sources(self, elements: Iterable[JsonNode]) -> Dict[str, List[Any]]: | ||
ret = defaultdict(list) | ||
for name, val, ix in elements: | ||
if (name == "states") or (name == "parameters" and 'name' in val): | ||
key = val['name'].strip() | ||
lower_case_key = key.lower() | ||
|
||
if "description" in val: | ||
ret[f"{key}: {val['description']}"] = val | ||
else: | ||
if lower_case_key in heuristics: | ||
descriptions = heuristics[lower_case_key] | ||
for desc in descriptions: | ||
ret[f"{key}: {desc}"] = val | ||
ret[key] = val | ||
|
||
return ret | ||
|
||
def _build_walker(self, amr_data) -> JsonDictWalker: | ||
return GeneralizedAMRWalker(amr_data) |
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
9 changes: 9 additions & 0 deletions
9
skema/metal/model_linker/skema_model_linker/walkers/generalized_amr.py
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,9 @@ | ||
from typing import Optional, Any | ||
|
||
from . import JsonDictWalker | ||
|
||
|
||
class GeneralizedAMRWalker(JsonDictWalker): | ||
|
||
def _filter(self, obj_name: Optional[str], obj: Any, index: Optional[int]) -> bool: | ||
return obj_name in {"states", "parameters"} |
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
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
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
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
Oops, something went wrong.