Repository navigation
spaCy for educational rule extraction (traffic rules use case) #13910
Replies: 1 comment
|
Yes. For a review queue, I’d start with a sentence splitter and a small list of phrases. Return the whole source sentence and its character offsets. The reviewer can then see negation and exceptions that a matched word alone would lose. Here’s a runnable English example. It needs spaCy but no downloaded language model. import spacy
from spacy.matcher import PhraseMatcher
nlp = spacy.blank("en")
nlp.add_pipe("sentencizer")
cues = PhraseMatcher(nlp.vocab, attr="LOWER")
cues.add("MODAL", [nlp.make_doc(p) for p in ("must", "forbidden", "required to")])
text = "You MUST stop. You are not required to stop here. Ice is slippery."
for sent in nlp(text).sents:
if cues(sent):
print(sent.start_char, sent.end_char, sent.text)This returns To check what the matcher misses, manually read one full lesson and compare its rules with the suggestions. For example, this starter list will miss “Parking is prohibited.” That gives you evidence for which phrases to add next. Sentencizer · PhraseMatcher Tested with Codex on spaCy 3.8.18. |
Uh oh!
There was an error while loading. Please reload this page.
Hi spaCy team,
I am working on an LMS system where lessons contain long explanatory text
(traffic rules / driving laws).
My current design:
Question:
Can spaCy be used to automatically SUGGEST fact candidates from lesson content
(e.g. sentences containing "must", "forbidden", "required")?
I do NOT want to auto-save facts without human review.
I am looking for best practices or pipelines using spaCy for this task.
Any guidance or examples would be appreciated.
Thank you!
All reactions