Skip to content

Commit 1899a21

Browse files
Added n_steps function
1 parent 8a9be28 commit 1899a21

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/python_mg/_lib_name.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class SyntacticStructure:
2727
def log_prob(self) -> float:
2828
"""Return the log probability."""
2929

30+
def n_steps(self) -> int:
31+
"""Returns the number of steps in the derivation of this structure"""
32+
3033
def contains_lexical_entry(self, s: str) -> bool:
3134
"""Check if this structure contains a specific lexical entry (formatted as an MG entry, will raise an error if unparseable)"""
3235

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ impl PySyntacticStructure {
8383
self.prob.into_inner().exp()
8484
}
8585

86+
fn n_steps(&self) -> usize {
87+
self.rules.n_steps()
88+
}
89+
8690
fn latex(&self) -> String {
8791
let lex = self.lex.get();
8892
self.rules.to_tree(&lex.lexicon).to_latex()

0 commit comments

Comments
 (0)