Prolog Doing a Query - database

This is directly from a tutorial online, and I get a top down level design error, help?
employee(193,'Jones','John','173 Elm St.','Hoboken','NJ',
12345,1,'25 Jun 93',25500).
employee(181,'Doe','Betty','11 Spring St.','Paterson','NJ',
12354,3,'12 May 91',28500).
employee(198,'Smith','Al','2 Ace Ave.','Paterson','NJ',
12354,3,'12 Sep 93',27000).
Given these basic relations (also called extensional relations), we can define other relations using Prolog procedure definitions to give us answers to questions we might have about the data. For example, we can define a new relation containing the names of all employees making more than $28,000:
well_paid_emp(First,Last) :-
employee(_Num,Last,First,_Addr,_City,_St,_Zip,_Dept,_Date,Sal),
Sal > 28000.

It could be that you are using a Prolog system which shows a singleton warning for well_paid_emp/2.
Not all Prolog systems allow _<Capital><Rest> as singletons, i.e. variables that occur only once in a rule.

Related

Using Watson as a testing tool

I'm wondering about using Watson assistant as a simple tool for informal testing of medical students. I'm a bit confused as to whether this is an appropriate use. I have played around but am quite stuck.
I have a symptom X in mind, that, if the user asks about, Watson would spit out 3 questions sequentially, and test the users responses against some specific terms.
These questions look like
1. how much water does a 'symptom X' patient drink ?
Watson would take their input and compare it against definition somehow
what are the 3 diseases that can manifest with 'symptom X' ?
Watson would then take their input and compare it against the known list
what tests should be run immediately on a patient presenting with 'symptom X' ?
Watson would then compare their input to known list
Am I way off base with how I am using trying to use it?
-So far I have set up
intent = test_me (eg Can you test me)
#entity = symptom X
My first dialog node is if #test_me and #symptom X ->
'Sure, I can test you on symptom X'. I'm going to ask you 3 questions on this.
Pause.
Response -> how much water does a 'symptom X' patient drink ?
Their response would be along the lines of 'more than 100ml/kg/day'
How can I evaluate this response?
Is what I'm trying to do beyond the scope of a chatbot / WA?
The simple way would be by adding NLU (Natural Language Understanding) to the solution. If the language is English, NLU by default would get the 100ml as a Quantity and you can also use the syntax enchantment, if you need to apply a different rule when the user writes things like "more".
If there are more complexity to the sentences and NLU by default is not enough, you can train a custom model using WKS (Watson Knowledge Studio) and use it with NLU. The same applies for languages where the default model doesn't give you enough info.
NLU also have some understand of a good number of medical terms, that seems to be of use for your solution.
If you need to do it using only Watson Assistant, the only solution I can imagine is to use regex to get the number and the type (ml/day/km/etc). Something like "(\d+)(\w{2})"

RDF - citations for predicates

I'm attempting to create/implement an RDF-schema for historical data: setting up a base schema is simple, but I've run into a roadblock when trying to add a verifiable source for each claim (predicate).
For example, it's relatively easy to declare 'Alexander (subject) has a brother (predicate) Robert (object)'... but I would like that claim (that is the whole) that Robert was indeed Alexander's brother to be cited, with a link to the original source document, if possible.
The best I could come up with is a 'doubled triplet' schema:
Alexander -> has_a_brother -> Robert
Alexander -> has_a_brother_source -> 'http://sourcedocumentserver.com/blablabla'
Alexander -> has_a_brother_source -> 'http://sourcedocumentserver2.com/blablabla'
Alexander -> has_a_brother_source -> 'http://sourcedocumentserver3.com/blablabla'
Is there a better way to go about this?
PS: this problem is a bit different than a 'predicate variable' (like the question that this one was said to replicate), but in this 'citation needed' circumstance, every single predicate in the database would need a secondary description/label/name (and that's even without imagining multiple citations, attribution data, etc.).
The best I could find was transforming every 'citation needed' predicate into a named graph (with multiple RDF triplets) that would contain the object normally directly joined (if no citation were required).

In OWL, is it possible to query a class that does not have a property?

In OWL, is it possible to query a class that does not have a property?
Suppose I have an object property R and I want to retrieve all classes that do not have the property R. Also, suppose that I have already closed all classes with closures.
I was trying this:
suppose the propety in question is hasProperty, my query was this
hasProperty only Nothing
But it doesn't work
What do you mean by "class that does not have a property"?
Semantically, a class is a set of individuals and a property is a set of pairs of individuals. Given these two sets, what do you mean by "class has / has not a property"?
Regarding your example query
hasProperty only Nothing
lets rewrite it a bit so that we can think about it in natural language. This gives better intuition about the meaning of this query.
First lets rename hasProperty to follows (or whatever English verb), then we have:
follows only Nothing
This is semantically equivalent to
follows only (not Thing)
which is semantically equivalent to
not (follows some Thing)
Now we have gotten rid of the only which is a confusing part of OWL and is better avoided. So now we can verbalize the query in English as:
those who do not follow anything
or
who does not follow anything?
or more formally
which individuals of the ontology are known
not to have a follow relationship to any other individual
E.g. if your ontology states that
John does not follow Mary.
John does not follow himself.
Every individual in the ontology is either John or is Mary.
then John will be the answer to the above query.
You can also get a named class as the query answer if the asked restriction holds for a (named) group of individuals. In any case, the following must hold: if you asserted that the answer (or a member of it) does have a follow-relation to some individual then it would render the ontology inconsistent.
OWL does not have any means for querying the data. SPARQL is used for that. So the SPARQL query to find all class definitions that do not have the property :R would be:
SELECT ?cls
WHERE {
?cls a owl:Class .
FILTER NOT EXISTS {?cls :R ?o}
}

What's the difference between "Exchange Legacy Distinguished Name" and "Active Directory Distingushed Name"?

I'm a little confused by these two terms: "Legacy Distinguished Name"(Legacy DN) and "Distingushed Name"(DN).
The first term Legacy DN seems only for Exchange, while the latter DN is only mentioned for Active Directory.
They are obviously not in same format:
DN is like: CN=Morgan Cheng, OU= SomeOrg, DC=SomeCom, DC=com
LegacyDN is like: /o=SomeDomain/ou=SomeGroup/cn=Recipients/cn=Morgan Cheng
I am still not clear what exactly the differce is. Are they two totally differnt stuff? or just same info represented in two different forms?
And, why is it called "Legacy"? If it is legacy, something must be new, right?
Hope some AD and Exchang experts can give me some inputs.
In Exchange 5.5, Exchange was assigning distinguished names to accounts and mailboxes (Obj-Dist-Name). When Active Directory came along, Exchange 2000 and later would use its distinguished names instead. In order to preserve backwards compatibility, migration from Exchange 5.5 to Exchange 2000 carried over the old DNs into the legacyExchangeDN attribute of ActiveDirectory.
Some applications continue to refer to Obj-Dist-Name. To preserve compatibility with these applications, later exchange versions synthesize a legacyExchangeDN value even for objects that have not been migrated from Exchange 5.5. The RUS automatically sets it to some value, apparently to the same value as the distinguishedName in your case.
The "new" way (since 2000) is to refer to objects by distinguished name, not Obj-Dist-Name.

SSIS/VB.NET Equivalent of SQL IN (anonymous array.Contains())

I've got some SQL which performs complex logic on combinations of GL account numbers and cost centers like this:
WHEN (#IntGLAcct In (
882001, 882025, 83000154, 83000155, 83000120, 83000130,
83000140, 83000157, 83000010, 83000159, 83000160, 83000161,
83000162, 83000011, 83000166, 83000168, 83000169, 82504000,
82504003, 82504005, 82504008, 82504029, 82530003, 82530004,
83000000, 83000100, 83000101, 83000102, 83000103, 83000104,
83000105, 83000106, 83000107, 83000108, 83000109, 83000110,
83000111, 83000112, 83000113, 83100005, 83100010, 83100015,
82518001, 82552004, 884424, 82550072, 82552000, 82552001,
82552002, 82552003, 82552005, 82552012, 82552015, 884433,
884450, 884501, 82504025, 82508010, 82508011, 82508012,
83016003, 82552014, 81000021, 80002222, 82506001, 82506005,
82532001, 82550000, 82500009, 82532000))
Overall, the whole thing is poorly performing in a UDF, especially when it's all nested and the order of the steps is important etc. I can't make it table-driven just yet, because the business logic is so terribly convoluted.
So I'm doing a little exploratory work in moving it into SSIS to see about doing it in a little bit of a different way. Inside my script task, however, I've got to use VB.NET, so I'm looking for an alternative to this:
Select Case IntGLAcct = 882001 OR IntGLAcct = 882025 OR ...
Which is obviously a lot more verbose, and would make it terribly hard to port the process.
Even something like ({90605, 90607, 90610} AS List(Of Integer)).Contains(IntGLAcct) would be easier to port, but I can't get the initializer to give me an anonymous array like that. And there are so many of these little collections, I'm not sure I can create them all in advance.
It really all NEEDS to be in one place. The business changes this logic regularly. My strategy was to use the udf to mirror their old "include" file, but performance has been poor. Now each of the functions takes just 2 or three parameters. It turns out that in a dark corner of the existing system they actually build a multi-million row table of all these results - even though the pre-calced table is not used much.
So my new experiment is to (since I'm still building the massive cross join table to reconcile that part of the process) go ahead and use the table instead of the code, but go ahead and populate this table during an SSIS phase instead of calling the udf 12 million times - because my udf version just basically stopped working within a reasonable time frame and the DBAs are not of much help right now. Yet, I know that SSIS can process these rows pretty efficiently - because each month I bring in the known good results dozens of multi-million row tables from the legacy system in minutes AND run queries to reconcile that there are no differences with the new versions.
The SSIS code would theoretically become the keeper of the business logic, and the efficient table would be built from that (based on all known parameter combinations). Of course, if I can simplify the logic down to a real logic table, that would be the ultimate design - but that's not really foreseeable at this point.
Try this:
Array.IndexOf(New Integer() {90605, 90607, 90610}, IntGLAcct) >-1
What if you used a conditional split transform on your incoming data set and then used expressions or something similar (I'm not sure if your GL Accounts are fixed or if you're going to dynamically pass them in) to apply to the results? You can then take the resulting data from that and process as necessary.

Resources