How to add specific Individual to swrl rule using protege editor in protege 5? - protege

I am using Protege 5 and I am trying to create a SWRL rule that results in creating a object property connection between a variable instance and a specific Individual.
This is the way i write it:
sosa:HumidityObservation( ?observation) ^
sosa:hasSimpleResult(?observation, ?result) ^
swrlb:greaterThan(?result, 80) ^
sosa:Weather(VeryMoistHumidity) ->
sosa:weatherSuggestion(?observation, VeryMoistHumidity)
However I ger this error:
Invalid OWL Individual Name "VeryMoistHumidity"
How am I supposed to add the Individual in the object property atom?

In the end I simply defined the prefix I use for Individuals in the ontology and I just used in this way:
sosa:HumidityObservation(?observation) ^
sosa:hasSimpleResult(?observation, ?result) ^
swrlb:greaterThan(?result, 80) ->
sosa:weatherDeduction(?observation, ex:VeryMoistHumidity)

Related

Using related models with conditional expression

Goal: use a related model attribute as a filter inside a conditional expression for an annotation.
I'm currently adding some functionality to an old Django app, this app has some design issues and i have nothing to do with it. After some research I found conditional expressions, this is great and what I needed.
However I'm not being able to make it.
Let's have model A, model B and model C.
class ModelA(models.Model):
name=models.Charfield()
reference=models.ForeignKey('app.ModelB')
class ModelB(models.Model):
name=models.Charfield()
class ModelC(models.Model):
name=models.Charfield()
reference=models.ForeignKey('app.ModelB', related_name='some_reference')
bool_field=models.BooleanField()
And this is what I would like to do:
ModelA.objects.all().annotate(some_field=When(Q(reference__some_reference__bool_field=True),
then=F('reference_some_reference_name')))
This should work since it is being interpreted by python, but I get some Syntax Error from MySQL.
What am i doing wrong? Is this even possible?
This is what I'm getting:
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHEN `ParametrosPreciosProveedor`.`already_iva` = 1 THEN `ParametrosPreciosProve' at line 1")
'ParametrosPreciosProveedor' is ModelC in this example and 'already_iva' is bool_field.
I would try removing the When and then parts of the annotation. Q objects do those automatically - you don't define those terms in Python.
ModelA.objects.all().annotate(some_field=Q(reference__some_reference__bool_field=True),
F('reference_some_reference_name')))
Check out the docs to see how to use Q()

IBM ODM : How to define rule to validate only numeric values in a String

I am totally new to IBM ODM and I have been given a set of rules to be designed in the IBM ODM rule designer.
Simple If else and conditional rules I managed to write but I am struck how to write regular expression related rules in the IBM ODM. Can someone please help.
I have Member variable of my XOM class which is a String and I need to validate if it contains only Numbers and having 8 characters as length.
As a long-time user of ODM/JRules, it's my opinion that this is not a high-value use of business rules and that in the long run these rules will not be worthwhile.
Having said that, it should be easy enough to write a couple BOM or XOM methods to do what you want.
boolean containsOnlyNumbers(String string) {}
Verbalization: "{0} contains only numbers"
int length(String string, int length) {}
Verbalization: "{0} is {1} characters long"
Define these methods as static, on any class you want, perhaps a Utility class created just for them. Fill in the body of the methods with Java code to do the obvious things. Then verbalize them so your rule reads nicely:
If X contains only numbers and X is 8 characters long then

Is it possible load in trasparent way for the user a cross reference file declaration in xtext web editor?

I'm building integration of text editors in web applications using Xtext. I chose ace as an editor, following this documentation. Is it possible to hide or load a cross-reference declaration file in a transparent way for the user?
The actual editor shows:
Integers: int a, int b, int sum //cross reference declaration loaded from a file
sum = s + a;
I want only the second line in the editor without obtaining a reference error.

JDL pattern is not correct in Java #Pattern

When I applied pattern in JDL, the generated entity classes has #Patternannotation, but the value for that annotation is not the exact pattern which applied in JDL.
For example, if I've defined patterns as pattern('/[^\\s]+.*[^\\s]+/') and in java
it reflects as
#Pattern(regexp = "[^\\\\s]+.*[^\\\\s]+")
If you noticed in java class, there are 4 (slash) which indeed should be 2 only. Because of this functionality is getting failed.
It looks to me like you are trying to use regex control characters in your pattern, which do not need to be doubled up in your JDL: see https://www.jhipster.tech/jdl/entities-fields, especially the part under "Regular Expressions" where it says: "/.../ the pattern is declared inside two slashes... \ anti-slashes needn’t be escaped"
So it's acting correctly. Since you have double-backslants in your JDL, Java is correctly interpreting it with quadruple-backslants. Your solution is just to use single backslants in your JDL, as per the documentation.

Can I put one check on a Lexial element instead for on a number of parser rules?

I,m trying to use antlr4 with the IDL.g4 grammar, to implement some checks that our idl-files shall follow. One rule is about names. The rule are like:
ID contains only letters, digits and signle underscores,
ID begin with a letter,
ID end with a letter or digit.
ID is not a reserved Word in ADA, C, C++, Java, IDL
One way to do this check is to write a function that check a string for these properties and call it in the exit listeners for every rule that has an ID. E.g(refering to IDL.g4) in exitConst_decl(), exitInit_decl(), exitSimple_declarator() and a lot of more places. Maybe that is the correct way to do it. But I was thinking about putting that check directly on the lexical element ID. But don't know how to do that, or if it is possible at all.
Validating this type of constraint in the lexer would make it significantly more difficult to provide usable error messages for invalid identifiers. However, you can create a new parser rule identifier, and replace all references to ID in various parser rules to reference identifier instead.
identifier
: ID
;
You can then place your identifier validation logic inside of the single method enterIdentifier instead of all of the various rules that currently reference ID.

Resources