Skip to content

Commit

Permalink
Provide pretty tree format
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhangcs committed Aug 28, 2023
1 parent 752ed6c commit 9bdf967
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions supar/models/const/crf/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import os
from typing import (TYPE_CHECKING, Dict, Iterable, List, Optional, Set, Tuple,
Union)
from typing import (TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set,
Tuple, Union)

import nltk

Expand Down Expand Up @@ -492,3 +492,7 @@ def __repr__(self):

def pretty_print(self):
self.values[-2].pretty_print()

def pretty_format(self, sentence: Any = None, highlight: Any = (), **kwargs) -> str:
from nltk.treeprettyprinter import TreePrettyPrinter
return TreePrettyPrinter(self.values[-2], sentence, highlight).text(**kwargs)

0 comments on commit 9bdf967

Please sign in to comment.