Skip to content

6.2.1 章の誤植 #57

@rmitsuboshi

Description

@rmitsuboshi

6.2.1 章,「スパンの重なる固有表現の存在を判定」において,誤植と思われる箇所があります.
出力結果は変わりませんが,正誤表に載っていないので報告します.

def has_overlap(
    spans: list[tuple[int, int]],
) -> int:
    sorted_spans = sorted(spans, key=lambda x: x[0])
    for i in range(1, len(sorted_spans)):
        if sorted_spans[i-1][1] > sorted_spans[i][0]:
            return 1
    return 0

overlap_count = 0
for split in dataset:
    for data in dataset[split]:
        if data["entities"]:
            spans = [e["span"] for e in data["entities"]]
            overlap_count += has_overlap(spans)
    print(f"{split} におけるスパンが重複する事例数: {overlap_count}")

このコードにおいて overlap_count = 0for split in dataset: の前に来ていますが,これは

for split in dataset:
    overlap_count = 0

ではないでしょうか?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions