Skip to content

Commit 2843801

Browse files
committed
feat: Add support for description selbri attachment points in parsing and graph representation
1 parent 3cf0ddc commit 2843801

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

JboParse.hs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ data FreeReturn
5050
evalFree :: Free -> ParseStateM FreeReturn
5151
evalFree (Discursive bt) = do
5252
ap <- getLastAttachmentPoint
53+
-- For sei, the terms in BridiTail3 are PRE-selbri terms (leading terms)
54+
-- but BridiTail3's second argument is normally TAIL terms (after selbri).
55+
-- We fix this by treating them as leading terms via parseSentence.
56+
let fixedParse = case bt of
57+
BridiTail3 sb preTerms -> parseSentence (Sentence preTerms (BridiTail3 sb []))
58+
_ -> parseBTail bt
5359
(FRSides SideDiscursive ap . (\p -> [TexticuleProp p]) <$>) $ evalParseM $
54-
($nullArgs) <$> partiallyRunBridiM (parseBTail bt)
60+
($nullArgs) <$> partiallyRunBridiM fixedParse
5561
evalFree (Bracketed text) = FRSides SideBracketed APBridi <$> evalText text
5662
evalFree (TruthQ kau) = return $ FRTruthQ kau
5763
evalFree _ = return FRIgnored
@@ -172,7 +178,9 @@ parseSelbri3 (ConnectedSB fore con sb sb') = do
172178
parseSelbri3 (ScalarNegatedSB nahe sb) =
173179
mapRelsInBridi (ScalarNegatedRel nahe) <$> parseSelbri3 sb
174180
parseSelbri3 (TanruUnit fs tu2 las) =
175-
advanceArgPosToSelbri >> parseTU tu2 <* parseTerms las <* doFreesInParseM fs
181+
advanceArgPosToSelbri >> parseTU tu2
182+
<* liftParseStateMToParseM (setLastAttachmentPoint APSelbri)
183+
<* parseTerms las <* doFreesInParseM fs
176184
{- Alternative: give tanru units their own scope, with linkargs deleting
177185
- places. Popular amongst lo irci, though contradicts CLL:5.12.11.
178186
- TODO: make it a command-line option?
@@ -663,7 +671,11 @@ mapRelsInBridi f b = (terpProp (\r ts -> Rel (f r) ts) id id) . b
663671
selbriToVPred :: Selbri -> ParseM r JboVPred
664672
selbriToVPred sb = parsedSelbriToVPred $ parseSelbri sb
665673
parsedSelbriToVPred :: BridiM Bridi -> ParseM r JboVPred
666-
parsedSelbriToVPred m = bridiToJboVPred <$> partiallyRunSubBridiM m
674+
parsedSelbriToVPred m = do
675+
b <- partiallyRunSubBridiM m
676+
-- Set APSelbri so frees inside descriptions attach to the description's selbri
677+
liftParseStateMToParseM $ setLastAttachmentPoint APSelbri
678+
return $ bridiToJboVPred b
667679

668680
parsedSelbriToNewSelbri :: BridiM Bridi -> ParseM r Bridi
669681
parsedSelbriToNewSelbri m = closeBridi <$> partiallyRunSubBridiM m

JboTree.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ jboPropsToGraph ps =
6565
in GraphOutput (reverse $ gsNodes finalState) (reverse $ gsEdges finalState)
6666

6767
-- | Record which node an attachment point refers to (overwrite for rightmost/last in tree)
68+
-- | Record which node an attachment point refers to.
69+
-- Only records the FIRST occurrence - this matches parsing order where SEI captures
70+
-- the "current" selbri at the time it's encountered (e.g., zarci in "le zarci sei...")
6871
recordAttachment :: AttachmentPoint -> String -> GraphM ()
6972
recordAttachment ap nodeId = do
7073
st <- get
71-
put $ st { gsAttachmentMap = Map.insert ap nodeId (gsAttachmentMap st) }
74+
case Map.lookup ap (gsAttachmentMap st) of
75+
Just _ -> return () -- Already recorded, keep the first one
76+
Nothing -> put $ st { gsAttachmentMap = Map.insert ap nodeId (gsAttachmentMap st) }
7277

7378
-- | Look up node ID for an attachment point; use bridi root for APUnknown/APBridi or when not found
7479
attachmentTarget :: String -> AttachmentPoint -> GraphM String

0 commit comments

Comments
 (0)