Skip to content

Haschunkrefs np#4515

Merged
JacquesCarette merged 4 commits intomainfrom
haschunkrefs-np
Jan 22, 2026
Merged

Haschunkrefs np#4515
JacquesCarette merged 4 commits intomainfrom
haschunkrefs-np

Conversation

@Xinlu-Y
Copy link
Collaborator

@Xinlu-Y Xinlu-Y commented Dec 9, 2025

Contributes to #4476 and #4434.

  • Moved NP data types into NounPhrase.Types to remove the old NP ↔ Sentence circular dependency.

  • Added a real HasChunkRefs instance for NP using the same logic from fill-chunk-refs. NP now reports any referenced UIDs.

  • Exported sentenceRefs so NP (and others later) can reuse the same reference-extraction code.

This sets up the next steps where Reference, NamedIdea, etc. will switch to automatic HasChunkRefs.

JacquesCarette
JacquesCarette previously approved these changes Dec 10, 2025
Copy link
Owner

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, makes sense to me, but I want @balacij 's review as well.

Comment on lines 39 to 49
-- | Convert a noun-phrase structure into a sentence and reuse 'sentenceRefs'.
npStructRefs :: NPStruct -> Set.Set UID
npStructRefs = sentenceRefs . npStructToSentence
{-# INLINABLE npStructRefs #-}

-- | Translate 'NPStruct' into a 'Sentence' so that sentence helpers can traverse it.
npStructToSentence :: NPStruct -> Sentence
npStructToSentence (S s) = Sent.S s
npStructToSentence (a :-: b) = npStructToSentence a Sent.:+: npStructToSentence b
npStructToSentence (a :+: b) = npStructToSentence a Sent.+:+ npStructToSentence b
npStructToSentence (P sym) = Sent.P sym
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What inside of an NPStruct can contain a UID reference? It looks like it would always be empty, no?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, NPStruct can never contain UIDs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I think we can short-circuit the definition of HasChunkRefs NP to mempty with an explanation of why mempty is appropriate.

@JacquesCarette
Copy link
Owner

Not quite sure where this stands? Could I get an update @balacij @Xinlu-Y ?

@Xinlu-Y
Copy link
Collaborator Author

Xinlu-Y commented Jan 20, 2026

Not quite sure where this stands? Could I get an update @balacij @Xinlu-Y ?

I updated HasChunkRefs NP to short‑circuit to mempty and removed the now-unused helper functions. Could you review this PR with #4514 together?

@JacquesCarette JacquesCarette merged commit f465955 into main Jan 22, 2026
5 checks passed
@JacquesCarette JacquesCarette deleted the haschunkrefs-np branch January 22, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants