how can we get all object properties of an ontology - owl

I need to get all semantic relations between concepts of an ontology. So while I'm working on an OWL ontology ( People), I'm interested in object properties.
I use codes like the following one with OBJECT_PROPERTY_DOMAIN or OBJECT_PROPERTY_RANGE:
for (OWLClass cls : classes) {
System.out.println("+: " + cls.getIRI().getFragment());
System.out.println(" \tObject Property Domain");
for (OWLObjectPropertyDomainAxiom op : ontology.getAxioms(AxiomType.OBJECT_PROPERTY_DOMAIN)) {
if (op.getDomain().equals(cls)) {
for(OWLObjectProperty oop : op.getObjectPropertiesInSignature()){
System.out.println("\t\t +: " + oop.getIRI().getFragment());
}
}
}
}
But I need to get the whole relation, I mean the expression that links the domain with the range and the object property something like : "Person drives car" exactly like in the image
please if you have any idea help me; Thank you

Related

Extjs 6.5 - finding an association type (hasOne, hasMany, belongsTo, etc)

I upgraded my application from Sencha Touch 2.4 to ExtJs 6.5.3.
On Sencha Touch 2.4, there is a function for the Association (Ext.data.association.Association) by the name of getType() that returns the association-type as a string, for example: "hasOne".
as seen for example, in here (the Model source code of Sencha Touch 2.4):
for (i = 0; i < associationCount; i++) {
association = associations[i];
associationName = association.getName();
type = association.getType();
allow = true;
if (associationType) {
allow = type == associationType;
}
if (allow && type.toLowerCase() == 'hasmany') {
In my project, by understanding if the association type is hasmany, hasone or belongsto I can "choose" what type of SQL query to create (not originally written by me, but that's a large project and I can't contact the original developer), so that's a must for me.
I try to look into the Extjs 6 / 6.5 documentation and couldn't find anything.
Seems like it was deprecated a long time ago.
I was thinking about inserting the "type" inside the model as an object of models and types, for example:
{
'MyProject.model.Receipt': 'hasone',
'MyProject.model.Order': 'hasmany',
'MyProject.model.invoice': 'belongsto',
...
}
and then try to access it from the model itself and find the type by the association "parent" model.
It feels like a risk and an overkill for such a (suppose-to-be) easy task.
I tried to also find online for solutions but it looks like no one ever tried to find a solution for something like that.
Thank you
The associations property on a record is a bit tricky and a little obscured from us as developers. If you use the inverse property in your associations, they'll sometimes appear in the associations property, which is problematic. I've raised an issue with Sencha Support asking for a reliable method on returning the actual associations on a record, but I've also come up with an interim solution to determine if they're truly an association. I've extended this idea to maybe something that might help you with the types? But you'll have to test this out to determine if it actually works for you... I only use hasOne and hasMany in my code, so I don't know if this is right for belongsTo.
Here's the Fiddle, and here's the code:
Ext.override(Ext.data.Model, {
isActualAssociation: function (role) {
var isThing = !role.instanceName || role.fromSingle;
if (!isThing) {
console.log('found weirdo', role)
}
return isThing;
},
getAssociationType: function (association) {
if (association.fromSingle) {
return 'hasOne';
}
else if (association.storeName) {
return 'hasMany';
}
return 'belongsTo';
}
});

Get a data property value of an individual - OWL API

I'm trying to get the data property value of my individual from an existing ontology. I'm using OWL API.
For example the name of my inidividual :
`
Set<OWLLiteral> literalA = John.getDataPropertyValues(name, ontology);
I've got this error :
> The method getDataPropertyValues(OWLDataPropertyExpression,
> OWLOntology) is undefined for the type OWLIndividua
`
This should get me : "John"
I've checked on this website the methods I can use to retrieve the information Interface OWLIndividual and it gave me getDataPropertyValues. Unfortunately, I can't make it work.
Any idea ?
Thanks for your help

Mongo query item from subarray, having trouble

I'm relatively new to mongodb, and I came into this company's set up that had the database already set up and running. It looks to me like the structure of this "array" isn't actually a proper array. They are saving info that I need in "offer_info_array" - which then has a nested array with an "offer id" which changes a lot between records, and then nested inside that is the info that I need to select. Here is an example of a record.
{
"_id" : ObjectId("52041af3bbf8057203000004"),
"offer_info_array" : {
"128" : {
"affid" : "68",
"s1" : "YJF"
}
},
"city" : "Cleveland",
"state" : "OH",
"zip" : "44111"
}
So from a whole db of records like this one, I need to find all records that have the "affid" of "68" - I realize this database is not structured correctly, but there's not much I can do about that for records that already exist. The "128" is the offer id that varies from record to record.
If anyone has any insight and can help me out with this, I would greatly appreciate it. Thank you!
You can use $where operator which accepts JavaScript function:
db.items.find({$where: function() {
for(var key in obj.offer_info_array)
if(obj.offer_info_array[key].affid == 68)
return true;
return false; }})
This function looks for properties of offer_info_array object and gets value of property by key. Then we verify if property value has affid property equal to 68. If yes, we return true which means objects matches our query. If there is no properties with affid equal to 68, we return false.
Keep in mind, that $where operator do not use indexes.

How to check if a db entry contains something using ObjectQuery(Of T) Class

I am using the new mvc4 ajax controller template and I don't know how to add a search to the database query that they have.
Let's say I have a model called Article, here is what the controller contains by default:
ObjectQuery<Article> articles = (db as IObjectContextAdapter).ObjectContext.CreateObjectSet<Article>();
articles = articles.OrderBy("it." + orderBy + (desc ? " desc" : ""));
This works fine, but I am not familial with IObjectContextAdapter and I don't know how to add a search (ie. to see if a Article contains a term.) Normally I would have something like this:
var articles = from a in db.Articles.ToList()
select a;
if(!String.IsNullOrEmpty(search))
{
articles = articles.Where(a => a.Title.ToLower().Contains(search.ToLower())
|| a.FullArticle.ToLower().Contains(search.ToLower())
|| a.TagsAndKeywords.ToLower().Contains(search.ToLower()));
}
switch(orderBy)
{
case "TimeStamp":
if(desc)
articles = articles.OrderByDescending(a => a.TimeStamp);
else
articles = articles.OrderBy(a => a.TimeStamp);
break;
case "Title":
...
}
Obviously the new way of doing this is more succinct so I would like to stick with this. I tried combining them, using the linq query to populate the var articles, but then I am not able to use the order by part, .OrderBy("it." + orderBy + (desc ? " desc" : "")).
So my question is what is the best way to search through my database? And what exactly is this .OrderBy("it." + orderBy + (desc ? " desc" : "")) doing? I'm only familial with using OrderBy with linq.
Edit
After a lot of reading I have a better understanding of what is going on, although I still can't get this to work.
According to this it seems like I need something similar to this:
articles = articles.Where("it.Title = #searchString");
although I think this would only work if searchString matched the title exactly. While I still don't quite understand what this is doing, I think it uses sql expressions so I thought that this may work:
articles = articles.Where("it.Title like '%#searchString%'");
But none of this worked, and I am only shooting in the dark since I am unfamiliar with this.
The most succinct way to query your model without changing mvc4 template code is to create an IQueryable object and query it, like this:
ObjectQuery<Article> articles = (db as IObjectContextAdapter).ObjectContext.CreateObjectSet<Article>();
articles = articles.OrderBy("it." + orderBy + ((bool)desc ? " desc" : ""));
IQueryable<Article> iArticles = articles;
if(!String.IsNullOrEmpty(search))
iArticles = iArticles.Where(a => a.Title.Contains(search) ||
a.FullArticle.Contains(search));
Response.AppendHeader("X-Total-Row-Count", iArticles.Count().ToString());
return PartialView(iArticles.Skip(start).Take((int)itemsPerPage));
This keep the entries in the correct order, and be sure to return the new iArticles instead of the old Articles.

Unable to find view for viewmodel?

I'm trying to make a composition UI for a small website.
My building tree looks like this:
Shell (Conductor.Collection.AllActive)
Contains multiple IPod's (you can view them as small widgets)
1 Pod is a PagePod.
This last one is of sort IPodConductor, so a combination of a Screen ( the pagepod ) containing IPage (like MainPage, ContactPage .. )
My whole construction can find all my viewmodels and views following Caliburns convention, but not my MainPage.
The error is as following:
"Cannot find view for Gymsport.Client.Pages.Main.MainPageViewModel"
My structure to the view is as following:
Gymsport.Client.Pages.Main.MainPageView
Following the convention, caliburn should be able to locate my view... but it doens't.
Anybody any tips on to figure out or pointers for debugging this error.
Thanks in advance.
In C.M, there is additional logic for finding Views concerning words like Page, etc. (see here).
So you can either change your views to match the rules in C.M, remove word Page from your view models, or you can enforce custom simple view location with something like that:
ViewLocator.LocateTypeForModelType = (modelType, displayLocation, context) =>
{
var viewTypeName = modelType.FullName.Substring(
0,
modelType.FullName.IndexOf("`") < 0
? modelType.FullName.Length
: modelType.FullName.IndexOf("`")
);
viewTypeName = viewTypeName.Replace("Model", string.Empty);
if (context != null)
{
viewTypeName = Regex.Replace(viewTypeName, "View$", string.Empty);
viewTypeName += "." + context;
}
var viewType = (from assembly in AssemblySource.Instance
from type in assembly.GetExportedTypes()
where type.FullName == viewTypeName
select type).FirstOrDefault();
return viewType;
};

Resources