How to include a remote vocabulary/namespace to OntModel using Jena? - namespaces

I'm new to Semantic Web and Jena.
I want to generate an ontology from a OntModel in Jena and I need to use vocabulary and ontologies predefined to caracterize my classes and properties.
In Jena, there are default ontologies like RDF, FOAF...So we can specify class and add property to resource like:
ontClass.setSameAs(FOAF.Person);
ontClass.addProperty(FOAF.name, "name");
or
ontProperty.setRange(XSD.xstring);
But how can I refer my ontClass to another vocabulary/ontology that does not exist in Jena (GeoSparql, Geofla, vocabulary that I defined myself,etc.)? Knowing that I can have the URI for these vocabularies?
This question's already been raised in this topic: How to add vocabulary in Jena? which suggests using Jena Schemagen but I can't see how to do it.
Thank you a lot for helping!

I guess one of the option is to import (or read) theses vocabularies/ontologies so that you can use them using Jena Ontology API.
For example (if we assume that your ontModel is named m) you can read the OWL-Time ontology into your model like so :
m.read("http://www.w3.org/2006/time")
and then you can use the elements it defines using Jena's programmatic API :
OntClass instant = dataModel.getOntClass("http://www.w3.org/2006/time#Instant");
If you don't wan't to read the whole ontology within your model, you can also just "create" the necessary ressource / property using its URI :
Property inXSDDateTime = m.createDatatypeProperty(
"http://www.w3.org/2006/time#inXSDDateTime");
Resource resource = m.createResource("someURIForThisRessource");
Statement s = m.createStatement(
resource, inXSDDateTime, m.createTypedLiteral(someValue));
m.add(s);
It should write the result as expected (but, by doing this, you are not loading the axioms of the ontology you are referencing, so you won't be able to reason about it - but according to your comment, I'm thinking maybe that's what you want)

Related

In springdocs, can I define multiple OpenAPI definitions based on tags on the operations

I need to define two different OpenApi definitions using springdocs for the same API within a single application: one for internal developers and one for external developers. The external definition would include some of the operations from the internal definition, but not all of them.
I have looked at using GroupedOpenApi to create the two definitions, but this requires that I move the endpoints that should be excluded from the external definition into a separate RestController and move to an excluded package, which would not be included in the definition for the external developers, but would still be included in the internal definition. I would prefer to structure my code based on the API definition and not based on the security access for my endpoints.
This seems like either SecurityScheme or tags could be used to define which operations are included in a given definition using something like GroupedOpenApi with the paths/packages to include. So for example, I could define the definition for my external API with something like the following:
GroupedOpenApi.builder()
.group("externalGroupName")
.securitySchemesToInclude("externalSchemeName") // this doesn't currently exist
.build();
And then any of the operations that are tagged with a SecurityRequirement with that SecurityScheme would get added to this external definition. So for example I could have the following two endpoints defined within the same RestController:
Would be included:
#SecurityRequirement(name = "externalSchemeName")
#GET
#Path("/pets")
public Response getResponse(){
return null;
}
}
Would not be included:
#SecurityRequirement(name = "internalSchemeName")
#GET
#Path("/pets/internal")
public Response getInternalResponse(){
return null;
}
}
With this approach, it would be nice to provide for include/excluded security schemes similar to paths/package inclusions/exclusions.
This seems like it would currently require a contribution to springdocs unless I am misunderstanding my options for how to create multiple definitions. Is there another way to achieve excluding an operation from only one of the definitions I define without completely hiding that operation from all definitions and without restructuring my packages?
Note that I also would prefer not to maintain a list of all the paths that should be excluded from the group in config if possible as this is error prone and doesn't allow for providing a shared config across multiple services. I would prefer an annotation-driven method similar to the way other swagger customization is done so that I define the config once and then update each resource as it is defined or modified based on an annotation to drive the swagger that is generated.
Using you example, you have other filters (based on paths) of GroupedOpenApi, that you haven't used:
GroupedOpenApi.builder()
.group("internalGroupName")
.pathsToMatch("/pets/internal")
.build();
GroupedOpenApi.builder()
.group("externalGroupName")
.pathsToMatch("/pets")
.packagesToExclude("/pets/internal")
.build();

Where exactly does trainable_variables method belong in Tensorflow?

I'm a newbie in both deep learning and tensorflow and now trying to learn how to implement deep learning codes based on function API (not keras) by following example codes.
Inside the codes I'm looking at, I found out sources saying 'gradients=tape.gradient(loss,model.trainable variables)'
I intuitionally got what trainable variables mean, however in order to understand clearly,I tried to search on tensorflow documentation (which module or class the method belongs to, which are key arguments, etc) ,but I wasn't able to find the information I want. ('trainable variables' method was not in their documentation index and I'm wondering why)
So can anyone please tell me the module/class which trainable_variable method belongs to, and which arguments it takes, and also how it is able to judge and get all the trainable variables from the model ?
The reason you did not find this method is because trainable_variables is not a method, but an attribute/property. The Model class has a trainable_variables attribute, which is not documented officialy. It is inherited from the base class Layer, and to put it shortly, the list (of trainable variables) gets populated as new layers are added, since all layers have an init parameter trainable (this comes from base class Layer too). You can check the source code if you want to: "the source of the property", "adding new weights to layer appends to the list".

JTreeTable model updating

I'm following the example of JTreeTable filesystem2 taken from the sun site http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html#updating_the
My problem is that I can't update my model (and then my JTreeTable)...
In fact I create my model, I pass it to the JTreeTable and all work fine...but I need to modify the model...
I've yet answer a similar question, but now I've changed my code, without find a solution.
The problem is when and how I have to call the method fireTreeNodesChanged()...in the example above is used the method getPath() to retrieve information about the root node...but this is a method of File class..not my case...
Does anyone have a link to a simple code which shows how create a TreeTabelModel (with objects as nodes) and how update it?
FileBrowser is a good example of modeling a hierarchical file system as a tree. While its TreeModel is implemented using DefaultTreeModel, an alternative FileTreeModel is shown here. As mentioned in How to Use Trees: Creating a Data Model "the TreeModel interface accepts any kind of object as a tree node."

Mapping Linq-to-Sql entities to custom domain entities

How could I map my Linq-to-Sql generated entities (DTO’s) to my domain entities? The problem is that I can’t map the associations because they are not of the same type. The DTO’s uses EntitySet and EntityRef and my domain entities uses IList and T.
I’ve looked at some blog post: Ian Cooper's architecting-linq-to-sql-applications-part-5 and digital_ruminations linq-to-sql-poco-support but they don’t fit my needs. I like some kind of generic converter class to handle the mapping.
Now I do something like this:
public IList<Entities.Customer> GetAll()
{
try
{
return _custConverter.Convert(base.GetEntities());
}
But the Convert method only converts the basic properties not the associations.
Any ideas how I can do this the best way?
You might want to look into AutoMapper. It does a great job of mapping properties automatically out of the box and supports extensive customization, such as custom converters, which I think could be used to make Lists out of your EntitySets.
Update:
The official project site and compiled releases are found in CodePlex (same link as above).
Code is SVN hosted at Google Code
Discussiong group is hosted at Google Groups
Accouncement and overview of features at Jimmy Bogart's blog post

What is a language binding?

My good friend, Wikipedia, didn't give me a very good response to that question. So:
What are language bindings?
How do they work?
Specifically accessing functions from code written in language X of a library written in language Y.
Let's say you create a C library to post stuff to stackoverflow. Now you want to be able to use the same library from Python. In this case, you will write Python bindings for your library.
Also see SWIG: http://www.swig.org
In the context of code libraries, bindings are wrapper libraries that bridge between two programming languages so that a library that was written for one language can also be implicitly used in another language.
For example, libsvn is the API for Subversion and was written in C. If you want to access Subversion from within Java code you can use libsvn-java. libsvn-java depends on libsvn being installed because libsvn-java is a mere bridge between the Java programming language and libsvn, providing an API that merely calls functions of libsvn to do the real work.
Okay, now the question has been clarified, this isn't really relevant so I'm moving it to a new question
Binding generally refers to a mapping of one thing to another - i.e. a datasource to a presentation object. It can typically refer to binding data from a database, or similar source (XML file, web service etc) to a presentation control or element - think list or table in HTML, combo box or data grid in desktop software.
...If that's the kind of binding you're interested in, read on...
You generally have to bind the presentation element to the datasource, not the other way around. This would involve some kind of mapping - i.e. which fields from the datasource do you want to appear in the output.
For more information in a couple of environments see:
Data binding in .Net using Windows Forms
http://www.codeproject.com/KB/database/databindingconcepts.aspx
http://www.akadia.com/services/dotnet_databinding.html
ASP.NET data binding
http://support.microsoft.com/kb/307860
http://www.15seconds.com/issue/040630.htm
http://www.w3schools.com/ASPNET/aspnet_databinding.asp
Java data binding
http://www.xml.com/pub/a/2003/09/03/binding.html
Python data binding
http://www.xml.com/pub/a/2005/07/27/py-xml.html
General XML data binding
http://www.rpbourret.com/xml/XMLDataBinding.htm
In Flex (Actionscript 3). Source
A data binding copies the value of a property in one object to a property in another object. You can bind the properties of following objects: Flex components, Flex data models, and Flex data services.
The object property that provides the data is known as the source property. The object property that receives the data is known as the destination property.
The following example binds the text property of a TextInput component (the source property) to the text property of a Label component (the destination property) so that text entered in the TextInput component is displayed by the Label component:
<mx:TextInput id="LNameInput"></mx:TextInput>
...
<mx:Label text="{LNameInput.text}"></mx:Label>
Data binding is usually a simple way to bind a model to user interface components. For example, you have a class with a FirstName property. In flex you could easily bind that property to a textbox by setting the value of the textbox to {Object.FirstName}. Then, every time that FirstName property changes, the textbox will be updated without requiring you to write any code to monitor that property for changes.
Hope that helps.
Matt