From 140ef7e0dabfb06009f4565d8c2d3bdc14daa106 Mon Sep 17 00:00:00 2001 From: Yohei Tamura Date: Fri, 5 Feb 2021 16:22:20 +0900 Subject: [PATCH] update readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f24d35..ba6002a 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,24 @@ original text of tokens obtained in the normalized text. [[(0, 2), (3, 4)], [(6, 9)]] ``` +### `lift_span_index` + +```python +def lift_span_index(span: Tuple[int, int], target_spans: List[Tuple[int, int]]) -> Tuple[Tuple[int, bool], Tuple[int, bool]]: ... +``` + +Examples: + +>>> import textspan +>>> spans = [(0, 3), (3, 4), (4, 9), (9, 12)] +>>> assert textspan.lift_spans_index((2, 10), spans) == (0, 4) + +### `lift_spans_index` + +```python +def lift_spans_index(spans: List[Tuple[int, int]], target_spans: List[Tuple[int, int]]) -> List[Tuple[Tuple[int, bool], Tuple[int, bool]]]: ... +``` + ### `remove_span_overlaps` ```python @@ -86,8 +104,25 @@ positions are same, the longer span will be remained. ```python >>> import textspan >>> spans = [(0, 2), (0, 3), (2, 4), (5, 7)] ->>> textspan.remove_span_overlaps(spans) -[(0, 3), (5, 7)] +>>> assert textspan.remove_span_overlaps(spans) == [(0, 3), (5, 7)] +``` + +### `remove_span_overlaps_idx` + +```python +def remove_span_overlaps_idx(tokens: List[Tuple[int, int]]) -> List[int]: ... +``` + +Remove overlapping spans from given `spans`, and returns remained span indices. + +First, longest spans are remained - if the two spans are overlapped, the +first span will be remained. If the two spans are overlapped and their start +positions are same, the longer span will be remained. + +```python +>>> import textspan +>>> spans = [(0, 2), (0, 3), (2, 4), (5, 7)] +>>> assert textspan.remove_span_overlaps_idx(spans) == [1, 3] ```