How to specify a specific class in SPARQL? - class

I am trying to learn ontologies and SPARQL using Protégé.
I'm trying to figure out SPARQL code to show subclasses of a given class:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX untitled-ontology-10: <http://www.semanticweb.org/chris/ontologies/2022/8/untitled-ontology-10#>
SELECT DISTINCT ?subclass
WHERE {
?subclass rdfs:subClassOf Class.Thing .
}
In the example here I'm trying to find all subclasses of the class Thing (or of any other defined class, e.g. Professions, in my project).
Class.Thing doesn't work of course. Neither does :Thing nor ns:Thing nor #Thing nor any of the other variants I've found in examples.
Of course if I use a variable in place of Class.Thing, it'll show me all classes, but I would really like to narrow it down to subclasses of a specific class.
Can anyone tell me how to do this?

You have to provide the URI of the class.
Either as an absolute URI between < and >:
?subclass rdfs:subClassOf <http://www.semanticweb.org/chris/ontologies/2022/8/untitled-ontology-10#YourClass> .
Or as a prefixed name (in the same way you already use rdfs:subClassOf), using the prefixes you define at the top of your query:
?subclass rdfs:subClassOf untitled-ontology-10:YourClass .
You could also use the empty prefix, if you define it as such in your SPARQL query:
PREFIX : <http://www.semanticweb.org/chris/ontologies/2022/8/untitled-ontology-10#>
# […]
?subclass rdfs:subClassOf :YourClass .
As default top-class, Protégé uses owl:Thing (http://www.w3.org/2002/07/owl#Thing), so that class is not defined under your own ontology’s URI namespace.
(You can change the URI of your ontology in Protégé. If you intend to publish your ontology and/or data, you should use a URI namespace under your control, e.g., under your own domain name.)

Related

How to check for DOM .contains? in clojurescript?

In JS one does document.some_element.contains(other_element) to find whether an element is contained within another.
How to do this in Clojurescript/Hiccup/Reagent framework?
I have tried:
(js/contains some-element another-element)
(-> js/contains some-element another-element)
(.-contains some-element another-element)
(js/.contains some-element another-element)
The proper syntax to call a method on an object is (.contains a b) which would be equal to a.contains(b). The js/ namespace is reserved for accessing the "global "scope and thus cannot be used with locals.
(.contains a b) can also be written as (. a (contains b)), which is actually what the .contains expands to after the compiler is done with it.
There is also .. which allows chaining interop forms, so (.. js/document -some-element (contains another-element)) would match document.some_element.contains(another_element). Note that js/document here is accessing the global document.
-> can also be used by requires repeating the ., eg (-> js/document .-some-element (.contains another-element)).

Why is a plus operator required in some Powershell type names?

Why is it that, in Powershell, the System.DayOfWeek enum can be referred to like [System.DayOfWeek], whereas the System.Environment.SpecialFolder enum must be referred to like [System.Environment+SpecialFolder] (note the plus character)?
My guess is because SpecialFolder is part of the static Environment class and DayOfWeek is sitting directly in the System namespace, but I'm having trouble finding any information on this. Normally static members would use the "static member operator", but that doesn't work in this case, nor does anything else I try except the mysterious plus character...
[System.DayOfWeek] # returns enum type
[enum]::GetValues([System.DayOfWeek]) # returns enum values
[enum]::GetValues([System.Environment.SpecialFolder]) # exception: unable to find type
[enum]::GetValues([System.Environment]::SpecialFolder) # exception: value cannot be null
[enum]::GetValues([System.Environment+SpecialFolder]) # returns enum values
System.Environment.SpecialFolder is definitely a type, and in C# both enums work the same way:
Enum.GetValues(typeof(System.Environment.SpecialFolder)) // works fine
Enum.GetValues(typeof(System.DayOfWeek)) // also works
I'd really like to understand why there's a distinction in Powershell and the reasoning behind this behaviour. Does anyone know why this is the case?
System.Environment.SpecialFolder is definitely a type
Type SpecialFolder, which is nested inside type Environment, is located in namespace System:
C# references that type as a full type name as in the quoted passage; that is, it uses . not only to separate the namespace from the containing type's name, but also to separate the latter from its nested type's name.
By contrast, PowerShell uses a .NET reflection method, Type.GetType(), to obtain a reference to the type at runtime:
That method uses a language-agnostic notation to identify types, as specified in documentation topic Specifying fully qualified type names.Tip of the hat to PetSerAl.
In that notation, it is + that is used to separate a nested type from its containing type (not ., as in C#).
That is, a PowerShell type literal ([...]) such as:
[System.Environment+SpecialFolder]
is effectively the same as taking the content between [ and ], System.Environment+SpecialFolder, and passing it as a string argument to Type.GetType, namely (expressed in PowerShell syntax):
[Type]::GetType('System.Environment+SpecialFolder')
Note that PowerShell offers convenient extensions (simplifications) to .NET's language-agnostic type notation, notably the ability to use PowerShell's type accelerators (such as [regex] for [System.Text.RegularExpressions.Regex]), the ability to omit the System. prefix from namespaces (e.g. [Collections.Generic.List`1[string]] instead of [System.Collections.Generic.List`1[string]]), and not having to specify the generic arity (e.g. `1) when a list of type argument is passed (e.g. [Collections.Generic.List[string]] instead of [Collections.Generic.List`1[string]] - see this answer) for more information.

how to fix a simple error on xtext?

this is my example to show you the problem I need to call two rules
generate umlDsl "http://www.xtext.org/example/umldsl/UmlDsl"
Model:
elements+=rule*
;
rule:
rul1 'and' rul2
;
rul1:
'rul1' action1=[uml::Action|FQN]
;
rul2:
'rul2' action2=[uml::Action|FQN]
;
FQN returns ecore::EString:
ID ("." ID)*
;
I have this error
Multiple markers at this line (rul1 'and' rul2)
An unassigned rule call is not allowed, when the 'current'
was already created.
Cannot change type twice within a rule
I want to know why I have this error and how to fix it please
These errors occurs because of your rule implementation of rule rule
rule:
rul1 'and' rul2
;
As I understand rule has two attributes, rul1 and rul2. But in your implementation rule does not have any attributes. To define rul1 and rul2 as attribuites you have assign these elements to an attribute. This could look like this:
rule:
rul1=rul1 'and' rul2=rul2
;
Have you looked into the Xtext documentation [1] to learn about the grammar language syntax and semantics?
The things you need to know for understanding your error are the following:
An attribute of a parser rule needs a name. To this name you assign a value, which is an other parser rules name. It is similar to assing values to a field in Java:
int i = 42;
A field declaration consists of the fields type (int) and the fields name (i) this normally is followd by the assignment operator (=) and the value (42). The attribute definiton of a parser rule follows this scheme:
RuleA: 'some syntax' attributeName=OtherRule 'more syntax';
OtherRule: 'other syntax' attribute=NextRule ... ;
...
A parser rule in Xtexts grammar language is like a Java class. RuleName corresponds to class ClassName. Then you can define some static syntax with 'keyword'. If any other rule should occur within any other rule, it can be understood as a field declaration. This rule is an attribute which is implemented like this:
attributeName=AnyRule
Where attributeName corresponds to the field name. But to an attribute the type of the value is assigned (AnyRule).
Btw. I strongly recommand that rule names should start with an Capital letter and attribute names should start with an lower case letter.
[1] https://www.eclipse.org/Xtext/documentation/301_grammarlanguage.html

Definition for BLOCK_LIST / BLOCK_IT

I am using tesseract ocr. I am not able to find the definition of BLOCK_LIST or BLOCK_IT. May I know where the definition of these classes are present.
class BLOCK_LIST and BLOCK_IT are generated by a macro named ELISTIZEH , it is defined in ccstruct/elst.h

Implementing Interfaces and calling Java Constants in Clojure (Newbie)

I am trying to write a wrapper for the google adwords api in Clojure but struggle with constants and Interfaces.
The java code looks like this :
CampaignServiceInterface campaignService =
user.getService(AdWordsService.V201109.CAMPAIGN_SERVICE);
Usually you can call constants in Clojure with e.g. (Math/PI) but when I write:
(def user (AdWordsUser. ))
(.getService user (AdWordsService/V201109/CAMPAIGN_SERVICE))
I just get "no such namespace".
Also I am a bit clueless on how to implement the interface correct. I think I should use "reify" but I get stuck.
Link to Interface:
http://google-api-adwords-java.googlecode.com/svn-history/r234/trunk/docs/com/google/api/adwords/v201003/cm/CampaignServiceInterface.html
(defn campaign-service [ ]
(reify
com.google.adwords.api.v201109.cm.CampaignServiceInterface
(get [this] ??))))
If I read it correctly, AdWordsService.V201109.CAMPAIGN_SERVICE is a static constant of an inner class of class AdWordsService.
To access inner classes you need to use java's internal name mangling scheme **; separate the inner class from its outer class with a $ sign:
AdWordsService$V201109/CAMPAIGN_SERVICE
** the JVM doesn't actually have a notion of inner classes, so java "fakes" it by creating a standalone class AdWordsService$V201109
1.About accessing constants. Did you import AdWordsService? If not you either can access AdWordsService with fully qualified name: some.package.name.AdWordsService/V201109/CAMPAIGN_SERVICE, or import it via import macro.
2.Check examples here: http://clojuredocs.org/clojure_core/clojure.core/reify
(defn campaign-service [ ]
(reify
com.google.adwords.api.v201109.cm.CampaignServiceInterface
(get [_ selector] (some-function selector))
(mutate [_ operations] (some-function-2 operations))))