How do I create the model detecting the language automatically? - windows-10

the documentation says:
Create a new editor model. You can specify the language that should be
set for this model or let the language be inferred from the uri.
(emphasis mine) But I can't find any example. How can I do that? pass language argument as undefined, like this
monaco.editor.createModel(value, undefined,
monaco.Uri.parse(myuri))
?

Related

I am trying to add custom term in text moderation service of azure for zho_chs language. but returning zho_chs is invalide code

I Given "OriginalText" as input to detect offensive terms and it detected the language as zho_chs. below text is response from API
{
"OriginalText": "some profanity in zho_chs\r\n",
"NormalizedText": "some profanity in zho_chs\r\n",
"Misrepresentation": null,
"Language": "**zho_chs**",
"Terms": null,
"Status": {
"Code": 3000,
"Description": "OK",
"Exception": null
},
"TrackingId": <my trackingID>
}
But Now I am trying to add the custom term to be detected for language zho_chs below is the response from custom term adding. except zho_chs we are able to add for spa,fra,jpn,eng,deu. only having problem with zho_chs.
The language code is invalid: zho_chs.
Azure Language Detection supported Chinese Simplified language code is zh_chs and not zho_chs
As per this, zho is ISO 639-2 Language Code while Azure Language Detection conform to ISO 639-1 Language Code identifiers.
You can refer to Languages supported by Language Detection
The Language Detection feature can detect a wide range of languages, variants, dialects, and some regional/cultural languages, and return detected languages with their name and code. The returned language code parameters conform to BCP-47 standard with most of them conforming to ISO-639-1 identifiers.
Note: Languages are added as new model versions are released. The current model version for Language Detection is 2021-01-05.

Configure ESLint to error when objects are defined with certain keys

I know of the no-restricted-properties option that allows setting up rules to error when accessing certain object keys (to discourage use of deprecated APIs and the like), but I cannot find a rule to disallow setting of certain keys.
Is this possible in ESLint?
To explain further, our project uses Sequelize ORM which uses the keyword allowNull for nullable columns, and we often copy our Sequelize model definitions directly into node-pg-migrate migration files, which uses the subtly different notNull keyword.
I always forget to change the object key in a definition from allowNull to notNull and would like a way to check this in the linter in a directory specific .eslintrc file.
I found that the similarly named no-restricted-syntax rule allows you to exclude pretty much anything you can find using Javascript AST selectors. Using the very helpful AST Explorer web tool, I was able to add a .eslintrc file in the directory with our database migrations with a single rule to error when objects have the key allowNull:
{
"rules": {
"no-restricted-syntax": [
"error", "Identifier[name='allowNull']",
]
}
}

when to use cross-reference and when use containment reference?

I need to implement a domain specific language. I have a panel and some shapes on it.
'panel' name = ID '(' title = STRING',' bgcolor = Color',' width = INT',' height = INT ')''{'((rects += Rect)| (ellipse += Ellipse)|(arcs += Arc)|)*'}'
and each shape has a unique rule with some other features. for example:
RoundRect:
'roundrectangle' name = ID '{'
(fill ?= 'filled' (fillpattern?='fillpattern' fillpaint=Paint)?)?
(stroke?='stroke' str=Stroke)?
'paint' paint=Paint
'coordination' x=INT ',' y=INT
'dimention' height=INT ',' width=INT
'arc' archeight=INT ',' arcwidth=INT
'}'
as it obvious in this DSL, I used some references. But I don't know this rules is correct or I should use cross-reference in those?
This rule works fine and I receive the correct output that I expected. But I know when a feature is not of the basic type (string, integer, and so on), it is
actually a reference (an instance of EReference),this is a containment reference, although for non-containment references, the referenced object is stored somewhere else,
for example, in another object of the same resource or even in a different resource.
And point is that a cross-reference is implemented as a non-containment reference.
I need to know when I should use cross-reference and when use containment reference?
As far as I know the difference is as following:
A containment-reference is if you want to reference to the content of a rule so it's just lazy for redefining the rule's content everytime you use the containment-reference.
A cross-reference behaves a bit different: If you use a cross-reference the parser need the user having typed in content of the rule the cross-reference refers to beforeallowing him to refer to that already typed in content.
An example would be a real programming language: A Method call would be a cross-reference as the method of this name should already be declared somewhere in the code because otherwise it doesn't exist. In contrary the normal code would be implemented as a containment-reference as it can be used (for example) within a class, a field or a method and the code you are typing in just needs to fullfill the existance of a few keywords and structures but these are only defined in the parser itself and needn't be defined by the user himself before beeing able to use them.
I hope I have illustrated it well enough so you now know about the difference and the meaning of these reference types.
Greeting Krzmbrzl
Your grammar describes the AST of your language. Therefore, a meta model is derived from your grammar. To describe references between your AST elements you can use containmend references and cross references. A containment reference is used if you want to describe a parent-child relation where the child object is "created" / declared during the parent object is created. A cross reference is used if the parent object points to a child object which is created / declared in an other parent object. To "draw a picture": A containment reference is a top -> bottom reference and a cross reference is a left -> right reference.
For example assume you have a field (private int field = 42;) or method (public void foo() {...}) declaration of a Java class. This declaration is modeled with a containment reference, because a Java class contains field and method declarations. On the other you have a statement field++; within the method body of foo(). There you use the former declared field foo and it is modeled as a cross reference.
In general I would say: Any declaration is modeled as a containment reference and any usage of an already declared whatever is modeled as a cross reference.

Setting default language

I would like to see default button captions in my native language ,
Even I changed iPad's language to another lang. my app still shows English ones...Edit,Done,Save etc.
I also set CFBundleDevelopmentRegion as a User-Defined variable in XCode but not helped !
Can you help ?
You should make these things:
Add your native language to app's supported Localization array of languages;
Make your Application.Main procedure looks like:
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
NSUserDefaults.StandardUserDefaults.SetValueForKey(NSArray.FromStrings("tr"), new NSString("AppleLanguages"));
NSUserDefaults.StandardUserDefaults.Synchronize();
UIApplication.Main (args, null, "AppDelegate");
}
Then, this
turns to this
(I suggested that your language is turkish.)
For monotouch I think it is different,
They hide some langs for reducing the size of IPA.
http://docs.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization

should it be allowed to change the method signature in a non statically typed language

Hypothetic and academic question.
pseudo-code:
<pre><code>
class Book{
read(theReader)
}
class BookWithMemory extends Book {
read(theReader, aTimestamp = null)
}
</pre></code>
Assuming:
an interface (if supported) would prohibit it
default value for parameters are supported
Notes:
PHP triggers an strict standards error for this.
I'm not surprised that PHP strict mode complains about such an override. It's very easy for a similar situation to arise unintentionally in which part of a class hierarchy was edited to use a new signature and a one or a few classes have fallen out of sync.
To avoid the ambiguity, name the new method something different (for this example, maybe readAt?), and override read to call readAt in the new class. This makes the intent plain to the interpreter as well as anyone reading the code.
The actual behavior in such a case is language-dependent -- more specifically, it depends on how much of the signature makes up the method selector, and how parameters are passed.
If the name alone is the selector (as in PHP or Perl), then it's down to how the language handles mismatched method parameter lists. If default arguments are processed at the call site based on the static type of the receiver instead of at the callee's entry point, when called through a base class reference you'd end up with an undefined argument value instead of your specified default, similarly to what would happen if there was no default specified.
If the number of parameters (with or without their types) are part of the method selector (as in Erlang or E), as is common in dynamic languages that run on JVM or CLR, you have two different methods. Create a new overload taking additional arguments, and override the base method with one that calls the new overload with default argument values.
If I am reading the question correctly, this question seems very language specific (as in it is not applicable to all dynamic languages), as I know you can do this in ruby.
class Book
def read(book)
puts book
end
end
class BookWithMemory < Book
def read(book,aTimeStamp = nil)
super book
puts aTimeStamp
end
end
I am not sure about dynamic languages besides ruby. This seems like a pretty subjective question as well, as at least two languages were designed on either side of the issue (method overloading vs not: ruby vs php).

Resources