Overlapping annotations in GATE - annotations

I am trying to merge two annotations in a document and that works fine but I want to select only the annotations which are common to both of them e.g. one annotation highlights a sentence "I am testing my grammar" and the second annotation highlights "testing my grammar". The second annotation also highlights "testing my grammar" at some other place but I dont want to pick that since its not highlighted by the first annotation.
I would like to figure out a way of picking up just the common part. I am using GATE 7.1 and have used normal PRs along with one Annotation Merging PR. Is there some way by which I can create a feature which somehow shows that both annotations have been used?
Thanks

You can use a jape transducer with operator "within", described here.
Here's a simple rule which will match only Ann2 (testing my ..) when it's within another annotation Ann1 (I am testing my ...)
Phase: phrase
Input: Ann1 Ann2
Options: control = appelt
Rule: ann2WithinAnn1
(
({Ann2 within Ann1})
):aa
--> :aa.Overlap = {}
Keep in mind that partial overlaps are harder to catch with jape (or at least I don't know how) for instance:
Ann1 on "I am testing".
Ann2 on "testing my grammar".

Related

VS Code Regex search to remove references based on containing text in string

I am attempting to remove all references of a managed package that is going to be uninstalled that spans throughout code base in VS Code
I have using a query to find the field permissions but am wondering if there is a way to search for the reference outside of specifying the exact field name compared to the field containing only "agf" since they are all using it.
Below is the search query:
<fieldPermissions>
<editable>false</editable>
<field>User.agf_Certified_Product_Owner__c</field>
<readable>false</readable>
</fieldPermissions>
In the field, I want to be able to find and delete the 5 associated lines from multiple files if they match "agf" in any combination. Something like the below:
<fieldPermissions>
<editable>false</editable>
<field>agf</field>
<readable>false</readable>
</fieldPermissions>
With any combination of agf in the field, delete all from any file it appears in.
Not an answer but too long for a comment
You don't have to? Profiles/perm sets don't block package's delete. Probably neither do reports.
You'd use your time better by searching for all instances of agf__ (that's with double underscore), should find fields, objects... used in classes, flows, page layouts etc. And search for agf. (with dot) should find all instances where your Apex code calls their classes marked as global.
Alternatively Apex / VF pages with dependencies on package will have it listed in their "meta.xml", for example
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<packageVersions>
<majorNumber>236</majorNumber>
<minorNumber>1</minorNumber>
<namespace>SBQQ</namespace>
</packageVersions>
<status>Active</status>
</ApexClass>
Last but not least - why not just spawn a dev sandbox and attempt the delete there? If it succeeds - great. If not - it'll list the dependencies that blocked the delete. It'll be "the real thing", it'll smite you even if your VSCode project doesn't contain all flows, layouts and thus could lull you into false sense of security. I'd seriously do it in sandbox and then run all tests for good measure, just in case there are some dynamic soql queries that don't count as hard, delete-blocking references.
After delete's done - fetch Profiles / Permsets from this org and the field references will be gone from the xml.

Can we store metadata on every words and let user modify it and still keep it?

I’m new to lexcal and I’m developing annotation tool for speech-to-text.
I have used draftjs. I use entity and decorator to store and manage metadata on each words. every single words are entities and each entity has timestamp as metadata.
example: I have a cat
" I ", " have ", " a ", " cat " are entities.
entity data of cat is like
offset: 12,
length: 5,
data: {
original_word: 'cat',
start: 4.2,
end: 4,6,
}
So when user select a word and modify the word cat into kitten, I can still get start and end timestamps.
Do you think I can develop similar thing with lexical?
It’s okay for metadata to break when user delete multiple words at a time… No need to be perfect because I need to migrate to some editor library from draftjs anyway sooner or later…
Thanks in advance.
Approaches:
Monitor Lexical updates
An (entity) node that extends LexicalTextNode
A wrapper node on top of LexicalTextNode (like Comments)
Monitor Lexical updates
If I understand your problem correctly, that's the preferred approach.
editor.registerUpdateListener(({editorState, previousEditorState, dirtyLeaves, dirtyNodes}) => {
// You can diff editor state and each of the individual nodes that
// were modified (dirtyLeaves and dirtyNodes)
});
Note that a TextNode may contain multiple words.
Tradeoffs:
(+) It's neat. It works well with the existing Lexical nodes and doesn't modify the rendered DOM.
(-) Diffing nodes can be complicated.
An (entity) node that extends LexicalTextNode
Just like MentionNode you can have an Entity node that has your own data.
class MarkedNode extends TextNode {
__timestamps: {...};
setTimestamps() { this.getWritable().__timestamps = ... }
getTimestamps() { return this.__timestamps; }
}
Tradeoffs:
(+) It's easy to replace each word with a MarkedNode.
(-) Replacing TextNodes with your own custom nodes kills all the optimizations around TextNodes that are currently part of the reconciler (merging adjacent text nodes). Having multiple individual spans can also cause accessibility issues or other external plugins like Grammarly to misbehave and it can also drop the efficacy of other plugins that rely on TextNodes.
A wrapper node on top of LexicalTextNode (like Comments)
Just like the previous approach but instead of replacing TextNode, you create your own wrapper (Element) node on top. Given that diffing based on characters can be complicated and slow that is the approach we went for for the CommentPlugin.
Tradeoffs:
(+) It's easy to add custom wrapper nodes.
(-) It can still impact the overall app performance negatively. Overall, it's better than the previous approach because you don't override TextNode but shares most of the downsides.
What about TextNode marks?
First of all, a TextNode can contain multiple words. A mark on a TextNode can potentially refer to 1+ words.
Besides that, allowing arbitrary metadata on TextNodes means that it's hard to optimize later. For example, when merging nodes we look at the properties they have and only merge them whenever they share all properties (mode, details, style etc.). To preserve such optimization we would have to establish rules to determine whether two TextNodes nodes can indeed be merged.

Annotated User Expression [dialogFlow]

Just a quick question. I'm currently doing a project using dialogflow and in the past I've used that. Usually under "Training Phrases", there are 2 different annotations. One with "#" and the other with a huge " " " ". Now there isn't a choice for you to choose "#". Does anyone knows how to call out the entity directly?
For eg. # #sys.any:orderFood
As you can see at the bottom of https://dialogflow.com/docs/intents/training-phrases page, Template mode has been deprecated now (the one starting with # sign).
You have to use example mode only from now on.
If you want to use #sys.any:orderFood, simply write a keyword for that and annotate it with the correct entity. It will be same as using #sys.any:orderFood.
Hope it helps.

Are there any built-in keys I can use in my segmentation rules in Intuit's Wasabi?

I am trying to use user segmentation rules in Wasabi. Are there any built-in keys that I can use?
You can segment on these three things:
The passed segmentation profile
The HTTP Header values
The context parameter
For example, if you wanted to segment on the context, you would build a segmentation rule context = QA, for getting users of chrome a (naive) approach would be to use a segmentation rule that matches the regular expression ".*chrome.*". So for example User-Agent =~ ".*curl.*" & context = "QA" would match users who are in the context QA (?context=QA) and use curl.
Note that sadly the alphabetical operators (e.g. contains) which you can select in the UI are currently broken, we are working on a fix for the (still precompiled) library Hyrule which leverages those rules. For now I recommend converting your rules to the text view or test them to see if they work or not. There is also a validation in place when you try to save a rule.

Is it possible to use a control without putting it on a form in VB6?

I'm pretty sure about the answer to this, but I'm trying a variety of things to get a very stubborn project to work. One idea was to try to run code through a control without defining it on a form.
So, for example, my original code looked like this:
frmProcess.MyViewer.MaxPageSize = 100
frmProcess.MyViewer.ResetPages
frmProcess.MyViewer.AddPageToView "C:\TestPage1.txt"
I've changed it to:
Dim objViewer As MyViewer
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I get an error window with "Run-time error '91': Object variable or With block variable not set".
But there doesn't seem to be a way to 'set' this control. Is this just impossible, or is there another way to do it that doesn't require a form?
EDIT: I ended up abandoning this entire path of activity, as an alternate solution was found that got around the problem I was having with this form freezing. I don't want to delete this question in case someone else comes along and can benefit from the answers, which are potentially useful.
Try this on a form.
Dim objViewer As MyViewer
Set objViewer = Controls.Add("MyViewer", "MyViewer1")
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I've had similar situations in the past. If all else fails and you have to use a form you can do something crude like
1) Set the .Left property of the control to a negative number (like -10000) so the control doesn't appear on the form, the user can not see it
2) Make the entire form not visible..
ActiveX controls normally expect a number of services from their containers, for example persistence. They are also "packaged and marked" in ways that set the kinds of instantiation they support.
See Introduction to ActiveX Controls.
While it is perfectly possible for a control to be created in such a way as to make many of the available services optional, most controls are created from template code that requires a number of them. And most controls that are "visible at runtime" are going to require container services.
However that doesn't mean a control can't be designed to support containerless instantiation. A well known example of such a control is Microsoft Script Control 1.0 (MSScriptControl.ScriptControl) which can be used either way.