Advanced usage of StringExample and other Example classes. #75
Replies: 1 comment
-
|
Thanks for the kind words- great use case. Short answer:
How you could do it:
from contextgem import Aspect, Document, DocumentLLM, StringConcept, StringExample
doc = Document(raw_text="<paper_text>")
refs = Aspect(
name="References",
description="APA-style bibliography entries. Ignore signatures, acknowledgements, inline mentions.",
)
authors = StringConcept(
name="APA authors",
description=(
"Return only author names from APA citations. "
"Ignore editors and names appearing only in titles."
),
examples=[
StringExample(content="Balderston, D."),
StringExample(content="Smith, J. A."),
],
)
refs.add_concepts([authors])
doc.add_aspects([refs])
llm = DocumentLLM(model="...", api_key="...")
doc= llm.extract_all(document=doc)
print([i.value for i in doc.aspects[0].concepts[0].extracted_items])
This setup achieves “ignore non-APA mentions” via aspect scoping and “only the author, not editor/title names” via the concept description and examples. Hope this helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, first of all, thanks for this package. It is coming very useful for a task where I'm needing to extract bibliographical references from a set of academic papers.
I am using the
StringExampleclass to extract author names from the bibliography sections of papers.I would like to use the StringExample class to extract author concepts. I was wondering if it would be possible to achieve this:
Balderston, D. (2001). Borges and the art of narrative. In H. Bloom (Ed.), Jorge Luis Borges (pp. 45–68). Chelsea House., then thecontentvalue of the example should be only the author, let's say "Balderston, D.", but not the editor (H. Bloom) or the person appearing in the title (Jorge Luis Borges)Is any of this possible? Can you think of another approach to achieve this? Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions