Extract a particular string given its heading - regex - python-3.x

Am trying to extract a particular string in the below data.
I have to extract the observations mentioned in the data. There are various ways observations has been written, for ex : OBSERVATION, Observation, observed, OBSERVED ....
Please let me know how to extract this.
Data :
Preconditions :1)One valid navigation map should be installed on the MGU.2)One route must be active.\nActions/steps : 1)Press PTT button.\n2)Give voice command "Navigate to Alibaba Restaurant" and observe system\' s behavior.\n\nExpected result/behaviour:\n1) Confirmation prompt of given spoken command should be played. \n2)User shall get the list of POI\'s which are spoken by user for e.g. \n\n\nObserved result/behavior:\n1) Confirmation prompt of given spoken command is not played.\n2) User not able to select POI via speech commands.\n3)User getting the list of POI destination but user not able to select those point via spoken commands for e.g.

Related

How to change a numeric ID into a sentence in Graylog using pipelines?

I am trying to "beautify" the data I receive from some windows logs on Graylog. My idea is to change the windows log ID from a number to the actual definition for that ID. For example: I receive a log with ID 4625, I want to show in my widget "An account failed to log on".
To do that, I am using a pipeline and a lookup table, which reads the IDs and the respective definitions in natural language from a .csv that I've uploaded on the server.
This is the rule that I wrote for my pipeline, that doesn't seem to work:
rule "eventid_windows_rule"
when
has_field("winlogbeat_winlog_event_id")
then
let winlogbeat_winlog_italiano = lookup("winlogbeat_winlog_event_id", to_string($message.winlogbeat_winlog_event_id));
set_field("winlogbeat_winlog_italiano", winlogbeat_winlog_italiano);
end
I think my problem is specifically in this rule, because Graylog allows to test the lookup tables, and if I manually write an ID, the lookup table finds the respective description.
I solved the issue myself, this is the correct code for the rule:
rule "eventid_windows_rule"
when
has_field("winlogbeat_winlog_event_id")
then
let winlogbeat_winlog_italiano = lookup("eventid_widget_windows_lookup", $message.winlogbeat_winlog_event_id);
set_field("winlogbeat_winlog_italiano", winlogbeat_winlog_italiano);
end
This rule checks if the log has the field "winlogbeat_winlog_event_id", then it generates the new field "winlogbeat_winlog_italiano", associates the numeric value of "winlogbeat_winlog_event_id" with the description in natural language thanks to the .csv that I've created, then puts the description in the field "winlogbeat_winlog_italiano".

Receiving OTP SMS Via AT+CMGL Command (e.g. Whatsapp)

I'm new to GSM AT Commands and I'm using ZTE MF190S USB 3G USB Modem with Modem Nodejs Module also tried with MS Hyperterminal.
The problem I'm facing that when I receive SMS using AT+CMGL="ALL" from Whatsapp (as example) I got in sender number field 81084326797126204 which is an invalid phone number and should be "Whatsapp" instead although the manufacture's software is showing message from Whatsapp normally.
Note: I tried to decode it as a Hexadecimal string but not done.
> AT+CSCS="GSM"
> AT+CPMS="ME"
> AT+CMGL="ALL"
//Result
+CMGL: 0,"REC UNREAD","81084326797126204",,"20/05/30,14:53:55+08"
FEFF000000000000000000000000000000000000020
As described in this link
+CMGL: index,message_status,address,[address_text],[service_center_time_stamp][,address_type,sms_message_body_length]sms_message_body[+CMGL:
...]
The address Field
The third field of the information response of the +CMGL AT command,
address, is a string that contains the address/phone number stored in
the SMS message header. If the SMS message read is an incoming SMS
message, the address field contains the originator address. If the SMS
message read is an outgoing SMS message, the address field contains
the recipient address. Usually the address field value is a phone
number formatted using the typical ISDN / telephony numbering plan
(ITU E.164/E.163). For example, "+85291234567".
The address_text Field
The fourth field of the information response of the +CMGL AT command,
address_text, is a string that contains the text associated to address
in the phonebook. For example, if the text "Alice" is associated to
the phone number "91234567" in the phonebook, address_text will be
"Alice". The AT command +CSCS (command name in text: Select TE
Character Set) can be used to specify the character set for displaying
address_text. Note that address_text is an optional field. Some
GSM/GPRS modems and mobile phones (examples: most Nokia products,
including my Nokia 6021) leave this field empty.
How can I identify the message is from Whatsapp or any other services providers names?
You wrote
The fourth field of the information response of the +CMGL AT command, address_text, is a string that contains the text associated to address in the phonebook
If your device used to recognize that number, it probably was in one of device's phonebooks, and maybe it got deleted.
What you can try to do is to store again the number using AT+CPBW command:
AT+CPBW=[<index>][,<number>[,<type>[,<text>]]]
where
index is the record position in the phonebook. If omitted the record is stored in the first free position
number is the number to be stored in phonebook, in string format
type is the number type; 129 for national scheme, 145 for international scheme
text is the name of the entry in the phonebook
So, in your case:
AT+CPBW=,"81084326797126204",129,"WhatsApp"
And after it you should see the name appearing in +CGML list. You might need a device reboot after the PB write in order to see the change making effect.
The change is done in the current phonebook, usually the SIM card. It can be queried with command AT+CPBS? (it also allows to change it; see the guide for further explanation).
I suggest exploring the content of every phonebook, in order to discover any device (and SIM) default contents. The command to read phonebook entries is **AT+CPBR**. Providing
AT+CPBR=1,N
all index between 1 and N are shown. If you set N to the size of the phonebook, you can list all the entries in it.

Azure Cognitives services speech to text recognition of numeric entities as text

I was wondering if its possible that the c++ sdk of Cognitives services Speech to text to return the numeric entities as text instead of numbers.
Current response 'I want to order 2 Cokes'
Expected response 'I want to order two Cokes'
Of course i can implement a feature to the translation. But i was wondering if its something that the service already provides. Particularly on spanish.
take a look at the sample repository at https://github.com/Azure-Samples/cognitive-services-speech-sdk
especially the file speech_recognition_samples.cpp , function SpeechRecognitionWithLanguageAndUsingDetailedOutputFormat
Enabling ‘detailed output’ will give you the result you want:
config->SetOutputFormat(OutputFormat::Detailed);
Then you need to look at the detailed output:
result->Properties.GetProperty(PropertyId::SpeechServiceResponse_JsonResult)
And that would create detailed output like this:
{"Duration":35500000,"NBest":[{"Confidence":0.7535948753356934,"Display":"I want to order 2 Cokes.","ITN":"I want to order 2 cokes","Lexical":"i want to order two cokes","MaskedITN":"I want to order 2 cokes"}],"Offset":17000000,"RecognitionStatus":"Success"}
The lexical output is probably what you want
Wolfgang

Finding Related Topics using Google Knowledge Graph API

I'm currently working on a behavioral targeting application and I need a considerably large keyword database/tool/provider that enables applications to reach to the similar keywords via given keyword for my app. I've recently found that Freebase, which had been providing a similar service before Google acquired them and then integrated to their Knowledge Graph. I was wondering if it's possible to have a list of related topics/keywords for the given entity.
import json
import urllib
api_key = 'API_KEY_HERE'
query = 'Yoga'
service_url = 'https://kgsearch.googleapis.com/v1/entities:search'
params = {
'query': query,
'limit': 10,
'indent': True,
'key': api_key,
}
url = service_url + '?' + urllib.urlencode(params)
response = json.loads(urllib.urlopen(url).read())
for element in response['itemListElement']:
print element['result']['name'] + ' (' + str(element['resultScore']) + ')'
The script above returns the queries below, though I'd like to receive related topics to yoga, such as health, fitness, gym and so on, rather than the things that has the word "Yoga" in their name.
Yoga Sutras of Patanjali (71.245544)
Yōga, Tokyo (28.808222)
Sri Aurobindo (28.727333)
Yoga Vasistha (28.637642)
Yoga Hosers (28.253984)
Yoga Lin (27.524054)
Patanjali (27.061115)
Yoga Journal (26.635073)
Kripalu Center (26.074436)
Yōga Station (25.10318)
I'd really appreciate any suggestions, and I'm also open to using any other API if there is any that I could make use of. Cheers.
See your point:) So here's the script I use for that using Serpstat's API. Here's how it works:
Script collects the keywords from Serpstat's database
Then, collects search suggestions from Serpstat's database
Finally, collects search suggestions from Google's suggestions
Note that to make script work correctly, it's preferable to fill all input boxes. But not all of them are required.
Keyword — required keyword
Search Engine — a search engine for which the analysis will be carried out. For example, for the US Google, you need to set the g_us. The entire list of available search engines can be found here.
Limit the maximum number of phrases from the organic issue, which will participate in the analysis. You cannot set more than 1000 here.
Default keys — list of two-word keywords. You should give each of them some "weight" to receive some kind of result if something goes wrong.
Format: type, keyword, "weight". Every keyword should be written from a new line.
Types:
w — one word
p — two words
Examples:
"w; bottle; 50" — initial weight of word bottle is 50.
"p; plastic bottle; 30" — initial weight of phrase plastic bottle is 30.
"w; plastic bottle; 20" — incorrect. You cannot use a two-word phrase for the "w" type.
Bad words — comma-separated list of words you want the script to exclude from the results.
Token — here you need to enter your token for API access. It can be found on your profile page.
You can download the source code for script here

Zebra RFD8500 : How to use read in ZETI

I have a Zebra RFD8500 here and I connected to it via the terminal. I am trying to use the ZETI command read to access epc's, but it does not read anything.
But if I use the ZETI command inventory it finds all the tags around.
Anyone knows how to use the read command properly? Also is there some kind of filter per default on?
I am using the developer example on page 174 Link to PDF
Not sure if you solved this problem, but I couldn't find anything else via Google. I had the same problem with using read in ZETI (Zebra RFD8500). The Zebra tech support told me that to use access operations like read and write, you have to turn off dynamic power (which I think is on by default).
Unfortunately, I am not using the iOS API/SDK (writing a custom one for another device), but here's the gist of what you'd be doing:
Turn off dynamic power
Do an inventory
Read some memory bank, like the EPC bank. Optionally, you can also specify access criteria to single out a tag.
To test how this worked in ZETI, I screened into the RFD8500 (on my Mac, doing ls /dev/tty.RFD* lists several ttys, I chose the one ending in "-R"):
screen /dev/tty.RFD8500{long number}-R
Then I issued these commands:
dp .disable
in
rd
Commands:
dp = setdynamicpower
in = inventory
rd = read
After issuing "rd", you should be able to see the user memory banks (the default bank for the "rd" command).

Resources