ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
297 stars 34 forks source link

Regular expression search function #83

Closed Mezzenilium closed 1 year ago

Mezzenilium commented 2 years ago

Is it possible to use a regular expression search function in a string offered by python, to make a Problog predicate. If so, would it be possible to have an example of such programming?

rmanhaeve commented 2 years ago

I'm not entirely sure what you intend to do here. Could you perhaps clarify with a small example?

Mezzenilium commented 2 years ago

I would like to use a regular expression predicate (Python, Prolog offer this kind of service) like regexp(string, pattern) which searches if the pattern can be found in the string (true if Yes and false if No).

Simplified use in Problog could be such as this :

symptom(“ABD : PAIN, aching, dull pain / liver / colic, gall-stones / malarious disctricts”).

symptom(“ABD : ERUPTIONS / RASH / red itching rash over the region of liver”).

symptom(“CHT : ANXIETY in / Heart, region of / rising and walking, amel”).

0.3::diagnostic(“cirrhosis”) :- symptom(S), regexp(S, “liver”).

query(diagnostic(M)).

rmanhaeve commented 2 years ago

There's no such functionality currently in ProbLog. You could implement this functionality using the Python extern possibility as it is done in this library: https://github.com/ML-KULeuven/problog/blob/master/problog/library/string.py

Mezzenilium commented 2 years ago

Ok, thank you.