How do I define that a resource is from datatype xsd.integer in RDF? - xsd

is it possible in rdf to define/model that a resource with uri http://example.com/counter has the data type integer because it has integer values.
For example in Turtle:
ex:counter rdf:type xsd.integer.
ex:counter ex:value "3".
the first statement is wrong. possible would be "3" rdf:type xsd:integer. right? So how can I express that counter has only values from type integer. Is it possible with rdfs:Dataype or rdfs:range?
Thanks in advance.

Related

Part of JSON from String to Integer

I have a text field with JSON structure in my Postgres v10.8 DB.
I need to grab a value inside the config and cast it to a whole number. (values are in format like this 0.0, 1.0, 2.0) It's never 1.5 so it should be possible to turn it into whole numbers.
With this select i can grab the value i need but i don't know how i can turn the results from this into a whole number?
select coalesce(cast(tb.config_exit as json)->> 'exit_time_tenant' , '') as exit_time from table tb
When i try to say cast('1.0' as Integer) i get this ERROR: invalid input syntax for integer: "1.0"
This works but it's probably not a good solution?
cast(substring('1.0' from '([0-9]+)(.{1})') as Integer)
You should convert tb.config_exit :: json ->> 'exit_time_tenant' between parentheses and then convert to decimal
Demo
select
(tb.config_exit :: json ->> 'exit_time_tenant') :: decimal :: int as exit_time
from
"table" tb

If i store index number fetched from db in variable & using in select from list by index, m getting err as expected string, int found-Robot Framework

enter image description here
select from list by index ${locator_var} ${inp_msge_type}
--getting error as expected string, int found
select from list by index ${locator_var} 7
-----not getting any error
${inp_msge_type}----contains 7 from DB query the result is stored in this variable, to avoid hard coding we need to do this
Is there any way to write
Do not add links to screenshots of code, or error messages, and format the code pieces accordingly - use the ` (tick) symbol to surround them.
The rant now behind us, your issue is that the keyword Select From List By Index expects the type of the index argument to be a string.
When you called it
Select From List By Index ${locator_var} 7
, that "7" is actually a string (though it looks like a number), because this is what the framework defaults to on any typed text. And so it works.
When you get the value from the DB, it is of the type that the DB stores it with; and probably the table schema says it is int. So now you pass an int to the keyword - and it fails.
The fix is simple - just cast (convert) the variable to a string type:
${inp_msge_type}= Convert To String ${inp_msge_type}
, and now you can call the keyword as you did before.

Problem to get integer values for Protege DataProperty from Excel using Cellfie

I am using Cellfie plug-in for Protégé to create ontological individuals from an Excel database of scientific articles. I face a problem when I try to assign an integer value to a property 'has interger value' which range is xsd:integer. In fact, the property is being assigned but without the ^^xsd:integer type specification, so the reasoner fail beacause those values are not recognized as integers. I am using this Manchester Syntax code, which is not causing any error, but the values given to the properties are not declared as integers inside the Protégé ontology:
Individual: #B*
Types: 'Publication year'
Facts: 'has integer value' #B*(xsd:integer)
The column B of the Excel is full of integer numbers (years). If I try using xsd:string, the properties have the correct type declaration ^^xsd:string, but if I try to use xsd:integer the axioms are created ignoring the type declaration.

Dynamic inference of type from String value in java

I have a parameter of type object in my endpoint method. I want jackson to be able to convert it to int if it sees "25" i.e. get 25, or boolean if it sees "true" i.e. get true. Currently, I am getting the value as "25" string or "true" as string. I don't have any information about the type of the property before hand.
You can use JSONPARSER and put a check like this:
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NUMBER_INT), then jsonParser.getIntValue()

Error converting string feature to numeric in Azure ML studio

QuotedPremium column is a string feature so I need to convert it to numeric value in order to use algorithm.
So, for that I am using Edit Metadata module, where I specify data type to be converted is Floating Point.
After I run it - I got an error:
Could not convert type System.String to type System.Double, inner exception message: Input string was not in a correct format.
What am I missing here?
As mentioned in comments, you must change column where numbers are handled as text to numeric type data and it shouldn't have any null values. Now answering the question of how to substitute NULL's in data using ML studio and converting to numeric type.
Substitute NULL's in data
Use Execute R Script module for that, and add this code in it.
dataset1 <- maml.mapInputPort(1); # class: data.frame
dataset1[dataset1 == "NULL"] = 0; # Wherever cell's value is "NULL", replace it with 0
maml.mapOutputPort("dataset1"); # return the modified data.frame
Image for same:
Convert to numeric data
As you have added in your answer, this can be done using the Edit Metadata module.

Resources