Some of my iOS AppShortcut phrases work, but some launch Safari? - swiftui

One of my intents responds to an optional parameter. The parameter is defined as an enum with 4 values (case today, week, month, year). I have 2 AppShortcut phrases defined, one that does not specify the parameter and another which does.
AppShortcut(intent: TopCardsIntent(),
phrases: [
"show \(.applicationName) top cards",
"show \(.applicationName) top cards for \(\.$timeframe)",
],
systemImageName: "atom"
)
The 1st phrase (with no $timeframe) ALWAYS is interpreted by Siri as a Safari lookup.
The 2nd phrase ALWAYS works, but only when I don't specify timeframes '.today' or '.year'. When I do specify '.today' or '.year' - I again always get a Safari lookup.
I've tried all sorts of goofy debugging. Thinking maybe it's because '.today' is 1st and '.year' is the last enum value defined, I added a .decade value. So, the '.decade' works perfect, but '.year' still doesn't. #RandomAF
There are lots of AppShortcut phrases which I'm trying to use that always result in Safari lookups. It almost feels as if Safari has it's own set of AppShortcut phrases, and these are evaluated before mine.
Any ideas?

Related

Is there a way to tweak this formula to make this work, even if the name doesn't 100% match? If so, how?

I'm trying to use a script to automatically set up conditional formatting to highlight a specific set of names in a Google Sheet. The data comes from a Google Form where people enter their own name. The conditional formatting is triggered if both first and last names match the listed entries (in the example below, *Harry Potter and Ron Weasley).
The script coding looks like this:
.whenFormulaSatisfied('=OR(AND($D7="Potter",$E7="Harry"),AND($D7="Weasley",$E7="Ron"))')
Problem: If the person hits the spacebar after their name, or types Ronald instead of Ron or the like, then the highlighting doesn't work. I know I can't make it work if they make a typo entering either half of their name. I would, though, like it to still work if they hit the spacebar or don't abbreviate, etc. So, I want it to work as long as the specified text string is present.
Question: Is there a way to tweak this formula to make this work, even if the name doesn't 100% match? If so, how?
Instead of strict comparison =, use REGEXMATCH.
For eg,
If the person hits the spacebar after their name, or types Ronald instead of Ron or the like,
Change
$E7="Ron"
to
REGEXMATCH($E7,"Ron.*")
. Any character(like space or ald)
* Previous regex repeated zero to unlimited times
See Reference - What does this regex mean?
REGEXMATCH returns TRUE or FALSE just like = does.

(C++) Can the color of text change as it is typed?

I have a list of instructions in my program and they are activated by entering a string. There are a large number of possible instructions. You could call them commands if you like.
I already have a program that can successfully execute the instructions I've added so far.
For example, adding a person to the database would require the user to enter add "John" "Doe".
This would output to the screen Added John Doe to the database, ID#1234. The IDs are random.
I know how to add colors; in this output text, "John Doe" would be colored green.
What I'm wondering is, can I make it so that color changes as one types? Because I learned how to use some kind of keyboard mode change so that when I type a password, all characters are displayed as * of any color I desire, or even nothing displayed at all, through "display" of \0, and I know how to do that. I was wondering if the color could change before the complete string (extracted with std::getline(std::cin, str);) is typed.
The first reason I want the colors to change is because when there are so many commands, and I already have more complex commands than that, I want to provide a way for the user to be able to correct syntax mistakes before they press enter. Something like Windows PowerShell, perhaps, which was written in C#. I know that C# is a very different language than C++, but if C# can achieve something like that, I want to see if C++ can as well. My hope is that it doesn't require thousands of lines of application-specific code, especially considering that PowerShell is an actual application and not a simple terminal-run executable. And while PowerShell appears to be open-source, I don't understand C#. See the bottom for the second reason.
I have no idea if this is possible, but because similar manipulation of entered text is possible (as I said, I know how to add colors and also mask text as some other single character like *), I want to know if this is also possible.
Simple examples:
Firstly, the user should know when they have not entered a valid command, and when they have. I want the text to be in red until the letters entered so far consist of an actual keyword, like add. So, the text would be red until the second d is added, when it reverts to white, and if another letter is entered, it becomes red again.
Example 1: add "John Elias" "Doe"
After the space, the text after "add" should be red no matter what, unless the character after the space is a quotation mark. In order to tell the user that they have not terminated the string, the text beyond the (orange?) quotation mark should be orange. When the final quotation mark is entered, the entire content of the quotation marks (including the quotation marks) should be some other color (probably green?) to tell the user that they have successfully entered an argument. The same applies to any instances of quotation-mark arguments. Note that a space is allowed in a quotation argument.
Example 2: list-info 1234
In this command, it gets more complex. list is a separate command, so the text should be red until t is entered, and it turns white. But then it turns red again after that, until o is entered, and it turns white again. The numerical argument following it should be red if the entered character isn't a digit. If it is, it's still red, because the only valid IDs are 3- or 4-digit numbers. It should turn green(?) once a third digit is entered, and still stay green when another digit is entered. But if a fifth digit is entered (or another character for that matter), the number turns red again. Although this would better be implemented as returning an error if the entered number is invalid, I would still like to know if this can be done as well.
Example 3: add "John" "Elias" "Doe" "fourth-string"
Since there is an overloaded function that enables an explicit first-middle-last name to be stored as well, it should be ok if there is a third string. But if there is a fourth string added, then it should be in red no matter what because add cannot take more than 3 arguments.
My question is, are any of these things possible? And yes, I am aware that it is almost certainly better to just implement an error system, but my intention is to expand my coding ability, and that is the second reason, and coding an error system will not do that because I have already done that for every command.
For reference, I'm operating in Linux Ubuntu 18.04, I compile with g++, my code conforms to C++17, I use ANSI escape sequences for color, bold, etc., and for masking characters with something like * I use a pointer to a char array (passed by address as char**) and a C-style FILE* to reference the input stream stdin (because I haven't bothered to conform it to a typical C++ implementation yet, learning ways to advance my current skills is my priority at this point in time).

Coldfusion Regex-ing logic acting strangely

I start with entries like this in a spreadsheet:
Notice the different size dashes.. Longer one after Permit Date. Chr(8211) if I am correct.
I turn the spreadsheet into a query:
I get a cell value and regex that first bit out of it. (Regex pattern seems a bit much but it works)
//i make a new query and set one cell
querysetcell(newquery,"permitDateHeader",rereplace(cellWithPermitDate,
"^[(\W)]*(\w)*(\s)*(\w)*(\s)*(\w)*(:| -| –)+","","all"), insertRow);
However, I still am left with this:
Notice the regex worked on the Construction Type with just the two small dashes.
So I created a test page .cfm (this other stuff was running in a controller)
number = "Permit Number: 2016-1";
date = "- Permit Date – January 13, 2016";
reformednumber = rereplace(number,"^[(\W)]*(\w)*(\s)*(\w)*(\s)*(\w)*(:| -| –)+","","all");
reformeddate = rereplace(date,"^[(\W)]*(\w)*(\s)*(\w)*(\s)*(\w)*(:| -| –)+","","all");
writeDump(reformednumber);
writeDump(reformeddate);
And this is what is dumped:
Permit date was successfully parsed. This time on a .cfm page rather than in the controller and putting it in a query. That's the only difference I see. same regex.
Why is this happening?
Possible solution is just changing the regex. I just didn't want to pick up values that fall under the \W scope such as a dollar sign.
Note if this can't be recreated then it may be too 'application-specific' of an error to be left on the forum.
I am still not sure why that happened, but this edit to the regex seems to have fixed it.
^[(\W)]*(\w)*(\s)*(\w)*(\s)*(\w)*(\s)*(\W)?
//used(\W)? at the end rather than (:| -| –)+

Amazon CloudSearch matching long strings against domain documents

I'm implementing Amazon's Cloud Search API and was wondering how well it would work for "vague" queries.
We basically have records that contain descriptions. We want to find matches based on the content of that description. For example, our domain dataset has the following strings (where each string is a different document):
"The sun is shining bright today"
"The moon is shining in the sky tonight"
"The rain is pouring outside today"
If I were to submit a description to the server like this:
"The sun and moon are shining bright lately"
is there a search method that would return a match for the first two elements (albeit with a low score)? There are key words that are important, ignoring the "the" and "is" type of words. If so, how is that search constructed?
I was eventually able to get those strings to be returned with a query based on "The sun and moon are shining bright lately". I accomplished this by boolean OR'ing the terms together like this:
(or name:'sun' name:'moon' name:'shining' name:'bright' name:'lately')
I also removed stopwords but I don't think you need to.
It's definitely not pretty. The problem I had with other approaches was that CloudSearch seems pretty heavy-handed about penalizing results that don't contain a word from your query, so a word like lately in the query would cause it to not match any of the test strings. I was hoping to fix that with a rank expression but I think you can only rank results, not docs that didn't even match your query.
I also played around with sloppy phrase search but that still requires that the words are found some distance from each other, where in this case certain words aren't found at all.
The only other thing I can think to try is looking at the lucene and dismax query parsers. They won't change the underlying search engine but they may give you a different means of specifying a query that would work better.

Removed hyphen from word_separators, ctrl+d no longer makes sense

I removed the - from the word_separators setting, and that works fine.
But ctrl + d on the word a still matches the "a" in a-b, I don't want it to do that anymore.
It's because ctrl + d wraps your search with regex boundaries \b, and - is still considered a boundary.
Is there anything I can do to now make ctrl + d not consider - a boundary anymore.
EDIT: picture:
The "a" in a-b should not be highlighted, as a-b is a single variable name in this language, which is why I removed the - from word_separators
More clarification: If I'm trying to replace all instance of the variable a, I don't want it matching against parts of other variables, like the "a" in a-b.
From what I can tell from some informal experimenting while answering your other question, the "word_separators" setting seems to primarily relevant when double-clicking to select words. For example, I have the following words in a file:
and my word_separators list is ./\\()\"'-:,;<>~!##%^&*|+=[]{}`~?$, so it includes - and / but not _. If I put my cursor in the first foo (without selecting the whole word first) and hit CtrlD, I get
and if I continue hitting CtrlD for several more times, I get
so only the "individual words" are selected - foo_bar is not, nor is foobar. However, if I set word_separators to .\\()\"':,;<>~!##%^&*|+=[]{}`~?$ (removing - and /) I get the same results when hitting CtrlD repeatedly:
- and / are still treated as word separators, even though I removed them from the list. If I add _ to the word_separators list, the results are the same, and only one obvious conclusion can be drawn: word_separators is ignored by CtrlD (find_under_expand).
However, the word_separators list IS used when double-clicking to select a word. With the list like this: .\\()\"'_:,;<>~!##%^&*|+=[]{}`~?$ (missing - and /, but with _), double-clicking on foo in each word in turn gives the following:
Interestingly, double-clicking on the very first foo gives
indicating that the "box" highlighting of similar selections is not paying attention to word_separators.
When using Find -> Find... to search, word_separators is ignored. When nothing is selected and foo is entered into the search box (non-regex search), the following matches are highlighted:
This is the same regardless of whether -, /, and/or / are in word_separators or not.
If "Whole Word" is set in the options, the results are a bit different, but again they don't change regardless of whether -, /, and/or / are in word_separators:
TL;DR
So, the conclusion is that word_separators is only in effect when double-clicking to select a word. Using a Find dialog or CtrlD (find_under_expand command) relies on some internal separator list, which apparently can't be altered (see my answer here).
A little bit more
Some info I forgot to add earlier: word_separators is also used by some plugins for various sorts of things, such as creating/modifying/otherwise working with selections, doing programmable completions, find and replace, and other sorts of stuff.