QnA Maker excel file - qnamaker

Does anyone know how to add or separate two questions to one answer in excel?
example:
Question:
elementary school name, primary school name, school name
Answer:
Critobal Columbus

If you have multiple questions with identical answers, it will group them together in the KB.
So it would look like:
Q: elementary school name
A: Critobal Columbus
Q: primary school name
A: Critobal Columbus
Q: school name
A: Critobal Columbus
Obviously this is not an ideal way to do this, but it has already been submitted as a suggestion for how to improve QnA Maker:
https://cognitive.uservoice.com/forums/578689-qna-maker-api/suggestions/34751899-qna-maker-excel-file-add-more-questions-to-one-an

Related

Identify wrong data [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
We discovered wrong data in one of our table and we would like to identify them.
We have 4 tables:
Student
School
School_Student
Location
The relation between them as follow
Each location has many schools
Each student can be in different schools in the same location
Due that some students have the same name although they are different persons with different ID, we found that some students are assigned to different schools in different locations
You can see in the screenshot that "Adam Mike" is assigned to 3 different schools, the second and the third line are ok because the location of the school is the same however the first line is not ok because the school is in a different location.
so i would like to have a query that returns all students that are assigned to different locations so that i can manually correct them.
Thank you
EDIT
In my last question Find duplication in multi tables
the student cannot be in different school.
To make it more clear.
In this screenshot you see that all records with "?" are not correct because the location is different.
So mike cannot be in a school in USA and in GB
in the otherhand JIM is in different schools but in the same location so this is ok
Now i would like to find all records where students has records in different locations.
Try something like. It returns the students that have more than 1 unique location.
SELECT ss.student_id
FROM school s
JOIN school_student ss
ON s.id = ss.school_id
GROUP BY ss.student_id
HAVING COUNT(DISTINCT s.location_id) > 1

Using LIKE in SQL Server to identify strings

I am writing a program that performs operations on a database of Football matches and data. One of the issues that I have is that my source data does not have consistent naming of each Team. So Leyton Orient could appear as L Orient. Most of the time this team is listed as L Orient. So I need to find the closest match to a team name when it does not appear in the database team name list exactly as it appears in the data that I am importing. Currently in my database I have a table 'Team' with a data sample as follows:
TeamID TeamName TeamLocation
1 Arsenal England
2 Aston Villa England
3 L Orient England
If the name 'Leyton Orient' appears in the data being imported I need to match this to L Orient and get the TeamID 3. My question is, can I use the LIKE function to achieve this in a case where the team name is longer than the name in the database?
I have figured out that if I had 'Leyton Orient' in the table and was importing 'L Orient' I could locate the correct entry with:
SELECT TeamName FROM Team WHERE TeamName LIKE '%l%orient%';
But can I do it the other way around? Also, I could have an example like Manchester United and I want to import Man Utd. I could find this by putting a % sign between every character like this:
SELECT TeamName FROM Team WHERE TeamName LIKE '%M%a%n%U%t%d%';
But is there a better way?
Finally, and this might be better put in another question, I would like not to have to search for the correct team when the way a team is named is repeated, i.e. I would like to store alternative spellings/aliases for teams in order to find the correct team entry quickly. Can anybody advise on how I might approach this? Thanks
The solution you are looking for is the FULL TEXT SEARCH, it'll require your DBA to create a full text index, however, once there you can perform much more powerful searches than just character pattern matching.
As the others have suggested, you could also just have an Alias table, which contains all possible forms of a team name and reference that. depending on how your search is working, that may well be the path of least resistance.
Finally, and this might be better put in another question, I would like not to have to search for the correct team when the way a team is named is repeated, i.e. I would like to store alternative spellings/aliases for teams in order to find the correct team entry quickly. Can anybody advise on how I might approach this? Thank
I would personally have a team table and a teamalias table. Use relationships to marry them up.
I believe the best way to prevent this, is to have a list of teams names displayed in a dropdown list. This will also let you drop validation for the team name. The users can now only choose one set team name and will also make it much easier for you working in your database. then you can look for the exact team name as it appears in your database. i.e.:
SELECT TeamName FROM Team WHERE TeamName = [dropdownlist_name];

Database design for an online quiz

I am designing an online math quiz for a college project and having some trouble with designing my database.
The basic idea of the website is as follows:
A teacher, once registered may log in and add questions to their account. They can choose between making the questions multiple choice OR true or false. They can also choose between making their questions public or private. (If they choose to make the questions public, other teachers may view the questions.)
At any time the teacher may create a quiz for their students using the questions in their private bank and / or questions from the public bank. Each question may be used in multiple quizzes.
The idea is that the students will later log in and do the quiz; their answers are stored and the teacher can generate reports and check how the students did individually / highest and lowest scoring questions etc.
I am having some trouble deciding how to store the quizzes and questions which I hope somebody may be able to help me with.
So far I have the following:
‘Question’ table with attributes: QuestionID, SubjectArea, Concept, QuestionText, TeacherID, QuestionType, PublicYorN
‘MCQuestions’ table with attributes: QuestionID, AnsA, AnsB, AnsC, AnsD, AnsE, CorrectAns
‘TorFQuestions’ table with attributes: QuestionID, CorrectAns
‘Quiz’ table with attributes: QuizID, CreationDate, TeacherID
I think I then need another table as follows:
‘QuizQuestions’ and the only attributes will be QuizID, QuestionID which together make a concatenated primary key.
I feel like I should have a separate table to store answers to questions and I'm not sure if I need to separate true or false questions and multiple choice questions as I have done above.
(Obviously there are other tables containing user data etc. but this is the part I’m concerned with.)
Any advice / input is greatly appreciated!
A simple yet flexible design would be something like this:
Questions table (id, text, correct answer id, all the other question related data)
Answers table (id, question id text, all the other answer related data)
Quiz table (id, text, all the other quiz related data)
Quiz questions table (quiz id, question id, question display order, other related data such as question weight might also be added)
Quiz results table (quiz id, question id, answer id, user id, all the other related data such as date of answer and such).
I think my only input to this open ended question is:
Combine MCQuestions and TorF Questions to have a different format. Answers table has 4 cols. QID, AnswerID,answer,Correct Y/N.
Then a true or false question has 2 rows - eg. QID=888, AID=1,Ans=TRUE,true. Next row is QID=888, AID=2,Ans=FALSE,false.
Multiple choice has several - so which is the bright yellowy thing? QID=889, AID=3,Ans=Moon,false. QID=889, AID=4,Ans=Sun,true. QID=889, AID=5,Ans=Mars,false.
Then you grab a list of answers and can populate a set of radio buttons with the QID and AID values. Then you are matching integers in your code rather than long text strings which will need to be passed around for matching. Might make it a bit easier in case of special chars in the answers or whatever and you're matching the quiz results to a unique key.
Apart from that minor change it's difficult to help without knowing any other constraints...
Nick

Database normalisation - some issues

I am completing some work for Uni and have a single table of data that i need to arrange into 1st,2nd and 3rd Normal Form, i have attempted to do so below but i have hit a brick wall with it.
I would appreciate any helpful input at all as my tutor is away on holiday and I don't want to start the rest of the work using the wrong tables/relations to start with.
Basically the system is supposed to allow users to add films, directors and actors. Allow multiple users to review films and categorise the films by genre.
UNF
**filmID**
title
directorID
categoryID
categoryName
notes
directorName
actorName
actorID
role
userID
userName
reviewDate
reviewText
1NF
**filmID**
title
notes
**directorID**
directorName
**categoryID**
categoryName
**actorID
filmID***
actorName
role
**userID**
userName
**filmID*
userID***
reviewDate
reviewText
2NF
**filmID**
title
notes
**directorID**
directorName
**categoryID**
categoryName
**actorID**
actorName
**actorID
filmID***
role
**userID**
userName
**filmID*
userID***
reviewDate
reviewText
You'll find here on Stack Overflow that people won't answer your homework for you.
However here's a link to a very good tutorial.
Normalisation Tutorial
You'll understand it much better if you work through it and complete it yourself, rather than copying and pasting the answer from here.
Here are some questions for you...
Can an actor also be a director?
Can a film have more than one director?
Can a user review a film more than once?
Are the genres predefined?
Can an actor play more than one role in a film?
It's entirely possible that a database that meets the criteria for 2nd Normal Form also meets the criteria for 3rd Normal Form. It looks like that is the case here.

How to pull data from Facebook hash with multiple entries with Ruby

I have used OmniAuth to connect with Facebook. I am pulling various pieces of information and have no problem pulling information where there is only one type of it. For example, to get the email address, I just place the following in user.rb:
user.email = auth["info"]["email"]
The problem is with multiple entries. For example, for education, there are two results. One is a High School named Punahou School while the other is a College named University of Illinois at Urbana-Champaign.
education:
- !map:Hashie::Mash
school: !map:Hashie::Mash
id: "105510192816251"
name: Punahou School
type: High School
- !map:Hashie::Mash
school: !map:Hashie::Mash
id: "163536409904"
name: University of Illinois at Urbana-Champaign
type: College
I was able to pull the first school using:
if auth["extra"]["raw_info"]["education"]
user.school = auth["extra"]["raw_info"]["education"][0]["school"]["name"]
end
The problem with this is, it only pulls the first school which is the high school. I have a couple of questions here:
If I only want the College, how would I get it to pull University of Illinois at Urbana-Champaign? If there is a high school and college, I would want the code to only pick up whatever school is the college.
Now, let's say I want both the high school and college. How would I pull both and how would I mark that Punahou is the high school and UIUC is the college?
If there are multiple colleges, how would I pull the most recent college entry?
Had a similar question with OmniAuth and LinkedIn, came across your question and it helped me come up with a solution. LinkedIn's hash returns the three current positions in a form similar to Facebook's behavior above. Change [0] to [1] and it will pull the college in your example. Use separate lines for each entry you want. I found the LinkedIn hash returned the three current positions in order with the most recent entry being in the [0] position.