Creating fake data using Faker library Python - random

Is there a way to create fake data other than the "providers" included in Faker library? For instance, can I generate "First name", "Last name", "Register numbers", "Score on Math exam", "Score on Physics exam", etc.?

Related

How to make DFDL model to JSON data?

I learn App Connect Enterprise v11 and try to make a DFDL Schema for JSON data and I do not know how. I successfully made a Schema for Record-Oriented-Text like the below but do not know how to do it for JSON.
Record-Oriented-Text example:
Delivery+++XYZ123ABC+++My order was delivered in time, but the package was torn|C01-COM684a2da-384+++Your complaint has been received
JSON example:
{
"YourComplaint": {
"Type": "Delivery",
"Reference": "XYZ123ABC",
"Text": "My order was delivered in time, but the package was torn"
},
"Reply": {
"OurReference": "C01-COM684a2da-384",
"Text": "Your complaint has been received"
}
}
You should not create a DFDL schema for JSON data. ACE can parse JSON without any help from a schema. You should use the JSON parser/domain for JSON (just as you use the XMLNSC domain for XML).
If you need to output your record-oriented data as JSON then you need to map from InputRoot.DFDL to OutputRoot.JSON. You may also need to set some field types to ensure that the JSON data looks exactly how you need it.

Dispatch CLI not passing Entities from Luis App

When generating a Dispatch model using the CLI, it doesn't pass the Entities from the Luis app in reference. This drastically affects the accuracy of the dispatch app.
For example, for the utterance "My [iPhone] isn't working", iPhone is attached to an entity list name CellPhoneType. There are three items in the list iPhone, Samsung, Smartphone.
In the bot emulator, using the Dispatch, if I write "my iPhone isn't working", the dispatch model passes it to Luis, as it should. However, if I write "my smartphone isn't working", the dispatch tool sends it over to QnA Maker.
I checked the model, and the entities are not passed in reference. I also tested with simple entities, they do not work as well.
I have the most recent version of the CLI installed.
Is this normal, is this a bug? Is there a work around to fix this?
So a couple things to address here with how you've built your LUIS model and what to expect from dispatch. Skip down to 2.) if you're a user who's reading this post and already has entities working in child LUIS models beautifully. #AlexandreViegas, read point 1.) to help properly build your LUIS model to detect intent properly in dispatch.
1. Use a Simple Entity + Phrase List to take Advantage of LUIS's machine learning--not List Entity
Right now it seems like your choice of using a list entity is not the best way to go here, and not how it's intended to be used. Instead list entities are used for terms that might have multiple ways of referring to the same thing.
Examples of When You Would Want to Use a List Entity
For example, California, Cali, CA, and The Golden State are all terms that refer to the same thing (a state). You can create a "States" list entity, include all 50 U.S. states and their nicknames. Now since this is a closed, explicit list, there is no machine learning when you use a list entity--LUIS will only detect "States" list entity if there's an exact text match.
Another example of when you would want to use list entities would be say with "Departments" for a school. You could have "chemistry", "CHEM142", "chem", etc. all meant to refer to that specific department, and do so with the rest of the departments in the school.
Why you want to use a Simple Entity and add a Phrase List
You can refer to this other StackOverflow answer I wrote, regarding how to create a simple entity and boost the signal of the entity using a phrase list.
To not completely duplicate the answer given in the link above, in essence, you want to use a simple entity, so LUIS can properly predict terms as CellPhoneType entity, even though you did not explicitly include it in your model.
For example you could have a Phone intent with utterances labeling various words as CellPhoneIntententity.
When I go to the Test panel, I type in "sunflower" and "moonstone" as made up mobile phones (maybe some phone company in the future creates phones with these names as their models):
Above you can see LUIS correctly predicts Phone intent and correctly extracts sunflower and moonstone as CellPhoneType entities.
However if I enter in brand names of mobiles that don't exist in the English language--for example Blackberry's "Z3" or T-Mobile's "G2X", LUIS cannot detect this with our model as is right now. (See 2 most recent utterances).
Above you can see utterances "i'd like to order a z3" and "my g2x is broken" do not properly predict as Phone intent, nor do z3 or g2x get detected as CellPhoneType entity. This is where phrase lists come in. As specified in the docs, phrase lists are good for boosting the signal of what a cell phone type may look like, as well as adding proprietary or foreign words to your LUIS model, such as the "made-up" words of many cell phone models. Again, refer to the StackOverflow answer I linked to, if you need guidance on how to create a phrase list.
After adding different names of cell phone models to phrase list
2. Query the endpoint of the LUIS model that was created by dispatch directly
Clarification:
When you add a child LUIS model to dispatch, even if that child LUIS model has entities in it, it will not show up in the model of the parent LUIS model created by dispatch.
the exception to the above bullet would be if you labelled an entity in a pattern
Why entities do not need to be labelled in the parent LUIS model, is because when you call the endpoint of the parent LUIS model, it does sort of a shared call, under the hood, so it doesn't have to ping LUIS twice.
You see the entities labelled from the child LUIS model in the connectedServiceResult property
How to extract entities from child LUIS model, using your parent dispatch LUIS app
Make sure to publish both the child LUIS app and the parent dispatch app.
Going to your parent dispatch-created LUIS app, go to Manage > Keys and Endpoints > click "Endpoint" to open a browser tab where your can query the parent app in the URL after q=
type in your utterances in the URL, after q= to see the entities and intents extracted from the child LUIS model under connectedServiceResult
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?verbose=true&timezoneOffset=-360&subscription-key=b7xxxxxxxxxxxxxxxxxxxxxxxxxxxx67&q=my%20iphone%20is%20broken
{
"query": "my iphone is broken",
"topScoringIntent": {
"intent": "l_Reminders",
"score": 0.99594605
},
"intents": [
{
"intent": "l_Reminders",
"score": 0.99594605
},
{
"intent": "None",
"score": 0.002990469
}
],
"entities": [],
"connectedServiceResult": {
"query": "my iphone is broken",
"topScoringIntent": {
"intent": "Phone",
"score": 0.9658808
},
"intents": [
{
"intent": "Phone",
"score": 0.9658808
},
{
"intent": "Calendar.Add",
"score": 0.0142210266
},
{
"intent": "Calendar.Find",
"score": 0.0112086516
},
{
"intent": "None",
"score": 0.009813501
},
{
"intent": "Email",
"score": 0.0025855056
}
],
"entities": [
{
"entity": "iphone",
"type": "CellPhoneType",
"startIndex": 3,
"endIndex": 8,
"score": 0.998970151
}
]
}
}
Above you can see that the parent LUIS app created from dispatch properly identifies iphone from the utterance my iphone is broken as a CellphoneType entity.
Note: you will not see results from the child LUIS model in the Test panel of the parent dispatch, because the UI does not show connectedServiceResult

Preselect drop down list when a value selected in sugarCRM

I have two drop down lists, lets say: "Job Types" and "Person in charge".
When users choose a "Job type" it will preselect the "Person in charge".
Example:
Job Types:
Finance
Computer
Sundry
Person in charge:
Alice
Bob
Celion
David
Eason
When i choose "Finance", "David" will be pre-selected.
When i choose "Computer", "Celion" will be pre-selected.
...
How to customize this in SugarCRM? in Logic hook? or metadata?
Thanks.
If you have access to SugarCRM Professional's Sugar Logic, you might start here: http://www.profilingsolutions.com/archive/dropdowns-using-sugarlogic-formul/
This article uses a logic statement like related($accounts,"account_type") but you could write out a series of equal/if/then statements to check fieldA for various values.
More on Sugar Logic: http://support.sugarcrm.com/02_Documentation/01_Sugar_Editions/04_Sugar_Professional/Sugar_Professional_6.7/Administration_Guide/07_Developer_Tools/01_Studio#Using_Sugar_Logic
If you are using SugarCRM CE, you won't have access to Sugar Logic. In that case, I find the easiest thing to do is adjust the module's editviewdefs to include custom JavaScript that monitors the field(s) and sets the values. Check /modules/Notes/metadata/editviewdefs.php for an example on including JavaScript in your edit view metadata.
One more caveat: if you were to use Sugar via it's API, it will ignore any thing you do to the UI view. You'll need to do this within a Logic Hook as well to enforce it throughout the system.

Building a database with Rails + Postgresql + Heroku

I'm building a web app where the user's need to choose from a database of exercises. They should be able to see the exercise name, description, and skill level. What is the best practice for building a database table for this purpose?
I'm thinking I could write each exercise and its attributes in a CSV file, then write a ruby script that would parse it and create an exercise object in the database table for each exercise that it parses. However, I have never done this before and would appreciate feedback.
And how would I migrate this database table from development to production on Heroku?
Thanks so much for any info.
Sounds like an Exercise model with name, description, skill level, and something to store the actual exercise. It is up to you to figure out whether you want to read it in with csv or yaml - I agree that yaml would be easier. Also how to store the user's responses - hstore, json, serialized yaml...
I ended up creating an array of hashes and iterating over the array in seeds.rb:
[
{
:name => "",
:description => "",
:skill_level => ""
},
# Input more hashes below
].each do |exercise|
ExerciseDb.create(
name: exercise[:name]
description: exercise[:description]
skill_level: exercise[:skill_level]
)
end

How to use named Machinist blueprints in Cucumber with Pickle

I noticed this little tid-bit in the readme for pickle:
(The latest version of pickle supports multiple
blueprints, for earlier versions of machinist use pickle <= 0.1.10)
I'm running in to a situation where I want to create a user with admin privileges. I've got two machinist blueprints:
User.blueprint do
first_name
last_name
email
password { "password" }
password_confirmation { "password" }
state "active"
end
User.blueprint(:super_admin) do
roles { ["super-admin", "moderator"] }
end
Rather than creating a custom step for myself to create the super-admin user, I was wondering if there's a way to do it using Pickle.
Using the following will use the normal pickle step and reference the basic machinist User blueprint:
Given a user exists with first_name: "Test", last_name: "Man"
The question is, how do I say that I want a super-admin user?
Not sure how this would be done in Pickle, with the very similar gem Cucumber Factory you could create a super-admin user like this:
Given there is a user (super admin) with the first name "Test" and the last name "Man"
So it turns out that creating named Machinist blueprints in Pickle is pretty simple:
Given a super admin user exists with first_name: "Test", last_name: "Man"
This line will call the same pickle step, but Pickle is intelligent enough to map the text "super admin user" to the User.blueprint(:super_admin) factory.
It's such an obvious method that I really should have just tried it before asking. The documentation for Pickle doesn't explicitly mention the syntax for doing this anywhere, only that it's possible to do. So now we know.

Resources