Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Conversation

@calyptobai
Copy link
Contributor

Depends on #811.

Some LLM articles contain a final paragraph like so:

The `ScopeGraph` struct also provides methods for inserting local scopes, local definitions, hoisted definitions,
global definitions, local imports, and references into the graph. These methods are used to build the scope
graph based on the provided source code. [^summary]: Scope graphs are built using the `build_scope` method
of the `ResolutionMethod` enum. This method uses a specific resolution function (like `scope_res_generic` for
the `Generic` resolution method) to create a `ScopeGraph` and populate it based on the provided query, root
node, source, and language. The `ScopeGraph` represents a graph of scopes and names in a single syntax tree,
and provides methods for inserting different types of nodes into the graph.

In this instance, the LLM has accidentally attached the summary to the end of the final markdown paragraph, instead of putting the summary (which is a markdown footnote definition) into its own block. To correct for this, we utilize comrak to examine all top-level Paragraph nodes, and extract a summary, if one is found in plain text.

Note: This implementation will work for cases where a code snippet contains [^summary]: ..., and it will also work when there is inline code, such as article that writes: Summaries are created by attaching `[^summary]:` to. These complex test cases are accounted for with the addition of a new unit test.


Closes BLO-1369

@calyptobai calyptobai force-pushed the enforce-newline-summary branch from 8a95498 to aea1c09 Compare August 4, 2023 19:30
@ggordonhall ggordonhall requested a review from oppiliappan August 7, 2023 08:43
@calyptobai calyptobai force-pushed the enforce-newline-summary branch from aea1c09 to 2ed1fbc Compare August 7, 2023 15:27
@calyptobai calyptobai marked this pull request as ready for review August 7, 2023 15:28
@ggordonhall ggordonhall self-requested a review August 7, 2023 17:03
Copy link
Contributor

@ggordonhall ggordonhall left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ggordonhall ggordonhall merged commit ab2b874 into main Aug 8, 2023
@ggordonhall ggordonhall deleted the enforce-newline-summary branch August 8, 2023 07:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants