e@1: #!/usr/bin/env python3 e@1: # -*- coding: utf-8 -*- e@1: """ e@1: Created on Wed Sep 26 13:38:38 2018 e@1: e@1: @author: Emmanouil Theofanis Chourdakis e@1: e@1: Problog module for extracting information from a sentence using clausiepy e@1: e@1: """ e@1: e@1: from problog.extern import problog_export_nondet e@1: e@1: import clausiepy as cl e@1: e@1: def remove_apostrophe(string): e@1: # Remove "'"S e@1: if string[0] == "'": e@1: string = string[1:] e@1: if string[-1] == "'": e@1: string = string[:-1] e@1: e@1: return string e@1: e@1: @problog_export_nondet('+str', '-str', '-str', '-str', '-str', '-str', '-str') e@1: def clausie(sent): e@1: e@1: sent = remove_apostrophe(sent) e@1: e@1: clauses = cl.clausie(sent) e@1: e@1: propositions = cl.extract_propositions(clauses) e@1: e@1: result = [] e@1: for proposition in propositions: e@1: ptext = cl.proposition_text(proposition) e@1: e@1: prop = [] e@1: e@1: for p in ptext: e@1: prop.append(" ".join([pp.text for pp in p])) e@1: e@1: result.append(tuple(prop)) e@1: e@1: return result