allenai / allenai/scispacy

fix: which_look_like Hearst pattern uses hyponym twice instead of hypernym

Open
#595 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

## Problem

In `scispacy/hearst_patterns.py`, the `which_look_like` pattern (line 484-498) has a copy-paste bug: the last element in the pattern is `hyponym` when it should be `hypernym`.

**Current (buggy):**
```python
{
"label": "which_look_like",
"pattern": [
det,
hyponym,
punct,
{"LEMMA": "which"},
{"LEMMA": "look"},
{"LEMMA": "like"},
hyponym, # BUG: should be hypernym
],
"position": "last",
},
```

**Expected:** The last element should be `hypernym`, matching all other "last" position patterns in the same file.

## Evidence

Compare with the adjacent `which_sound_like` pattern (lines 499-513), which is structurally identical but correctly uses `hypernym` at the end:

```python
{
"label": "which_sound_like",
"pattern": [
det,
hyponym,
punct,
{"LEMMA": "which"},
{"LEMMA": "sound"},
{"LEMMA": "like"},
hypernym, # correct
],
"position": "last",
},
```

Also compare with `which_be_call` (lines 422-435) and `which_be_name` (lines 438-451), which all correctly end with `hypernym`.

## Impact

The `which_look_like` pattern is a "last" position pattern, meaning the hypernym should appear at the end of the matched phrase (e.g., "cells which look like fibroblasts" — "fibroblasts" is the hypernym). With `hyponym` at the end, the pattern matches but assigns the wrong role to the final noun phrase, causing the hyponym detector to produce incorrect hypernym/hyponym relationships.

## Affected File
- `scispacy/hearst_patterns.py` line 495

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.