I am developing an application in iOS where I need to add a functionality to switch the application language in Chinese/English.
I am using Baidu API to achieve this. I am able to translate single world or complete one sentence. But suppose my has multiple text which I need to place at diff location then either I have to hit the API multiple times or by wrapping all into one API.
I have followed their documentation but nothing seems work.
As per their documentation.....
1. How do I translate multiple words or more text in a request?
You can use the newline (in the majority of the programming language for the escape symbol \ n) in the sent field q to separate the multiple words or pieces of text to be translated so that you can get multiple words or multiple text independent translations The result. Note that before sending the request to the q field do URL encode!
And I am trying to get the result for this....
appid = 2015063000000001 + q = apple + salt = 1435660288 + key = 12345678
Let me give an example: Suppose I need to convert two different word. “apple” and “mango”
2015063000000001+apple\ nmango+1435660288+7_8ogRLnl7PO52O0UYd2
2015063000000001apple\n mango143566028812345678 (Get the MD5 = c0610b314af72e42a4a5b9e62757faf7)
http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple\nmango&from=en&to=zh&appid=2015063000000001&salt=1435660288&sign=c0610b314af72e42a4a5b9e62757faf7
When I am hitting above url on chrome then getting this result.
Result : {"error_code":"54001","error_msg":"Invalid Sign”}
Now I got the answer for my question.
In URL replace "\n" with URL encode "%0A".
Also generate MD5 via the code not from online.
Related
I'm using Google Cloud Speech API with IBM Voice Gateway in order to interact with a VoiceBot through a phone.
If I say an identifier contening letters and numbers through the phone, the Google Cloud Speech converts it into string with spaces. For example, if I say "A1B2C3", it will convert it into the following string "a 1 b 2 c 3".
Do you know if there is way to avoid these useless spaces ?
Thanks for your help!
Lucas
I don't see any way in which you can eliminate spaces from the API response. What you could do is experiment with the available features, as this is probably your best chance to get a recognition more similar to what you are looking for.
For example: you can provide some sample hint phrases echoing your use case, indicate that the audio is a phone call, or use an enhanced model (although for the latter to be available you need to first opt in for data logging).
Honestly though, for your case, it might be better if you post process the returned string (e.g. with a simple "a 1 b 2 c 3".replace(' ','') ).
I need a way to extract the Salesforce record ID from a URL using Zapier Push. How can I find the first 3 characters in a string that match the start of the Id like 006 and then return a set number of characters after that?
The url is formatted as such:
https://useindio.lightning.force.com/lightning/r/Opportunity/006f400000AiVufAAF/view
David here, from the Zapier Platform team. Good question!
Whenever you want to extract data from a string and you know the exact format the string will be in, Regular Expressions are the answer.
Assuming you want to grab anything after 006 (and you know it'll always be there), you could use the regex 006(\w{15}) (more info), which will find the 15 characters after that. If you know the surrounding url will always be the same, you could easily grab the whole ID by anchoring via Opportunity and view: \/Opportunity\/(.*)\/view (more info).
Either way, there's info about setting up a formatter zap here, or you could do it in code (JS Example, Python Example).
Let me know if you've got any other questions!
I'm making a list of the videos of my channel, and want to use the search endpoint of the API : https://developers.google.com/youtube/v3/docs/search/list
Ther eis a "q" parameter to send the query. What completely bugs me is that no wildcard is referenced in the documentation, and when using * it doesn't do anything. For example, in order to find any video containing "television" in the title, the full word has to be input ! Sending "tel" won't work, nor sending "televisio".
Did I miss something ? Is there a way around this ?
Thanks !
YouTube searching works along the same paradigm as Google searching, which is quite a bit different than the character-wildcard keyword approach. It's semantic probabilistic searching, looking for relevance based on the terms you give it, so while the * does represent a wildcard, it represents a whole word. For example, you can search for "a * saved" and it will return to you the videos which score the highest relevance score where any word could be substituted in place of your wildcard.
You can also use other punctuation based search operators ... the + sign, - sign, quotation marks, etc. Just make sure they're all URL encoded before you send the query in.
I have a file that contain twitter post and I am trying to identify the structure of the twitter post per line, like get the noun ,verb and stuff, using opennlp.
it work perfectly until it reach line that contain hashtag and link only
example :
#birthday www.mybirthday/test/mypi.com
and give error com.cybozu.labs.langdetect.LangDetectException: no features in text
when I write a sentence next to the line it just work. any idea how to handle it?? there are more then thousand line that almost like the example.
To use the POS tagger, you need to pass tokens, (in laymen terms say individual words). The link contains multiple words separated by a slash /. The link in itself is not associated with any Part Of Speech. See here the list of tags and how they are assigned to a word. If you want it to identify your link, and give a separate tag to it, say LN either give your own training data, here you will know how to create the training dataor separate the words in the link as separate token (you can separate a link by slash/, question mark?, equal to sign = or ampersand (&)) to get the underlying words and then use the POSTagger to get Part Of Speech (similar case for the hash tag.) For tokenization also, you can use opennlp tokenizer and for your special case, train it. Go through the documentation, it will help you a lot.
I've seen a number of QR codes that contain a URL but also have extra some text after it. Something like:
http://www.example.com Thanks for scanning this QR code!
I've experimented with using a number of different delimiting methods (several spaces, a question mark, two dashes, one or two returns) and all work to varying degrees on various scanning programs.
Some respect the space character, others respect the return. Some think the URL isn't a URL at all when I use a return. Long story short, it's all over the map how the various scanning programs (NeoReader, iNigma, Qrafter, Beetag, OptiScan, etc.) treat characters after a URL.
Is there any consensus on weather (a)this is even a good idea or not and (b)if so, what is the 'correct' (best practice) way to do it? (I know I should go read the RFC for the exact definition of a URL but since the reader programs are all over the map, I suspect they didn't read it either.)
You can make it work by converting the text message into valid URL, while trying to keep readability.
In your case it can be:
http://www.example.com?Thanks_for_scanning_this_QR_code
It's not perfect, but it can help on web analytics side to distinguish all QR code users.
Spaces are definitely not part of a URL, so, in that sense a space definitely should delimit the end of a URL.
The entire string is not a URL, taken as a whole of course. So yes it's asking for trouble.
As you've found, the empirical answer is that not every reader does what you want. Barcode Scanner for instance understands the split here, but does not prompt the user to launch the browser since the payload isn't a URL per se.
So: it's a bad idea.