I'm playing around with JSON-LD but I think I'm missing something about linking. Gregg Kellogg's answer to Repeat whole JSON-LD structure or only the ID? almost clears it up for me, but not quite.
He has an example like this, where the author is an organization:
{
...
"author": {
"#id" : "http://example.com",
"name": "My Organization"
}
}
Which he simplifies at the end to look like this:
{
...
"author": {"#id" : "http://example.com"}
}
It seems to me that if I wanted to link to something, I should be able to simply reference it:
{
...
"author": "http://example.com"
}
That value would be seen as an IRI (assuming author is defined correctly) and that something would inflate the object at that IRI. However, almost all of the examples I see have extra stuff around that. What am I missing here? What can't I do if I just use the IRI instead of the method Gregg uses? He says that some people repeat parts of the graph, but that would seem to be a huge problem in managing data should I have to change a name. Is there a practical or theoretical problem there?
The sample on json-ld.org seems to be what I expect, but the things I've seen most often don't do it like this (linking to spouse):
{
"#context": "http://json-ld.org/contexts/person.jsonld",
"#id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
I think in the end if doesn't matter because Markus Lanthaler also notes that you can't rely on parsers to inflate objects so you're stuck specifying everything all the time just in case.
Related
I am building a template using the dotnet new template engine.
I have a parameter that looks like this:
"symbols": {
"rootEntity": {
"displayName": "Root Entity",
"type": "parameter",
"datatype": "string",
"replaces": "Notebook",
"defultName": "Notebook",
"isRequired": false,
"description": "An example root level data entity"
},
... other parameters here
}
It seems to mostly work, but it only replaces Notebook, not notebook. I could add another parameter for the lowercase version, but that requires users to type it in twice (yuck).
I saw the casing generator, but it does all uppercase or all lowercase (not just the first letter).
Digging more, I found a thing called a form that has the options firstLowerCase and firstUpperCase. But I can't find any examples using forms, only symbols (as shown in my example).
So, I have two possible questions (either will work):
How can I lowercase or uppercase the first letter of a symbol variable
How can I use forms in a template.
(I would prefer the second question as that enables me to use all the forms, but the first will get me moving forward, so I would be happy with either.)
I've converting some JSON-ld to RDF however it doesn't seem to produce RDF with the subject as I'd expect.
So, my JSON-ld looks like this:
{
"#context":{
"personid":"http://schema.org/id",
"hasUpdateType":"http://schema.org/updateType"
},
"#type":"http://schema.org/Person",
"personid":"123456",
"hasUpdateType":{
"#type":"updateType",
"updateType":"Full"
}
}
And the RDF that is produced is
_:b0 <http://schema.org/id> "123456" .
_:b0 <http://schema.org/updateType> _:b1 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
However I was expecting something like (syntax not correct, just trying to show roughly):
person hasUpdatetype Full
Is my json-ld wrong?
To make the conversion from json-ld to rdf, I'm using the toRDF() from this library https://github.com/digitalbazaar/jsonld.js
Any help would be appreciated.
Thanks.
You need to use #id (or an alias) to define the subject of the node object. You could potentially defined "persondid" as #id in the context.
You defined "hasUpdateTime" to expand to "schema:updateTime", so the expanded RDF should use "http://schema.org/updateType" as the predicate. If you want the value to be a single URI associated with "Full", use type coercion on "hasUpdateType". Something like the following may be closer to what you want.
{
"#context":{
"#base": "http://example.com/",
"personid":"#id",
"hasUpdateType": {"#id": "http://schema.org/updateType", "#type": "#id"}
},
"#type":"http://schema.org/Person",
"personid":"123456",
"hasUpdateType":"Full"
}
This would give you the following triples:
<http://example.com/123456> <http://schema.org/updateType> <http://example.com/Full> .
<http://example.com/123456> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
I'm trying to cite a paper that is forthcoming, and unfortunately if I put year = {Forthcoming} in my BibTeX citation entry, pandoc-citeproc always takes this as n.d. (e.g. "Greig (n.d.)" in footnotes/bibliography entry). Ideally it'd be nice to have it just output Forthcoming (e.g. "Greig (Forthcoming").
I tried searching here and other places for solutions to this issue, but couldn't find anything. I then tried using some suggested solutions from others with a standard LaTeX/BibTeX output---e.g. here: https://jblevins.org/log/forthcoming.
I attempted this (from the link above):
#Preamble{ " \newcommand{\noop}[1]{} " }
#Article{smith-2011,
author = "John Smith",
year = 2011,
journal = "Unorganized Scholarly Impressions",
...
}
#Article{smith-inpress-a,
author = "John Smith",
year = "\noop{3001}in press",
journal = "Journal of Nothingness",
...
}
#Article{smith-inpress-b,
author = "John Smith",
year = "\noop{3002}forthcoming",
journal = "Review of Random Thoughts",
...
}
Unfortunately pandoc-citeproc doesn't seem to do anything with \noop{xxx}forthcoming---I still get n.d. in the resulting citation. I would otherwise expect Forthcoming (e.g. "Greig (Forthcoming) ...").
How would I then go about that when exporting citations via pandoc/pandoc-citeproc?
I haven't worked out totally how to implement this myself, but for "forthcoming" works, the variable you'll want to use is "status" and not "year". You can look at this closed issue from JGM to see a bit about usage here.
I got a trouble about Alexa Number type. When I try to command number "two" or "four" Alexa always returns an undefined value or "?" to my server.
My utterance is as below:
echo, tell machine "Machinename" "action" "......".
"machine" is skill invocation.
"Machinename" is AMAZON.FOUR_DIGIT_NUMBER. I also tried it as AMAZON.NUMBER.
the second and third component is custom type and they are OK.
I have read almost topic related to this issue. I found solution {two|Machinename} is not worked with me. The Alexa skill kit always reponds as
"The built-in slot type "{two | Machinename}" cannot be extended with custom values. Error code: InextensibleSlot".
because "AMAZON.FOUR_DIGIT_NUMBER" and "AMAZON.NUMBER" is not extensible Built-In Types.
In another case when i tried to move "Machinename" to the last slot in my utterance. It still did not work. All numbers are ok except "two" and "four". So looks like it not related to invocation with "to" or "for".
Anyone please give me a solution or workaround.
ps: sorry for my bad English.
Thanks in advance.
I tried your interaction model with AMAZON.NUMBER instead of AMAZON.FOUR_DIGIT_NUMBER and everything is working fine. Slot values are mapped correctly.
Ex: ask machine number four start printing
Request generated:
"request": {
....
"machinename": {
"name": "machinename",
"value": "4",
....
"actionname": {
"name": "actionname",
"value": "start",
....
"functionname": {
"name": "functionname",
"value": "printing",
....
Hope this helps
After about 2 week i try to contact with Amazon also fine solution from the Internet. This times they can't help anything.
From the Amazon support team, they alway tell me recheck AMAZON.NUM/AMAZON.FOUR_DEGIT_NUMBER. I told them it alway ok with simulator and ask for help from real devices. But don't have any response as expected.
So this times, i tried to resolve this issue by another way:
AMAZON.SearchQuery ==> receive command string and process it yourself instead of slots.
Dialog Management.
Hope this helps
In JMeter I want to check the number of objects in a JSON array, which I receive from the server.
For example, on a certain request I expect an array with 5 objects.
[{...},{...},{...},{...},{...}]
After reading this: count members with jsonpath?, I tried using the following JSON Path Assertion:
JSON Path: $
Expected value: hasSize(5)
Validate against expected value = checked
However, this doesn't seem to work properly. When I actually do receive 5 objects in the array, the response assertion says it doesn't match.
What am I doing wrong?
Or how else can I do this?
Although JSONPath Extractor doesn't provide hasSize function it still can be done.
Given the example JSON from the answer by PMD UBIK-INGENIERIE, you can get matches number on book array in at least 2 ways:
1. Easiest (but fragile) way - using Regular Expression Extractor.
As you can see, there are 4 entries for category like:
{ "category": "reference",
{ \"category\": \"fiction\"
...
If you add a Regular Expression Extractor configured as follows:
It'll capture all the category entries and return matches number as below:
So you will be able to use this ${matches_matchNr} variable wherever required.
This approach is straightforward and easy to implement but it's very vulnerable to any changes in the response format. If you expect that JSON data may change in the foreseeable future continue with the next option.
2. Harder (but more stable) way - calling JsonPath methods from Beanshell PostProcessor
JMeter has a Beanshell scripting extension mechanism which has access to all variables/properties in scope as well as to the underlying JMeter and 3rd-party dependencies APIs. In this case you can call JsonPath library (which is under the hood of JsonPath Extractor) directly from Beanshell PostProcessor.
import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.JsonPath;
Object json = new String(data);
List categories = new ArrayList();
categories.add("fiction");
categories.add("reference");
Filter filter = Filter.filter(Criteria.where("category").in(categories));
List books = JsonPath.read(json, "$.store.book[?]", new Filter[] {filter});
vars.put("JSON_ARRAY_SIZE", String.valueOf(books.size()));
The code above evaluates JSONPath expression of $.store.book[?] against parent sampler response, counts matches number and stores it into ${JSON_ARRAY_SIZE} JMeter Variable
which can later be reused in an if clause or an assertion.
References:
JMeter – Working with JSON – Extract JSON response
JMeter's User Manual Regular Expressions entry
JSON Path Documentation and Examples
How to use BeanShell: JMeter's favorite built-in component
This is not possible with the plugin you are using (JMeter-plugins).
But it can be done with JSON Extractor since JMeter 3.0, this plugin has been donated by UbikLoadPack (http://jmeter.apache.org/changes_history.html)
Example:
Say you have this JSON that contains an array of books:
{ "store": {"book": [
{ "category": "reference","author": "Nigel Rees","title": "Sayings of the Century","price": 8.95},
{ "category": "fiction","author": "Evelyn Waugh","title": "Sword of Honour","price": 12.99},
{ "category": "fiction","author": "Herman Melville","title": "Moby Dick","isbn": "0-553-21311-3","price": 8.99},
{ "category": "fiction","author": "J. R. R. Tolkien","title": "The Lord of the Rings","isbn": "0-395-19395-8","price": 22.99}
],
"bicycle": {"color": "red","price": 19.95}} }
To have this count:
1/ Add JSON Extractor:
The count will be then available bookTitle_matchNr which you can access through:
${bookTitle_matchNr}
Running this Test Plan would display this:
As you can see, Debug Sampler-${bookTitle_matchNr} shows Debug Sampler-4