I have this formula I am using in a tab I set up as a search engine for the tab Programs where I am keeping detailed information about a large number of programs. I have a several search criteria I can use for finding a list of programs to look through. The formula works well this way but I would like to make it case insensitive. I've done a little searching online for solutions but I'm afraid I don't currently have enough time to come to a complete understanding of how to make this work - I'm not a programmer and need to have considerable time to go in and work on more complex formulas to make them happen. I'm wondering if someone who's already familiar can give me a hand?
=QUERY(Programs!A3:V,
"where "&TEXTJOIN(" "&A2&" ", 1,
IF(B2<>"", " B='"&B2&"'", ),
IF(C2<>"", " C='"&C2&"'", ),
IF(D2<>"", " A='"&D2&"'", ),
IF(E2<>"", " E='"&E2&"'", ),
IF(F2<>"", " F="&F2&"", ),
IF(G2<>"", " G='"&G2&"'", ),
IF(H2<>"", " H='"&H2&"'", ),
IF(I2<>"", " I='"&I2&"'", ),
IF(O2<>"", " O='"&O2&"'", ),
IF(P2<>"", " P='"&P2&"'", )))
try:
=QUERY(Programs!A3:V,
"where "&TEXTJOIN(" "&A2&" ", 1,
IF(B2<>"", " lower(B)='"&lower(B2)&"'", ),
IF(C2<>"", " lower(C)='"&lower(C2)&"'", ),
IF(D2<>"", " lower(A)='"&lower(D2)&"'", ),
IF(E2<>"", " lower(E)='"&lower(E2)&"'", ),
IF(F2<>"", " F="&F2&"", ),
IF(G2<>"", " lower(G)='"&lower(G2)&"'", ),
IF(H2<>"", " lower(H)='"&lower(H2)&"'", ),
IF(I2<>"", " lower(I)='"&lower(I2)&"'", ),
IF(O2<>"", " lower(O)='"&lower(O2)&"'", ),
IF(P2<>"", " lower(P)='"&lower(P2)&"'", )))
Related
I am using GoogleTranslate() with Sheets to translate some contents into different languages. In those contents, we have some placeholders that do not need to translate. E.g.:
This is a Sample Text added by `{__NAME__}` on `{__DATE__}`
I do not need to translate placeholders like {__NAME__} and {__DATE__}.
How can I skip those words from the translation process?
=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(TRANSPOSE(SPLIT(GOOGLETRANSLATE(QUERY(
REGEXREPLACE(TRANSPOSE(SPLIT(A1, " ")), "\{.*\}", "♦"),, 999^99), "en", "es"), " ")),
{REGEXREPLACE(TRANSPOSE(SPLIT(A1, " ")), "\{.*\}", "♦"), TRANSPOSE(SPLIT(A1, " "))}, 2, 0),
TRANSPOSE(SPLIT(GOOGLETRANSLATE(QUERY(REGEXREPLACE(
TRANSPOSE(SPLIT(A1, " ")), "\{.*\}", "♦"),,999), "en", "es"), " "))),,999^99))
Finally find a way, as it seems logical that gtranslate don't translate email adress you can easily protect words with email pattern:
exemple, translating the following sentence from en to ru:
"I need %amount% of cherry"
Original translate from en to ru using: =GOOGLETRANSLATE(A3,"en", "ru")
"Мне нужно% Сумма% вишни"
Step1: replacing %amount% by skip#skip.amount.skip.com :
=GOOGLETRANSLATE(REGEXREPLACE(A3, "%(.*?)%", "skip#skip.$1.skip.com"),"en", "ru")
Мне нужно skip#skip.amount.skip.com вишни
Step2 : replacing back skip#skip.amount.skip.com with %amount%,
=REGEXREPLACE(GOOGLETRANSLATE(REGEXREPLACE(A5, "%(.*?)%", "skip#skip.$1.skip.com"),"en", "tr"), "(?i)skip#\s*skip.(.*?).skip.com", "%$1%")
Мне нужно %amount% вишни
What do I need to insert into TextField(inputFormatters:?
I want to disallow \ and / in one TextField and only allow a to Z in another.
Formatters
In the services library you will find the TextInputFormatter abstract class (this means that you have to import package:flutter/services.dart).
It already has implementations, which are FilteringTextInputFormatter (formerly BlacklistingTextInputFormatter and WhitelistingTextInputFormatter) and LengthLimitingTextInputFormatter.
If you want to implement your own formatter, you can do so by extending TextInputFormatter itself and implementing formatEditUpdate in there.
I will show how to apply the premade FilteringTextInputFormatter with given context.
Examples
disallow \ and /
For this we are going to use the FilteringTextInputFormatter.deny constructor:
TextField(
inputFormatters: [
FilteringTextInputFormatter.deny(RegExp(r'[/\\]')),
],
)
For the Pattern, which needs to be supplied to the formatter, I will be using RegExp, i.e. regular expressions. You can find out more about that here, which also links you to the features I will be using in my examples.
Pay attention to the double backslash \\ and the raw string (r'') in this example. This represents only a single backslash in reality. The reason for this is that backslashes are escape keys in RegExp, so we need to use two backslashes if we want to match the \ character. We would even need quadruple backslashes(\\\\) without the raw string (r'…') because Dart also uses backslashes as escape keys. Using a raw string will ensure that Dart does not unescape characters.
If we were to block a, b, F, !, and ., we would also put it in a list […] like this:
FilteringTextInputFormatter.deny(RegExp('[abF!.]'))
This translates to "deny/blacklist all 'a', 'b', 'F', '!' and '.'".
only allow a to Z
This time we use the FilteringTextInputFormatter.allow constructor:
TextField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z]')),
],
)
For this, we are specifying two ranges of characters: a-z and A-Z, which will also accept all the characters (here all the letters) in-between those two specified. This will also work for 0-9 and you can append any character to that list, e.g. a-zA-Z0-9!. will also take ! and . into account.
We can combine this
TextField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z]')),
FilteringTextInputFormatter.deny(RegExp('[abFeG]')),
],
)
This is only to show that inputFormatters takes a List<InputFormatter> and multiple formatters can be combined. In reality, you can solve this with one allow/whitelist and a regular expression, but this does work as well.
digitsOnly
There are also already included static properties in the FilteringTextInputFormatter class: one of these is FilteringTextInputFormatter.digitsOnly.
It will only accept/allow digits and is equivalent to an .allow(RegExp('[0-9]')) formatter.
Other options:
lowercase letters : a-z
capital letters : A-Z
lowercase vowels accented : á-ú
capital vowels accented : Á-Ú
numbers : 0-9
space : (a space)
Note: the spacings are to explain better
inputFormatters: [
WhitelistingTextInputFormatter(RegExp("[a-z A-Z á-ú Á-Ú 0-9]"))
]
BlacklistingTextInputFormatter and WhitelistingTextInputFormatter is #Deprecated version 1.20.0
Now you can use FilteringTextInputFormatter to do InputFormatter on TextField or TextFormField.
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'^ ?\d*')),]
inputFormatters: [FilteringTextInputFormatter.deny(' ')]
inputFormatters: [FilteringTextInputFormatter.digitsOnly]
For e.x
TextFormField(
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
],
),
First of all you have to check you have imported the following package:
import 'package:flutter/services.dart';
then you can use it like following:
TextFormField(
inputFormatters: [
FilteringTextInputFormatter(RegExp("[a-zA-Z]"), allow: true),
]);
import 'package:flutter/services.dart';
Use these parameters in the TextFormField.
maxLength: 5,
keyboardType: TextInputType.number,
inputFormatters: [WhitelistingTextInputFormatter.digitsOnly,],
I was able to extract these lines from a text file
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
but wanted to insert a new line( text before the match TBL Papers). see expected output
ACTION "INS"
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
How do I do that ? thanks
Using awk
awk '/TBL Papers/ {$0="ACTION \"INS\"" RS$0}8' file
ACTION "INS"
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
This code will add a line above pattern TBL Papers and then print everything out.
awk '/TBL Papers/{ print "ACTION \"INS\"" } 1' file
I want to create a very simple parser to convert:
"I wan't this to be ready by 10:15 p.m. today Mr. Gönzalés.!" to:
(
'I',
' ',
'wan',
'\'',
't',
' ',
'this',
' ',
'to',
' ',
'be',
' ',
'ready',
' ',
'by',
' ',
'10',
':',
'15',
' ',
'p',
'.',
'm',
'.',
' ',
'today',
' ',
'Mr'
'.'
' ',
'Gönzalés',
'.'
'!'
)
So basically I want consecutive letters and numbers to be grouped into a single string. I'm using Python 3 and I don't want to install external libs. I also would like the solution to be as efficient as possible as I will be processing a book.
So what approaches would you recommend me with regard to solving this problem. Any examples?
The only way I can think of now is to step trough the text, character for character, in a for loop. But I'm guessing there's a better more elegant approach.
Thanks,
Barry
You are looking for a procedure called tokenization. That means splitting raw text into discrete "tokens", in our case just words. For programming languages this is fairly easy, but unfortunately it is not so for natural language.
You need to do two things: Split up the text in sentences and split the sentences into words. Usually we do this with regular expressions. Naïvely you could split sentences by the pattern ". ", ie period followed by space, and then split up the words in sentences by space. This won't work very well however, because abbreviations are often also ending in periods. As it turns out, tokenizing and sentence segmentation is actually fairly tricky to get right. You could experiment with several regexps, but it would be better to use a ready made tokenizer. I know you didn't want to install any external libs, but im sure this will spare you pain later on. NLTK has good tokenizers.
I believe this is a solution:
import regex
text = "123 2 can't, 4 Å, é, and 中ABC _ sh_t"
print(regex.findall('\d+|\P{alpha}|\p{alpha}+', text))
Can it be improved?
Thank!
I am using Ruby on Rails v3.0.9 and I would like to "transform" an array of strings in a sentence including punctuation. That is, if I have an array like the following:
["element 1", "element 2", "element 3"]
I would like to get\build:
# Note: I added 'Elements are: ' at the begin, ',' between elements and '.' at
# the end.
"Elements are: element 1, element 2, element 3."
How can I do that?
Rails has Array#to_sentence that will do the same as array.join(', ') and additionally add "and " before the last item.
puts "Elements are: #{["element 1", "element 2", "element 3"].to_sentence}."
The rest, as you can see, is just putting it together.
#coreyward's answer is close, but his suggestion's output doesn't match the requested output. This will give you exactly what you want:
puts "Elements are: #{array.to_sentence(last_word_connector: ', ')}."
See the docs for more examples and options.