How can RDF be defined using RDFS and OWL? - uri

I just browsed this uri http://www.w3.org/1999/02/22-rdf-syntax-ns and found this prefix declarations:
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix dc: <http://purl.org/dc/elements/1.1/> .
if this uri supposed to define rdf? How can we use rdfs and owl in this document if we all know that rdf is the basis of those languages?

Note that in this example RDFS and OWL are purely namespaces - there is no hierarchy of classes or properties, nor any class restrictions or other RDFS or OWL constructs.
The basic definitions are not included in actual RDFS or OWL ontologies - this is not a default top level ontology (for example, the label for rdf:type cannot be found searching in an RDFS ontology, unless it contains explicitly these triples.
You could consider this example a metaontology - looks more like a convenient format to hold a few basic information, which could be embedded in the specs instead.

Related

tagging 'plain-language' vs technical definition in a SKOS vocabulary

I am trying to implement a technical glossary in SKOS (which uses BCP47) that has both a 'technical' scientific definition as well as a more accessible 'plain-language' definition. I have not been able to find an appropriate solution
Is there a best-practice for this ?
There is no specific level of technicality expressible through SKOS, but you may look into other vocabularies to find a property that would suit your needs, for example on Linked Open Vocabularies.
As for using such a property, I think the easiest would be to use rdf:CompoundLiteral to describe the literal itself:
<resource>
skos:prefLabel [
a rdf:CompoundLiteral ;
rdf:value "layman term" ;
rdf:language "en" ;
:isTechnical false
] ;
skos:altLabel [
a rdf:CompoundLiteral ;
rdf:value "technical term" ;
rdf:language "en" ;
:isTechnical true
] ;
Just remember that SKOS has an integrity condition such that only one skos:prefLabel may be present on a resource for a given language tag.
If you absolutely must use BCP47 (for language ranges, more restrictive formats etc.), I have tried to find a way to express what you want using existing standards and extensions, but I wasn't successful. In that case, the only remaining possibility is to use a private-use subtag, like "term"#en-x-tech.

How to set up URIs for a classification that has new editions

I have a classification that at regular times has a new edition. Concepts are added, the structure may change, or properties like classification codes may change, but most concepts stay and should have stable uri's. I want to know what is the best way of uri construction to deal with these issues.
My setup tries to conform to the rule that good base uri's and concept uri's don't contain version or datetime information. The concepts themselves can always be referred to by the same identifier, unless there is a change in meaning. Then a new concept has to be created. There can be new concepts or changes to the properties of an existing concept. This is how I set it up.
concept uri's: <http://example.org/myschema/concept/1>
schema uri: <http://example.org/myschema/2018>
schema uri next version: <http://example.org/myschema/2020>
#base <http://example.org/myschema/> .
#prefix dcterms <http://purl.org/dc/terms/> .
#prefix skos <http://www.w3.org/2004/02/skos/core> .
Example of a concept:
<http://example.org/myschema/concept/1> a skos: concept ;
skos:inScheme <http://example.org/myschema/2018>;
skos:prefLabel "nameless dog";
skos:notation "AB251".
In the next version the classfication code has changed:
<http://example.org/myschema/concept/1> a skos: concept ;
skos:inScheme <http://example.org/myschema/2020>;
skos:prefLabel "nameless dog";
skos:notation "AB254";
skos:changeNote "the classification code has changed from AB251 in 2018 to AB254 in 2020 due to addition of new concepts";
dcterms:modified 2020-08-19.
I want to know what happens when someone has referenced http://example.org/myschema/concept/1 with the prefLabel and the uri, possibly even with the classification code from 2018, when in 2020 there is a new version live. The 2018 version is also still live. Maybe this should depend upon my server setup, so that I always return the latest version when none is specified. I would like to keep giving access to the older classification version, but not create confusion.

DBpedia getting page category using sparql

I am using DBpedia to getting page category using SPARQL in R. However, there are having some problems on it. Source code I am using:
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?categoryUri ?categoryName WHERE {
<http://dbpedia.org/resource/xxx> dcterms:subject ?categoryUri.
## xxx are random words (e.g. Agree, Film, Work, Plan...)
?categoryUri rdfs:label ?categoryName.
FILTER (lang(?categoryName) = "en")
}
The problems are:
Category cannot be retrieved if the words need to be redirected (e.g. Agree -> Agreement)
Disambiguation pages cannot be used from the above source code, because there are so many sub-pages within the category of word (e.g. Work)
So, how can I resolve the above problems? I am really appreciate if anyone can offer your help!!!
SPARQL does only do what you write, so there is no magic behind. If some resource :s is possibly connected to others by a property :p, add a triple pattern :s :p ?o . - sometimes you might even consider to use a property path in case of the resolution of the transitive closure of :p, i.e. :s :p* ?o ..
With redirects resolved:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT * WHERE
{ <http://dbpedia.org/resource/Agree> (dbo:wikiPageRedirects)* ?page
OPTIONAL
{ ?page dcterms:subject ?categoryUri}
}
Note the OPTIONAL clause, which is necessary here because not all resources in DBpedia belong to a category.
Including disambiguation pages:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT * WHERE
{ <http://dbpedia.org/resource/Agree> (dbo:wikiPageRedirects)*/(dbo:wikiPageDisambiguates)* ?page
OPTIONAL
{ ?page dcterms:subject ?categoryUri}
}

Override a WordPress plugin translation file on load

I'm using WordPress in french with the plugin The Events Calendar.
This plugin comes with a bundled french translation but it has some mistakes. I want to fix them but replacing the original file is a bad idea since it's gonna be replaced with the next update. I contacted the developer to submit a fix but it may take some time.
In the meantime, I would like to load a duplicate I did from my template directory. I already tried multiple things like:
load_plugin_textdomain( 'tribe-events-calendar', get_template_directory() . '/languages' );
Or with
add_filter('override_load_textdomain', …)
in my functions.php but it doesn't seem to work. The only thing I was able to do is disabling the load of the original translation file.
Is there any way to replace a plugin translation file on load? I use WPML too but in "Translate with .mo files" mode not in "Translate with WPML" so I can't change plugin translation on the fly. Maybe WPML can load my own translation of The Events Calendar?
You can add this few lines in your functions.php theme file
$text_domain = 'the-events-calendar';
$original_language_file = ABSPATH . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'the-events-calendar' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'the-events-calendar-fr_FR.mo';
$override_language_file = ABSPATH . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'your-own-theme' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'the-events-calendar-fr_FR.override.mo';
// Unload the translation for the text domain of the plugin
unload_textdomain($text_domain);
// Load first the override file
load_textdomain($text_domain, $override_language_file );
// Then load the original translation file
load_textdomain($text_domain, $original_language_file );
You'll have to replace the two file variables with the actual language file.
But we'll suppose that the french language file is in the plugin language folder and your override language file is in the language theme folder.
The idea is to :
Un load the language that has already been loaded automatically by WP
Load your override file first. This is important to load it first, because already defined translations will be skipped when you'll load another language file for this text domain (see WP core).
Load the original translation file, which will in fact load all the untranslated strings of the override file.
This works only with compiled mo file.
You can only add to your override file the few strings you want to override.
I am the author of the Transposh plugin,
Your answer actually is in the following four filters:
add_filter('gettext', ......, 3);
add_filter('gettext_with_context', ......, 3);
add_filter('ngettext', ......, 4);
add_filter('ngettext_with_context', ....., 4);
(Naturally, you need to add the function and the priority instead of the .....)
Those functions will get the strings and the domain, and you can use those to do functions like:
function gettext_filter($translation, $orig, $domain) {
if ($domain == 'plugin_domain') {
if ($orig == 'some text') {
return "some translation";
}
}
return $translation;
}
This solution uses wordpress's automatic loaders to override the plugin and doesn't need additional programming logic, instead it lets the CMS do the override.
Let's say you want to translate a plugin called my-plugin. A properly built plugin would have two translated files in the directory wp-content/languages/plugins/ called my-plugin-fr_FR.po and my-plugin-fr_FR.mo. (The locale fr_FR is just my example for French translation, it works respectively for other language translations).
If your plugin has this structure, the steps below will override the translations, if not you can try and see anyway:
Copy the .po and .mo files mentioned above into the directory wp-content/languages/my-plugin. If the directory doesn't exist, create it.
Edit the translation files as you wish and save them.

Best approach To include 3rd party files with Symfony2

I would like to know What is the best way to include 3rd party php files in symfony2. I am using a different php - ajax package for uploading files in my symfony2 application. The package offers me some php oops code which i need to use in my symfony controller. I am creating objects of that code in my controller. So i would like to know where i can put that third party code or file and how can i include or create objects of that code in my symfony2 controller. Do we use require or include in symfony2 as well. If So is that the only approach.
I'm not so sure about trying to add namespaces to a third party library. Twig, for example, does not use name spaces. And there really is no need. Consider for example a case where you want to use the PDF component from the Zend_Framework 1 library.
In your app/autoload.php file you would do something like:
$loader->registerPrefixes(array(
'Twig_Extensions_' => $ws . 'Symfony/vendor/twig-extensions/lib',
'Twig_' => $ws . 'Symfony/vendor/twig/lib',
'Zend_' => $ws . 'ZendFramework-1.0.0/library',
));
// And since Zend internally uses require/include we need to set an include path
ini_set('include_path','.' .
PATH_SEPARATOR . $ws . 'ZendFramework-1.0.0/library'
);
At this point we should be able to create 3rd part objects inside of controllers while letting the autoload system take care of finding and including the classes:
$page = new \Zend_Pdf_Page(\Zend_Pdf_Page::SIZE_A4);
$doc->pages[] = $page;
$font1 = \Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_HELVETICA);
$font2 = \Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_COURIER_BOLD);
You do have to use the \ to get around the lack of namespacing.
This answer does assume that your 3rd part library follows the more or less standard class naming convention. If it has it's own auto loading functionality then just call it from autolaod.php as well. And if you don't want to use autoloading at all then just set the include path and include away.
The documentation explains the directory structure in detail.
Basically, you can put them wherever you want, but for the sake of consistency and following best-practices, you should put your third-party libraries in vendor/ directory.
Than you can include the relevant files with namespaces.

Resources