configuration file allenNLP - allennlp

I am trying to understand how to build configuration file for our experiements
let us take this example from the AllenNLP documentation
training and prediction
in particular this snippet
From where we got "token_embedders"? shouldn't be "basic" as documentation here?
or do I miss something?

There is a bit of a short-cut going on here. The long form would be this:
"model": {
"type": "simple_classifier",
"embedder": {
"type": "basic",
"token_embedders": {
...
}
}
}
BasicTextFieldEmbedder is the default implementation of TextFieldEmbedder, and that's why you don't have to explicitly say "type": "basic". "token_embedders" is simply a parameter of BasicTextFieldEmbedder.__init__(), as seen here: https://github.com/allenai/allennlp/blob/master/allennlp/modules/text_field_embedders/basic_text_field_embedder.py#L35

Related

Check with jsonschema if path is valid

I am trying to write a json schema including the feature to check if a path is valid and exist.
For example I want to validate this json:
{
"paths": ["/path/to_check", "../path/not/valid", "../../path/exists"]
}
My current schema is:
{
"type": "object",
"properties": {
"paths": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Is there a way to indicate that items must contain valid/existing paths?
You can use regex, but there's no way to determine if a path is a real path according to a file system. JSON Schema works with JSON data... that's all, nothing more. It has no notion of a file system.
I've been googling for the same thing and was coming to the same conclusion that #Relequestual posted (who is the authority on such things).
What may be of interest is that the pydantic library extends their JSON Schema with a bunch of extensions for complex string sub-types, including file-path, directory-path and path (and many, many more).
This could be useful either directly, or to adopt as a quasi-standard for a custom implementation.

How to use the type "expandable" correctly?

Question
How to use the type "expandable" correctly?
Description
I have a batch that runs every hour and sends some stats to our slack. Each JSON output can be quite large and I'm looking for a way to have it collapsable/expandable.
I was playing with slack's BlockKit Builder in hopes that there was something of the sort, and I came across (when looking at the message errors) that there is a type called expandable.
However, there is no (?) documentation regarding it. The only thing that I know is.
It requires a blocks property
It should be a child of a blocks property
What I've tried
I went on the block builder (demo) and was able to get this to not throw any errors but there was no visual output...
{
"blocks": [
{
"type": "expandable",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where you'd like to take the Paper Company investors to dinner tonight.\n\n *Please select a restaurant:*"
}
}
]
}
]
}
What I would like:
I would like to have a working collapsable/expandable and understand what the different properties are and how they work.

Custom code completion for class methods?

In MATLAB, it is possible to define code suggestions and completions as explained in the documentation page titled "Customize Code Suggestions and Completions".
The snippets given therein, e.g.
{
"_schemaVersion": "1.0.0",
"anotherFunc":
{
"inputs":
[
{"name":"input1", "kind":"required", "type":["numeric"]},
{"name":"input2", "kind":"required", "type":["numeric"]}
]
}
}
show how we can control the predictions of functions found (presumably) in separate files in the same folder as functionSignatures.json.
Suppose I have a method called myMethod which resides in a class called myClass. Creating a JSON as above with "myMethod" instead of "anotherFunc" didn't seem to have an effect.
My question is - how can we define completions for class methods using this technique?
After some trial and error, it appears that the prediction/completion logic expects to see syntax like:
"myClass.myMethod"
In other words, this should work:
{
"_schemaVersion": "1.0.0",
"myClass.myMethod":
{
"inputs":
[
...
]
}
}

How to pass variables between templates - ARM json

I'm looking for a way to pass a variable (normal string) from a linked template back up to my main template.
I want to use something like: (in linked template)
"outputs": {
"installStringNodes": {
"type": "string",
"value": "[variables('installString').value]"
}
}
And then i want to call this variable into my main template. But i can't seem to crack how.
"variables":{
"installStringFromNodeResources": {
"value": "[??('node-resources')??.outputs.installStringNodes.value]"
},
}
There's a 'sharing state in resource manager templates' doc with the usage of reference() but apparently that can't be used in variables as it gives me an error while trying to deploy.
Seems to me there should be an easy solution for this but i haven't been able to see it yet..
In the main template, the variable should be:
"installStringFromNodeResources": {
"value": "[reference('node-resources').outputs.installStringNodes.value]"
}
Follow this walk through sharing state between templates

i18next failing to load translation file: "there is a typo"

I've created translation file, validated it at jsonlint, ensured the translation file was located at /locales/translation-en.json.
I consistently get the error,
There is a typo in: locales/translation-en.json
I'm stumped ... here's the translation json I have.
{
"tab":{
"legionella":"LEGIONELLA",
"logbook":"LOGBOOK"
},
"representative":{
"tag":"Representative: __rep__ — Phone: __phone__ — ",
"email":"Click here to email your rep"
},
"portlet":{
"contacts":{
"title":"Contacts",
"type":"Contact<br>Type",
"name":"Contact<br>Name",
"phone":"Phone<br>Number",
"type_context_1":"Owner",
"type_context_2":"Maintenance",
"type_context_3":"Other"
},
"samples":{
"title":"Legionella Samples",
"sampleDate":"Sample<br>Date",
"transmitForm":"Transmittal<br>Form",
"certOfAnalysis":"Certificate<br>of Analysis",
"concentration":"Concentration<br>(UFC/L)",
"correctAction":"Corrective<br>Action",
"range_context_1":"Interference",
"range_context_2":"Less than 10,000 UFC/L",
"range_context_3":"Between 10,000 to 1,000,000 UFC/L",
"range_context_4":"Greater than 1,000,000 UFC/L"
},
"serviceReports":{
"title":"Service Reports",
"date":"Report<br>Date"
},
"maintenance":{
"title":"Maintenance Programs",
"popup":"Create New Maintenance Program",
"type":"Program<br>Type",
"date":"Effective<br>Date",
"document":"Program<br>Document",
"type_context_1":"Water Treatment",
"type_context_2":"Mechanical",
"type_context_3":"Schematic",
"type_context_4":"O&M Manual",
"popup_type":"Type",
"popup_date":"Effective Date",
"popup_document":"Document",
"popup_save":"Save Maintenance Program"
},
"history":{
"title":"System History",
"popup":"Create New System History Entry",
"date":"Event<br>Date",
"type":"Event<br>Type",
"details":"Event<br>Details",
"type_context_1":"Breakage",
"type_context_2":"Repair",
"type_context_3":"Decontamination",
"type_context_4":"Replacement"
},
"reminders":{
"title":"Reminders",
"date":"Date",
"description":"Description"
},
"emails":{
"title":"Emails",
"date":"Date",
"subject":"Subject",
"recipient":"Recipient"
}
},
"common":{
"view":"View",
"registryList":"Registry: ",
"signout":"Sign Out"
}
}
So, I found the issue. I didn't give ALL the details required in the original question. What I failed to let everyone know was that the json file resided in Netsuite. Netsuite doesn't like serving up .json files. When I converted it to .json.txt, all was well in the world. Thanks!
Just in the event someone missed the obvious..
JSON, unlike Javascipt, requires the keys be quoted.
Valid JSON:
{ "foo": "bar" }
Invalid JSON:
{ foo: "bar" }
Since this question pops high in Google when search for "i18next there is a typo in", here's what you can do.
Use a JSON validation tool. If it's not valid, correct your mistakes and try again.