Skip to content

Commit d96a0fc

Browse files
committed
Renamed Hyperedge.normalized to normalise
1 parent c0ce6ed commit d96a0fc

6 files changed

Lines changed: 16 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- Hyperedge.insert_argrole now private, renamed to Hyperedge._insert_argrole.
2323
- Renamed Hyperedge.insert_edge_with_argrole to add_argument, pos optional (default to add at the end).
2424
- Renamed Hyperedge.edges_with_argrole to arguments_with_role.
25+
- Renamed Hyperedge.normalized to normalise.
2526

2627
### Removed
2728
- function patterns.edge_matches_pattern.
@@ -92,7 +93,7 @@
9293
- Hypergraph.text().
9394
- Parser.parse_and_add().
9495
- Parser.sentences().
95-
- Hyperedge.normalized().
96+
- Hyperedge.normalise().
9697
- New package graphbrain.readers, for text readers from various sources.
9798
- New package graphbrain.processors, for miscellaneous processors.
9899
- Processor class.

docs/manual/hyperedges.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,13 @@ Returns a dictionary of structural errors found in the edge. Each key is the pro
469469

470470
The checks include connector type validation, modifier and builder structure, trigger structure, predicate argument types, conjunction arity, and argument role counts and validity.
471471

472-
### normalized()
472+
### normalise()
473473

474474
Returns a normalized version of the edge where argument roles (and their corresponding arguments) are sorted into a canonical order:
475475

476476
```pycon
477477
>>> edge = hedge('(is/P.cs nice/C berlin/C)')
478-
>>> edge.normalized()
478+
>>> edge.normalise()
479479
(is/P.sc berlin/C nice/C)
480480
```
481481

src/hyperbase/hyperedge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def check_correctness(self) -> dict[Hyperedge, list[tuple[str, str]]]:
712712

713713
return output
714714

715-
def normalized(self) -> Hyperedge:
715+
def normalise(self) -> Hyperedge:
716716
edge: Hyperedge = self
717717
conn = edge[0]
718718
ar = conn.argroles()
@@ -724,7 +724,7 @@ def normalized(self) -> Hyperedge:
724724
key=lambda role_edge: argrole_order[role_edge[0]],
725725
)
726726
edge = hedge([conn, *[role_edge[1] for role_edge in roles_edges_sorted]])
727-
return hedge([subedge.normalized() for subedge in edge])
727+
return hedge([subedge.normalise() for subedge in edge])
728728

729729
def __add__(self, other: Hyperedge | tuple[Any, ...] | list[Any]) -> Hyperedge:
730730
if isinstance(other, (list, tuple)) and not isinstance(other, Hyperedge):
@@ -1054,7 +1054,7 @@ def check_correctness(self) -> dict[Hyperedge, list[tuple[str, str]]]:
10541054

10551055
return output
10561056

1057-
def normalized(self) -> Atom:
1057+
def normalise(self) -> Atom:
10581058
if self.mtype() in {"B", "P"}:
10591059
ar = self.argroles()
10601060
if len(ar) > 0:

src/hyperbase/patterns/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def common_pattern_argroles(edge1: Hyperedge, edge2: Hyperedge) -> Hyperedge | N
4040
if best_pattern is None:
4141
return None
4242

43-
return best_pattern.normalized()
43+
return best_pattern.normalise()
4444

4545

4646
def common_type(edges: Sequence[Hyperedge]) -> str | None:

src/hyperbase/patterns/counter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _list2patterns(
103103
def _edge2patterns(self, edge: Hyperedge) -> list[Hyperedge]:
104104
force_subtypes = self._force_subtypes(edge)
105105
force_root, _ = self._force_root_expansion(edge)
106-
normalized = edge.normalized()
106+
normalized = edge.normalise()
107107
return [
108108
hedge(pattern)
109109
for pattern in self._list2patterns(

tests/test_hyperedge.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,33 +1066,33 @@ def test_check_correctness_wrong_argroles6(self):
10661066

10671067
def test_normalized_1(self):
10681068
edge = hedge("(plays/Pd.os chess/C mary/C)")
1069-
assert edge.normalized() == hedge("(plays/Pd.so mary/C chess/C)")
1069+
assert edge.normalise() == hedge("(plays/Pd.so mary/C chess/C)")
10701070

10711071
def test_normalized_2(self):
10721072
edge = hedge("(plays/Pd chess/C mary/C)")
1073-
assert edge.normalized() == hedge("(plays/Pd chess/C mary/C)")
1073+
assert edge.normalise() == hedge("(plays/Pd chess/C mary/C)")
10741074

10751075
def test_normalized_3(self):
10761076
edge = hedge("(plays/Pd.os (of/B.am chess/C games/C) mary/C)")
1077-
assert edge.normalized() == hedge(
1077+
assert edge.normalise() == hedge(
10781078
"(plays/Pd.so mary/C (of/B.ma games/C chess/C))"
10791079
)
10801080

10811081
def test_normalized_4(self):
10821082
edge = hedge("(plays/Pd.os.xxx/en chess/C mary/C)")
1083-
assert edge.normalized() == hedge("(plays/Pd.so.xxx/en mary/C chess/C)")
1083+
assert edge.normalise() == hedge("(plays/Pd.so.xxx/en mary/C chess/C)")
10841084

10851085
def test_normalized_5(self):
10861086
edge = hedge("plays/Pd.os.xxx/en")
1087-
assert edge.normalized() == hedge("plays/Pd.so.xxx/en")
1087+
assert edge.normalise() == hedge("plays/Pd.so.xxx/en")
10881088

10891089
def test_normalized_6(self):
10901090
edge = hedge("of/Br.am/en")
1091-
assert edge.normalized() == hedge("of/Br.ma/en")
1091+
assert edge.normalise() == hedge("of/Br.ma/en")
10921092

10931093
def test_normalized_7(self):
10941094
edge = hedge("plays/Pd.{os}.xxx/en")
1095-
assert edge.normalized() == hedge("plays/Pd.{so}.xxx/en")
1095+
assert edge.normalise() == hedge("plays/Pd.{so}.xxx/en")
10961096

10971097
def test_bug_fix1(self):
10981098
edge_str = "((ahead/M/en (would/Mm/en go/P..-i-----/en)))"

0 commit comments

Comments
 (0)