how to create a stand-alone swi-plog executable file? - prolog

i'm new to Prolog. i have a .pl like this
male(philip).
male(charles).
male(andrew).
male(edward) .
male(mark) .
male(peter) .
male(mike) .
male(timothy) .
male(william) .
male(harry) .
male(geogre) .
male(louis) .
male(archie) .
male(james) .
female(elizabeth).
female(anne) .
female(zara) .
female(autumn) .
female(sophie) .
female(louise) .
female(sarah) .
female(diana) .
female(camilla) .
female(eugenie) .
female(beatrice) .
female(kate) .
female(meghan) .
female(charlotte) .
married(philip, elizabeth).
married(peter, autumn) .
married(zara, mike) .
married(anne, timothy) .
married(edward, sophie) .
married(andrew, sarah) .
married(charles, camilla) .
married(william, kate).
married(harry, meghan).
parent(philip, charles) .
parent(elizabeth, charles) .
parent(philip, andrew) .
parent(alizabeth, andrew) .
parent(philip, anne) .
parent(elizabeth, anne) .
parent(philip, edward) .
parent(elizabeth, edward) .
parent(mark, peter) .
parent(anne, peter) .
parent(mark, zara) .
parent(anne, zara) .
parent(edward, louise) .
parent(sophie, louise) .
parent(edward, james) .
parent(sophie, james) .
parent(andrew, eugenie) .
parent(andrew, beatrice) .
parent(sarah, eugenie) .
parent(sarah, beatrice) .
parent(charles, william) .
parent(diana, william) .
parent(charles, harry) .
parent(diana, harry) .
parent(kate, geogre) .
parent(kate, charlotte) .
parent(kate, louis) .
parent(william, geogre) .
parent(william, charlotte) .
parent(william, louis) .
parent(harry, archie) .
parent(meghan, archie) .
divorced(anne, mark) .
divorced(charles, diana) .
father(Parent,Child):-male(Parent), parent(Parent,Child).
mother(Parent,Child):-female(Parent), parent(Parent,Child).
child(Child,Parent):-father(Parent,Child); mother(Parent,Child).
son(Child,Parent):-male(Child), child(Child,Parent).
daughter(Child,Parent):-female(Child), child(Child,Parent).
grandparent(GP,GC):-parent(GP,Parent),parent(Parent,GC).
grandmother(GM,GC):-mother(GM,Parent),mother(Parent,GC).
grandfather(GF,GC):-father(GF,Parent),father(Parent,GC).
grandchild(GC,GP):-parent(Parent,GC), parent(GP,Parent).
grandson(GS,GP):-male(GS), parent(GP,Parent),parent(Parent,GS).
granddaughter(GD,GP):-female(GD), parent(GP,Parent),parent(Parent,GD).
spouse(Husband,Wife):-married(Husband,Wife).
husband(Person,Wife):-male(Person),married(Person,Wife).
wife(Person,Husband):-female(Person),married(Husband,Person).
sibling(Person1,Person2):-parent(P,Person1), parent(P,Person2).
brother(Person,Sibling):-male(Person), parent(P,Person), parent(P,Sibling), Person \=Sibling.
sister(Person,Sibling):-female(Person), parent(P,Person), parent(P,Sibling), Person \=Sibling.
aunt1(Aunt, Person):- parent(Parent, Person), sister(Aunt, Parent).
aunt2(Aunt, Person):- parent(Parent, Person), sibling(Parent, Sib), married(Sib, Aunt).
aunt3(Aunt, Person):- married(P, Person), (aunt1(Aunt, P); aunt2(Aunt, P)).
aunt(Aunt, Person):- (aunt1(Aunt,Person); aunt2(Aunt, Person); aunt3(Aunt, Person)).
uncle1(Uncle, Person):- parent(Parent, Person), brother(Uncle, Parent).
uncle2(Uncle, Person):- parent(Parent, Person), sibling(Parent, Sib), married(Sib, Uncle).
uncle3(Uncle, Person):- married(P, Person), (uncle1(Uncle, P); uncle2(Uncle, P)).
uncle(Uncle, Person):- (uncle1(Uncle,Person); uncle2(Uncle, Person); uncle3(Uncle, Person)).
nephew(Person, Uncle):- male(Person), uncle(Uncle, Person).
niece(Person, Aunt):- female(Person), aunt(Aunt, Person).
firstCousin(Person, Cousin):- child(Cousin, AC), (aunt(AC, Person);uncle(AC, Person)).
After i use the command "swipl.exe -o 1812057_18127064_18127205.exe -c 1812057_18127064_18127205.pl --goal=main", i got 1812057_18127064_18127205.exe file in same directory. Then i use "1812057_18127064_18127205.exe" to cmd prompt to run the file but seem like it open and end immediately. What i want is to use this file like a program which you can ask using "?-". Can anyone help me? Thanks alot.

Seems that you forgot to define the "main" predicate in your code !

Related

Stardog raises ConcurrentModificationException upon reasoned query on graph with SWRL Rules

When trying to execute a query with reasoning in a model, I get this error: 000012: com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: ConcurrentModificationException
Ontology model has 2 SWRL rules and is consistent, as it runs fine in Protege (with built-in pellet reasoner). Model has been imported into a stardog rdf model and the query
SELECT ?tse
FROM <urn:test_graph>
{
?tse a :TaperedShaftEnd
}
fails with the above error message.
By deleting the SWRL rules the query runs fine, but of course the model does no longer represent the desired domain. By translating the SWRL rules into stardog native rules, the error appears again.
Reasoning level is set to DL, as SL would imply too high processing times for the target application.
Changing the sameAs flag in the reasoner options does not change the behavior.
Setting the reasoning level to SL, as advised generally in Stardog documentation would solve the problem on this simplified model, but as said would result impractical for the use on the final target application.
May you help me in identifying the root cause and the possible solution?
Did anyone experienced the same issue when dealing with SWRL rules?
Here below the concerned model in turtle format, to easily replicate the issue on a test graph.
Heartful thanks to anyone who may help me with this.
#prefix : <http://api.stardog.com/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix stardog: <tag:stardog:api:> .
#prefix test: <urn:test_graph#> .
<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> a owl:AnnotationProperty .
<urn:test> a owl:Ontology .
:hasTorqueTransmissionConnectionWith a owl:ObjectProperty , owl:FunctionalProperty , owl:InverseFunctionalProperty , owl:SymmetricProperty , owl:IrreflexiveProperty .
:CouplingConnection a owl:Class ;
owl:disjointWith :ShaftEnd .
:ShaftEnd a owl:Class ;
owl:disjointWith :ShaftEnd .
:LeftCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection ;
owl:disjointWith :RightCouplingConnection .
:RightCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection .
:LeftShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd ;
owl:disjointWith :RightShaftEnd .
:RightShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd .
:TaperedCouplingConnection a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :CouplingConnection ;
<tag:stardog:api:rule:content> """IF {
?tse a :TaperedShaftEnd .
?tse :hasTorqueTransmissionConnectionWith ?cc .
?cc a :CouplingConnection .
}
THEN {
?cc a :TaperedCouplingConnection .
}
""" .
:TaperedShaftEnd a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :ShaftEnd ;
<tag:stardog:api:rule:content> """IF {
?tcc a :TaperedCouplingConnection .
?tcc :hasTorqueTransmissionConnectionWith ?se .
?se a :ShaftEnd .
}
THEN {
?se a :TaperedShaftEnd .
}
""" .
:lcc1 a :LeftCouplingConnection , owl:NamedIndividual .
:lse2 a :LeftShaftEnd , owl:NamedIndividual .
:rcc2 a :RightCouplingConnection , :TaperedCouplingConnection , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lse2 .
:rse1 a :RightShaftEnd , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lcc1 .

Convert Query from Codeigniter to Laravel 8

How to write this query in laravel? this query was used in Codeigniter
$ci->db->query("SELECT ratings.rating_id," . $table . "." . $namefield . " as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating
FROM ratings," . $table . " WHERE " . $table . "." . $idfield . " = ratings.rating_id GROUP BY rating_id
ORDER BY rating DESC LIMIT " . $limit . "");
try this
$select_part = $table . "." . $namefield;
DB::table('ratings')
->select('ratings.rating_id',DB::raw("{$select_part} as thenamefield"),DB::raw("ROUND(AVG(ratings.rating_num)2) as rating"))
->crossJoin($table)
->whereRaw("{$select_part} = ratings.rating_id")
->groupBy("rating_id")
->orderByRaw("rating DESC")
->limit($limit)
->get();

eliminate rows from bed file

I produced a bed file like this
Simple_repeat KQ420259.1 45090 45150 (TTAT)n . +
Simple_repeat KQ420259.1 46815 46864 (TG)n . +
Simple_repeat KQ420259.1 47062 47104 (GT)n . +
SINE/tRNA-Deu KQ420259.1 49227 49290 AmnSINE2 . +
Simple_repeat KQ416943.1 112522 112609 (ATAC)n . +
Simple_repeat KQ416943.1 113250 113283 (ACA)n . +
Simple_repeat KQ416943.1 113283 113358 (ACT)n . +
Simple_repeat KQ416943.1 117308 117357 (AC)n . +
Simple_repeat KQ416943.1 117357 117435 (ACAC)n . +
Simple_repeat KQ416944.1 117964 118025 (TATG)n . +
DNA/TcMar KQ416944.1 121083 121651 HSMAR1 . +
Low_complexity KQ416944.1 124929 124970 A-rich . +
and I would to eliminate all the rows containing KQ416943.1 . I don't know if exists a way to do it preserving the order. I'll appreciate your help. Thank you
try this:
grep -v "KQ416943.1" yourfile.txt > output.txt

Get latitude and longitude given name and address

I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude
Can any one suggest which API is best for these,
I already tried
Google API's
Textsearch: this is giving overall city wise. Not particular
eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list
I want exactly
echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Which API will fulfill my requirement?
I tried this also
$url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;

Upside down text

How would you design a program that will take in a string of lower case letters and produce the string upside down?
so if I type in home
i get ǝɯoɥ upside down.
I've tried looking for in the book to get started, but nothing.
Try this, a bit of a brute-force approach but works quite well for uppercase, lowercase and number characters - all other characters are presented just as they come:
(define upside-map '#hash(
(#\a . #\ɐ) (#\b . #\q) (#\c . #\ɔ) (#\d . #\p) (#\e . #\ǝ) (#\f . #\ɟ)
(#\g . #\ƃ) (#\h . #\ɥ) (#\i . #\ı) (#\j . #\ɾ) (#\k . #\ʞ) (#\l . #\ן)
(#\m . #\ɯ) (#\n . #\u) (#\o . #\o) (#\p . #\d) (#\q . #\b) (#\r . #\ɹ)
(#\s . #\s) (#\t . #\ʇ) (#\u . #\n) (#\v . #\ʌ) (#\w . #\ʍ) (#\x . #\x)
(#\y . #\ʎ) (#\z . #\z) (#\A . #\∀) (#\B . #\𐐒) (#\C . #\Ɔ) (#\D . #\◖)
(#\E . #\Ǝ) (#\F . #\Ⅎ) (#\G . #\⅁) (#\H . #\H) (#\I . #\I) (#\J . #\s)
(#\K . #\⋊) (#\L . #\˥) (#\M . #\W) (#\N . #\N) (#\O . #\O) (#\P . #\Ԁ)
(#\Q . #\Ό) (#\R . #\ᴚ) (#\S . #\S) (#\T . #\⊥) (#\U . #\∩) (#\V . #\Λ)
(#\W . #\M) (#\X . #\X) (#\Y . #\⅄) (#\Z . #\Z) (#\0 . #\0) (#\1 . #\Ɩ)
(#\2 . #\ᄅ) (#\3 . #\Ɛ) (#\4 . #\ㄣ) (#\5 . #\ϛ) (#\6 . #\9) (#\7 . #\ㄥ)
(#\8 . #\8) (#\9 . #\6)))
(define (flip-string str)
(list->string
(map (lambda (c)
(hash-ref upside-map c (const c)))
(reverse (string->list str)))))
For example:
(flip-string "Hello World")
=> "pןɹoM oןןǝH"
For reference, I used this conversion table taken from Wikipedia. The above solution has a little wrinkle: I couldn't manage to make it work for the 𐐒 character (flipped B), with unicode value of #\u10412 - because it won't fit in a 16-bit unicode character, so it can't be represented. I wasn't aware that Racket doesn't support characters with an encoding requiring more than 16 bits.
first of all your website must support Unicode, Unicode consists thousands of characters, the first 127 of Unicode are ASCII. It is possible to create text that appears to be upside down by converting character by character to a Unicode sign that looks like the upside down version of the character, for example to convert "6" you can use "9" but the flipped version of "f" is "ɟ", which is a Latin character with Unicode number 607 (hex code 025F)
technically, you need two text area boxes, one for the original text and the other one for the flipped text, also you need a Javascript, use the onkeyup Javascript hook in the first text box to call an upsideDownText() function each time a key is released like this:
<textarea rows="5" cols="70" id="src" onkeyup="upsideDownText()"></textarea>
then do the text processing in the upsideDownText() Javascript function like this:
<script type="text/javascript">
function upsideDownText() {
var srcText = document.getElementById( 'src' ).value.toLowerCase();
var out = '';
for( var i = srcText.length - 1; i >= 0; --i ) {
var ch = srcText.charAt( i );
if( ch == 'a' ) {
out += '\u0250' }
} else if( ch == 'b' ) {
out += 'q' }
} else if( ch == 'c' ) {
out += '\u0254'
// etc....
} else {
out += ch
}
}
document.getElementById( 'dest' ).value = out;
}
</script>
get the content of the text box identified by id="src" and convert the string to lowercase using the toLowerCase() method. Then loop through the string, character by character, starting from the end of the string. A big if-then-else-if block handles the character conversion. finally push the converted string into the text box identified by id="dest", which is the lower text box.
you can find the full list of how doing this step by step from Source twiki.org

Resources