Skip to content

Example: Lives & Knows

Verena Blaschke edited this page Jun 29, 2022 · 10 revisions

PSL-Infrastructure & PSL-RAGviewer demo

A very simple project demonstrating how to use the psl-infrastructure and psl-ragviewer packages.

This demo project is based on a PSL problem for inferring whether a pair of people knows each other based on information whether they share the same address.

Classes

Predicates

We have two predicates:

  • LivesPred: Lives(P,L) -- "Person P lives at address L"
  • KnowsPred: Knows(P1,P2) -- "Person P1 knows person P2"

Both predicate classes contain templates for describing a ground atom as a noun phrase ("Alice knowing Bob") or a sentence ("Alice probably knows Bob").

The SampleConstantRenderer provides pretty-print functions for some of the atom arguments.

Rules

We have one weighted logical rule and one arithmetic constraint:

  • LivesToKnowsRule: 1.0: Lives(P1,L) & Lives(P2,L) & (P1 != P2) -> Knows(P1,P2) -- "If there is evidence that two people live at the same address, this makes it more likely that they know each other."
  • KnowsSymmetryConstraint: Knows(P1,P2) = Knows(P2,P1). -- "The knows relationship is symmetric."

Each rule overrides the method generateExplanation to provide explanation templates that match the rule logic more naturally than the default explanations might.

PslProblem & IdeaGenerator

TODO

Putting it all together

TODO

Clone this wiki locally