James Simmons
James Simmons

Reputation: 1

Clingo beginner looking for some guidance

I am very new to Clingo and I am having trouble developing an OR condition to work. My idea is to create a rule that find a mention of the word "burner" in the content OR the App (basically combining the "contains_burner_content" and "contains_burner_app"). I have tried using 'not' but it doesnt seem to work.

I am also trying to see if its possible to use some sort of wildcard in the content to find any mention of the word "burner" rather than exact, however everything I have seen suggests this isnt possible.

Below is my code that I have developed so far.

activity("Not", "unknown", "910-248-4781", "2022-12-01", "12:16", "Login", "burner").
activity("Burner", "unknown", "910-248-4781", "2022-12-01", "12:19", "Created My Burner number", "unknown").
activity("Burner", "unknown", "910-248-4781", "2022-12-01", "13:28", "Received Picture", "OG use of Cookies").
activity("Burner", "unknown", "910-248-4781", "2022-12-01", "13:30", "Saved Picture", "OG use of Cookies").
activity("Burner", "unknown", "910-248-4781", "2022-12-01", "13:31", "Sent Message", "burner").

% Rule to identify activities where 'Content' contains the word "burner"
contains_burner_content(App, ContactID, PhoneNumber, Date, Time, Action, Content) :-
    activity(App, ContactID, PhoneNumber, Date, Time, Action, Content),
    contains_word_burner(Content).
    
contains_burner_app(App, ContactID, PhoneNumber, Date, Time, Action, Content) :-
    activity(App, ContactID, PhoneNumber, Date, Time, Action, Content),
    contains_word_burner(App).
    
contains_word_burner(Content) :- Content = "burner".
contains_word_burner(App) :- App = "Burner".

#show contains_burner_content/7.
#show contains_burner_app/7.

I am hoping to combine my two rules into one, also any help in the wildcard would be greatly appreciated. :)

Upvotes: 0

Views: 140

Answers (1)

Duda
Duda

Reputation: 3746

Good start.

First, I want to start pointing out that the 2 rules

contains_word_burner(Content) :- Content = "burner".
contains_word_burner(App) :- App = "Burner".

are actually the same and you can even shorten it to the following (assuming capital letters do not matter)

contains_word_burner("burner").

About the or: You can implement it using cardinality constraints:

contains_burner_content(App, ContactID, PhoneNumber, Date, Time, Action, Content) :-
    activity(App, ContactID, PhoneNumber, Date, Time, Action, Content), 
    1{contains_word_burner(Content) ; contains_word_burner(App)}.

this reads: for every activity where at least one of contains_word_burner(Content) and contains_word_burner(App) holds, contains_burner_content holds as well for the same arguments.

To read more about the syntax you can consult the slides from potassco.

Upvotes: 0

Related Questions