How to use create a Custom class to format phone number in Google Speech-to-Text api? - speech-to-text

I'm using Google Speech-to-Text api in order to transcribe phone calls in Hebrew.
Most of the phone calls contains customers that tells their phone-number, can I make some custom class in-order to format these numbers with the correct way?
Other example can be formatting an order-id which has a specific format.
I've read this article https://cloud.google.com/speech-to-text/docs/adaptation-model#custom_classes which tells that it can be a list of items...
What is the difference between class & phrase list?

PhraseSet indeed contain field phrases which is list of Phrase objects. The object contain two fields: value and boost (reference).
Now, in field value, is the phrase itself and is string. But instead of string value you can define and use CustomClass there, which in fact is a list of phrases (reference). So it works, when you want to add the same boost value to whole list of items. Example from the documentation mentioned by you is one of the best:
For example, you want to transcribe audio data that is likely to
include the name of any one of several hundred regional restaurants
Without custom class you would have to add all hundred names with seperate boost value. Instead you can create a list of values using CustomClass and assign one boost value for all of them. Additionally CustomClass can be managed independently to PhreaseSet.

Related

How do I create a Dialogflow custom entity that works like #sys.airport?

Since #sys.airport only exists for the default English locale, I want to create a custom entity that emulates it for other locales.
From what I've read here, you can put subentity types into the value fields, say, the system entity #sys.geo-city:city and a custom entity #usr.iata-code:iata, and it will match either one or the other.
But I don't understand how you would tell Dialogflow which city and which IATA code go together, so that Dialogflow (ES) would know to send the complete object {"city":"Amsterdam", "iata": "AMS"} to the webhook after matching either "Amsterdam" or "AMS", as it does happen with #sys.airport.
Thanks for any input!
It will be difficult to create a custom entity that works just like #sys.airport. The #sys entities are special and can do somethings custom entities can't, for instance, pairing values together.
As you pointed out, you can put multiple entities together in one single entity by using Composite Entities, but the only thing this does is allow you to recognize two values made up from other #sys or custom entities in a single entity. It doesn't give you the option to create pairs between the values of the entities.
If you would want to create something like this, you would need some code that does a look up in a dictionary or list. So when "AMS" is matched, the code fills in the missing property "Amsterdam" or vice versa.

Kentico 12 Azure Search

I'm trying to implement Azure Search on Kentico 12. Following the article below.
https://docs.kentico.com/k12/configuring-kentico/setting-up-search-on-your-website/using-azure-search/integrating-azure-search-into-pages
However, I have multiple indexes defined on the smart search not just a single index code name that I can hard code and also cannot aford to hard code index fields. Is there any tutorial out there that I can follow?
It sounds as if you're referring to building an Azure Search web part, is this correct. If so, make a property in your web part which allows you to select the code name from a list in the database. Secondly, regarding field names, you should be using generic field names like DocumentName, NodeAliaspath, etc. Although if you have very specific search results that need to be displayed, simply put in a switch statement to get the field names based on a class name.

Translator vs Cell Decorator in hybris, which one is preferred in what situation

I know how to write and use Cell Decorator and Translators during impex imports
in hybris, However, I am not sure when the one is preferred over the other?
For example, I have used Cell Decorator to change the value of an attribute slightly like if a customer is from US I will append an '_US' at the end of customer number while inserting in the DB.
Similarly, I have used Translator when I need to find a status of a product Available/Out of stock based on product ID.
However, I am not 100% positive is this the only differentiation.
Any explanation with example will be appreciated.
What is a translator?
(from SAP documatentation):
A translator class is a converter between ImpEx-related CSV files and values of attributes of Hybris Commerce items
The translator is a "converter" it is used when you need to modify your data into some other kind of data.
What is a decorator?
(From Wikipedia)
The decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
What should be used in hybris
For Impex most of the time you want to use a translator because you want to use simple syntax in the Impex file and convert( ie. translate/modify) it to the target format using code.
When you need to add functionality to an existing feature use a decorator. It can be used in Impex too if you want to add data.
For example you can read the Wikipedia article for decorator, in hybris you can look at ChineseLogisticCellDecorator. For translators, you have the list in hybris documentation (mentioned above)

management of big number of parameters of a keyword in VBscript

I'm working on test automation using keyword driven framework. I have to add a keyword add_car. This keyword needs a big number of parameters that should be entered in the excel sheet as parameters for this keyword.
I want to find a solution to manage the big number of parameters(some of them are always required and the others are optional)
The below picture is an example of how the values of parameters are entered in the Excel sheet.
excel sheet example
Here is how I call this keyword in UFT
keyword Call in UFT
And in my Functions Library, I defined the instructions of my_keyword.
Is there any solution to manage this big number of parameters(I have more than 30 parameter in general some are optional and others are always required).
I'd advise walking through your worksheet to get all parameters and store them into a dictionary. Then you would call your functions by calling the dictionary instead of all parameters individually.
The way to manage all of the parameters to add them into dictionary would have to be handled in a separate function and you could then check if the parameters exist/have values inside your functions or even externally. It would actually be kind of a whole new framework just to work with it, but when you're done, you could reuse the functions anywhere you wanted.
At least that was the way implemented in the project I've worked (though I was not the one to implement it).
It is hard to provide a thorough answer about the topic because it is pretty extensive, but for starters, I'd recommend this link about working with dictionaries:
http://automated-360.com/qtpuft/advanced-concepts/everything-dictionary-object/
In a very brief way, Dictionary objects are sort of a collection of Key,Item pairs, where you could store your parameters like Parameter1,ParameterValue to use later.
It also allows you to sort your parameters, check for existence, store them in a Case Insensitive way, edit them, delete them and so forth.
This is what I can offer to you now.
Happy research and happy coding.
Not sure how many parameters do you have.
However, I have 600+ parameters required for 1 test case (I know... It's a huge end to end test that takes loads of parameters).
I have used different tabs in excel sheet to logically separate the test data parameters.
I read the excel as database (using ADODB.connection) and query each tab in excel to get the row that I need. I can write SQL join to query from multiple excel tabs at once.
Reference on reading excel as DB:
http://www.automation.ultimatetimepass.com/index.php/home/qtp/excel/qtp-read-excel-using-adodb-connection/10-qtp-excel
Few thoughts on this.
Possible solution 1: Text File Approach
You will have all the parameters are stored with key,value combination like given below in the text file.
Parameter1=abc
Parameter2=def
Parameter3=ghi
The advantage here is when any of your parameter not needed, just remove from the text file.That being said, Your framework engine should read the keyword "ReadFile" as function and return a collection of string from file.
sParameterList = ReadFile("")
Possible solution 2:
Define all the parameters with comma separated value.Split and pass it your function call.
Parameter1=abc,Parameter2=def,Parameter3=ghi

JSF displaying entities with IDs: how to translate IDs to descriptions?

In a JSF page I have to display the data from an entity.
This entity has some int fields which cannot be displayed directly but need to be translated into a descriptive string.
Between them some can have a limited number of values, others have lots of possible values (such as a wordlwide Country_ID) and deserve a table on the Db with the association (ID, description).
This latter case can easily be solved navigating via relationship from the original entity to the entity corresponding to the dictionary table (ID, description) but I don't want to introduce new entities just to solve translations form ID to description.
Besides another integer field has special needs: the hundred thousand number should be changed with a letter according to a rule such as 100015 -> A00015, 301023 -> C01023.
Initially I put the translation code inside the entity itself but I know the great limits and drawbacks of this solution.
Then I created a singletone (EntityTranslator) with all the methods to translate the different fields. For cases where the field values are a lot I put them inside a table which is loaded from the singletone and transformed in a TreeMap, otherwise the descriptions are in arrays inside the class.
In the ManagedBean I wrote a getter for EntityTranslator and inside the jsf I use quite long el statements like the following:
#{myManagedBean.entityTranslator.translateCountryID(myManagedBean.selectedEntity.countryID)}
I think the problem is quite general and I'm looking for a standard way to solve it but, as already stated, I don't want to create new 'stupid' entities only to associate an ID to a description, I think it is overkill.
Another possibility is the use of converters Object(Integer) <-> String but I'm more comfortable in having all the translation needs for an Entity inside the same class.
Your question boils down to the following simple line:
How can I display a field different from id of my entity in my view and how can I morph an integer field into something more meaningful.
The answer is that it depends on a situation.
If you solely want to input/output data, you don't need id at all apart from the possible view parameter like ?id=12345. In this case you can input/output anything you want in your view: the id is always there.
If you want to create a new entity most possibly you have a way of generating ids via JPA, or database, or elsehow besides the direct input from the user. In this situation you don't need to mess with ids as well.
If you want to use information on other entities like show user a dropdown box with e.g. a list of countries, you always have the option to separate label (let it be name) and value (let it be id), or even have a unique not null column containing the country name in your database table that will serve as a natural identifier. If you'd like to get data from the user using an input text field you always can create a converter that will do the job of transforming user input strings to actual entity objects.
Regarding the transformation of your integers, you've actually got several choices: the first one is to attach a converter for these fields that will roughly do 301023 -> C01023 and C01023 -> 301023 transformations, the second one is to write a custom EL function and the third one is to prepare the right model beforehand / do the transformations on-the-fly.

Resources