Skip to content
Snippets Groups Projects
Commit 8a8d5485 authored by pabvald's avatar pabvald
Browse files

Init commit

parent 0c80bd33
Branches
No related tags found
No related merge requests found
#!/usr/bin/env python
# coding: utf-8
# Imports
import json
import spacy
import numpy as np
import sys, getopt
def sentence_embedding(sentences):
""" Computes the embeddings of a list of sentences, omitting
stop_words and punctuation symbols """
nlp = spacy.load("en_core_web_lg")
sentence_embeddings = []
for doc in nlp.pipe(sentences, disable=["tagget", "parser", "ner"]):
tokens = list(filter(lambda t: t.has_vector and (not t.is_punct) and (not t.is_stop), doc.doc))
vectors = list(map(lambda t: t.vector, tokens))
embedding = np.average(vectors, axis=0)
sentence_embeddings.append(embedding)
return np.array(sentence_embeddings)
def save_as_json(file_name, data):
""" Saves the provided data as a json file """
with open(file_name, 'w', encoding='utf8') as fout:
json.dump(data , fout, indent=4, sort_keys=True, ensure_ascii=False)
def read_json(file_name):
""" Reads a json file and returns it content """
with open(file_name, 'r', encoding='utf8') as file:
data = json.load(file)
return data
def main(argv):
""" MAIN """
input_file = ''
output_file = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
except getopt.GetoptError:
print('add_embeddings -i <input_file.json> -o <output_file.json>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('add_embeddings -i <input_file.json> -o <output_file.json>')
sys.exit()
elif opt in ("-i", "--ifile"):
input_file = arg
elif opt in ("-o", "--ofile"):
output_file = arg
qa_pairs = read_json(input_file)
questions = list(map(lambda pair: pair['question'].lower(), qa_pairs))
q_embeddings = sentence_embedding(questions)
# Add embeddings
for i in range(len(qa_pairs)):
pair = qa_pairs[i]
pair['embedding'] = q_embeddings[i].tolist()
# Save QA pairs with embeddings
save_as_json(output_file, qa_pairs)
if __name__ == '__main__':
main(sys.argv[1:])
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env python
# coding: utf-8
# IMPORTS
import os
import pandas as pd
from re import sub
from json import dump
from bs4 import BeautifulSoup
from urllib import error
from urllib.request import Request, urlopen
from functools import reduce
# GLOBAL VARIABLES
DIR_NAME = 'raw_html'
OUTPUT_ROOT_NAME = "qa_pairs"
INTREL_ROOT_NAME = "intrel"
DOCTORATE_ROOT_NAME = "doctorate"
INTREL_URLS = ['https://relint.uva.es/internacional/english/students/welcome-guide/faq/',
]
DOCTORATE_URLS = ['https://escueladoctorado.uva.es/export/sites/doctorado/faqs/AAFF/?lang=en',
'https://escueladoctorado.uva.es/export/sites/doctorado/faqs/admisionYMatricula/?lang=en',
'https://escueladoctorado.uva.es/export/sites/doctorado/faqs/PD/?lang=en',
'https://escueladoctorado.uva.es/export/sites/doctorado/faqs/tesis/?lang=en',
'https://escueladoctorado.uva.es/export/sites/doctorado/faqs/financiacion/?lang=en',
]
# FUNCTIONS
def gen_file_path( root, i):
""" Combines a root name and an index into an HTML file name """
return "{}/{}{}.html".format(DIR_NAME, root, i)
def download_files():
""" Downloads html files if they don't exist and saves
them in the specified directory.
"""
# Create directory
try:
os.makedirs(DIR_NAME)
except FileExistsError:
# Directory already exists
pass
# Download UVA International Relationships FAQs
for i, url in enumerate(INTREL_URLS):
file_path = gen_file_path(INTREL_ROOT_NAME, i+1)
try:
fin = open(file_path, 'rb')
fin.close()
except FileNotFoundError:
# File doesn't exist
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
webContent = urlopen(req).read()
fout = open(file_path, 'wb')
fout.write(webContent)
fout.close()
# Download UVA Doctorate School FAQs
for i, url in enumerate(DOCTORATE_URLS):
file_path = gen_file_path(DOCTORATE_ROOT_NAME, i+1)
try:
fin = open(file_path, 'rb')
fin.close()
except FileNotFoundError:
# File doesn't exist
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
webContent = urlopen(req).read()
fout = open(file_path, 'wb')
fout.write(webContent)
fout.close()
def process_a_tags(content):
""" Processes each <a> tag extracting its 'href' attribute and adding
it between parenthesis after the text. It considers the existence
of a <base> tag.
"""
base = content.find('base')
for a in content.find_all('a'):
if a.previousSibling:
href = a['href']
text = a.get_text()
if base != None:
url = urljoin(base['href'], href)
else:
url = href
a.previousSibling.replaceWith(a.previousSibling + " {} ({}) ".format(text, url))
a.extract()
def extract_qa_pairs_intrel(page):
""" Extracts all the QA pairs of a intrelX.html file and
creates a list of dicts with 'answer', 'question' and 'section' values
"""
qa_pairs = []
content = BeautifulSoup(page, "html.parser")
process_a_tags(content)
sec_titles = list(map(lambda x : x.get_text(),
content.find_all('div', class_='elementor-clearfix')))
sec_contents = content.find_all('div', {'data-accordion-type':'accordion'})
for sec in range(len(sec_titles)):
q_is = sec_contents[sec].find_all('i', class_='fa-accordion-icon')
q_spans = reduce(lambda a, b: a+b, list(map(lambda x : x.find_parents('span'), q_is)))
sec_questions = list(map(lambda x : x.get_text(), q_spans))
sec_answers = list(map(lambda x : x.get_text(),
sec_contents[sec].find_all('div', class_=['eael-accordion-content', 'clearfix'])))
for p in range(len(sec_questions)):
qa_pairs.append({'question': sec_questions[p],
'answer': sec_answers[p],
'page': 'relint',
'section': sec_titles[sec]
})
return qa_pairs
def extract_qa_pairs_doctorate(page):
""" Extracts all the QA pairs of doctorateX.html file and
creates a list of dicts with 'answer', 'question' and 'section' values
"""
qa_pairs = []
content = BeautifulSoup(page, "html.parser")
sec_title = content.find_all('div', class_='headline')[1].get_text()\
.replace('Frequently asked questions about ', '')\
.replace('Frequently Asked Questions about ', '')
sec_content = content.find_all('div', class_='panel-group acc-v2')[1]
sec_questions = list(map(lambda x: sub('\n[\t]+[\s]+', '', x.get_text()),
sec_content.find_all('a', class_='accordion-toggle')))
process_a_tags(sec_content)
sec_answers = list(map(lambda x: x.get_text().replace('\n', ''),
sec_content.find_all('div', class_='panel-body')))
for p in range(len(sec_questions)):
qa_pairs.append({'question': sec_questions[p],
'answer': sec_answers[p],
'page': 'doctorate',
'section': sec_title,
})
return qa_pairs
def extract_qa_pairs():
""" Extracts all the QA pairs and creates a list of dicts with
'answer', 'question' and 'section' values
"""
qa_pairs = []
for i in range(len(INTREL_URLS)):
file_path = gen_file_path(INTREL_ROOT_NAME, i+1)
with open(file_path, "r") as fin:
page = fin.read()
qa_pairs.append(extract_qa_pairs_intrel(page))
for i in range(len(DOCTORATE_URLS)):
file_path = gen_file_path(DOCTORATE_ROOT_NAME, i+1)
with open(file_path, "r") as fin:
page = fin.read()
qa_pairs.append(extract_qa_pairs_doctorate(page))
return list(reduce(lambda x,y: x+y, qa_pairs))
def save_as_json(file_name, data):
""" Saves the provided data as a json file """
with open('{}.json'.format(file_name), 'w', encoding='utf8') as fout:
dump(data , fout, indent=4, sort_keys=True, ensure_ascii=False)
def save_as_csv(file_name, data):
""" Saves the provided data as a csv file """
questions = list(map(lambda p: p['question'], data))
answers = list(map(lambda p: p['answer'], data))
sections = list(map(lambda p: p['section'], data))
d = {'Section': sections, 'Question': questions, 'Answer': answers }
df = pd.DataFrame(data=d)
df.to_csv('{}.csv'.format(file_name), sep='\t', index=False)
def main():
""" MAIN """
download_files()
qa_pairs = extract_qa_pairs()
save_as_json(OUTPUT_ROOT_NAME, qa_pairs)
save_as_csv(OUTPUT_ROOT_NAME, qa_pairs)
if __name__ == '__main__':
main()
\ No newline at end of file
Section Question Answer
STUDIES AT THE UNIVERSITY OF VALLADOLID CAN I DO A STUDY EXCHANGE AT THE UNIVERSITY OF VALLADOLID? You should find out whether there is an exchange agreement between our universities. To do this, you should contact incoming@uva.es (mailto:incoming@uva.es) If there is no agreement between our universities, you can always come as a Visiting student (http://relint.uva.es/internacional/english/students/visitors-programme/) .
STUDIES AT THE UNIVERSITY OF VALLADOLID WHICH COURSES CAN I TAKE AT THE UNIVERSITY OF VALLADOLID? You can choose the courses you like from any academic course or academic year. You can also even take courses from various curricula and from different faculties at the same time. However, you must make sure that your coordinating teacher accepts your choices when signing your studies contract or Learning Agreement.Whatever you opt to do, you should take at least one course from the University of Valladolid faculty you have chosen.
STUDIES AT THE UNIVERSITY OF VALLADOLID CAN I CHOOSE COURSES FROM ANY TERM OR SEMESTER? No, you can only choose courses taught during the time you are at our university.If you are here between September and February, you can choose courses taught in the first term or semester.If you are here between February and June, you can choose courses taught in the second term or semester.If you are here from September to June, you can choose any course, including full-year courses.
STUDIES AT THE UNIVERSITY OF VALLADOLID CAN I CHOOSE FULL-YEAR COURSES IF I STUDY AT THE UVA FOR A TERM OR A SEMESTER? No. Full-year courses are taught continuously from September until June. You are not allowed to take them if you are only going to be here during the first or second semester.
STUDIES AT THE UNIVERSITY OF VALLADOLID CAN I CHOOSE COURSES FROM VARIOUS FACULTIES AT THE SAME TIME? Yes, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement. However, you must always take at least one course from the University of Valladolid faculty you have chosen.
STUDIES AT THE UNIVERSITY OF VALLADOLID CAN I TAKE COURSES AT VARIOUS CAMPUSES AT THE SAME TIME? You may only choose courses from the Valladolid and Palencia campuses at the same time, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement. All of the other combinations of campuses are over 100 kilometres away from each other.
STUDIES AT THE UNIVERSITY OF VALLADOLID I AM A MASTER’S DEGREE STUDENT. CAN I TAKE BACHELOR’S DEGREE COURSES? Yes, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement.
STUDIES AT THE UNIVERSITY OF VALLADOLID WHERE CAN I SEE THE UVA CURRICULA? "You can see the various bachelor's degree curricula here (http://www.uva.es/export/sites/uva/2.docencia/2.01.grados/2.01.02.ofertaformativagrados/2.01.02.01.alfabetica/index.html) , and the master's degree curricula here (http://www.uva.es/export/sites/uva/2.docencia/2.02.mastersoficiales/2.02.01.ofertaeducativa/2.02.01.01.alfabetica/index.html) . Choose the curriculum you are interested in, and then click on ""Asignaturas"" (courses) to see the courses. "
STUDIES AT THE UNIVERSITY OF VALLADOLID WHERE CAN I FIND THE TIMETABLE AND CLASSROOMS FOR MY COURSES? "Each University of Valladolid faculty has its own webpage where the calendars, timetables and classrooms for the courses are published. You can find the link to your centre’s web here (http://www.uva.es/export/sites/uva/2.docencia/2.01.grados/2.01.02.ofertaformativagrados/2.01.02.01.alfabetica/index.html) .Choose the curriculum you are interested in, and then click on ""Horarios"" (timetables) to see the times and rooms for your courses."
STUDIES AT THE UNIVERSITY OF VALLADOLID IN SOME COURSES IT MENTIONS GROUPS SUCH AS 1 T, 2 A, 1 S. WHAT DOES THIS MEAN? CAN I CHOOSE THE GROUP I WANT? Some courses are divided into groups because not all of the students can fit into the classroom at the same time. Some courses may have more than one group for the lectures, some for practical lessons, and others for both lectures and practical lessons.Exchange students can choose whichever groups suit them best. In other words, they can choose group 1 for the lectures in one course, and group 2 for another, etc. However, once a student has chosen a particular group for a course, they should always go to the same group for that course.
STUDIES AT THE UNIVERSITY OF VALLADOLID WHAT IS THE MINIMUM NUMBER AND THE MAXIMUM NUMBER OF CREDITS I CAN TAKE? You can take a maximum of 30 ECTS (European Credit Transfer and Accumulation System).We do not set a minimum number of credits. If you need to choose a minimum number of credits you must notify your university.
STUDIES AT THE UNIVERSITY OF VALLADOLID WHEN SHOULD I SEND MY LEARNING AGREEMENT OR STUDIES PROGRAMME? You only need to send it to us if we ask you for it. If we don’t ask you for it, it is because we don’t need it yet. Generally speaking, Erasmus+ students can fill in their Learning Agreement and obtain their coordinating teacher’s signature after they get to the University of Valladolid.
STUDIES AT THE UNIVERSITY OF VALLADOLID I NEED TO SIGN MY LEARNING AGREEMENT. WHO DO I SEND IT TO? You should send it directly to your coordinating teacher at the University of Valladolid.
STUDIES AT THE UNIVERSITY OF VALLADOLID MY COORDINATING TEACHER ISN’T ANSWERING MY EMAILS. WHO CAN HELP ME? If you have any questions related to academic matters or if you need your Learning Agreement signed, you can contact your faculty’s International Relations Coordinator at the University of Valladolid.For any other kinds of question, contact incoming@uva.es (mailto:incoming@uva.es)
STUDIES AT THE UNIVERSITY OF VALLADOLID I WANT TO DO A FULL BACHELOR’S/MASTER’S/DOCTORAL DEGREE AT THE UNIVERSITY OF VALLADOLID. WHERE CAN I GET INFORMATION? You can find information on the general website http://www.uva.es/ (http://www.uva.es/) . The enrolment procedure is the same for Spanish students as for students of other nationalities. If you have any doubts, you should contact the Seccion de Alumnos (http://directorio.uva.es/detalle.html?id=4001004) .
THE LANGUAGE OF INSTRUCTION WHAT LANGUAGE OF INSTRUCTION IS USED AT THE UNIVERSITY OF VALLADOLID? Approximately 90% of the lessons are in Spanish. A few courses are also in English, and there are courses in other languages as foreign languages.
THE LANGUAGE OF INSTRUCTION CAN I STUDY IN ENGLISH AT THE UNIVERSITY OF VALLADOLID? Some degrees have a lot of courses in English, such as the Bachelor's Degree in English Studies. There are also courses taught in English. You can check which ones here (http://relint.uva.es/wp-content/uploads/2019/03/English18-19.pdf) .You can also take the International Semesters:https://campusvirtual.uva.es/course/index.php?categoryid=309http://www2.emp.uva.es/index.php/relaciones-internacionales-facultad-de-comercio-de-valladolid/https://campusvirtual.uva.es/course/index.php?categoryid=277http://www.feyts.uva.es/?q=node/2424
THE LANGUAGE OF INSTRUCTION WHAT LEVEL OF SPANISH DO I NEED TO STUDY AT THE UVA? You need a B1 level of Spanish (Common European Framework of Reference for Languages - CEFR) when you get to the University of Valladolid.
THE LANGUAGE OF INSTRUCTION I HAVE A GOOD COMMAND OF SPANISH BUT DO NOT HAVE AN OFFICIAL B1 CERTIFICATE. CAN I PRESENT OTHER CERTIFICATES OF SPANISH? Yes. We only need to be sure that you won’t have any difficulty understanding your teachers, such that we accept non-official certificates.
THE LANGUAGE OF INSTRUCTION I SPEAK SPANISH BUT DO NOT HAVE CERTIFICATES. WHAT CAN I DO? You can send us a report from a Spanish language teacher at your university, or from your International Relations Office, stating that you have sufficient command of Spanish to be able to satisfactorily undertake your stay at our university.Another way to acquire a sufficient level of Spanish is to take an intensive course at a language centre or language school in Spain before you start your academic year.
WHEN YOU GET TO THE UNIVERSITY OF VALLADOLID WHAT DO I HAVE TO DO THE FIRST DAY I GET TO THE UVA? If you are going to study in the city of Valladolid, you should go to the International Relations Office to register that you have arrived and we will give you information. You can find our address and the office opening hours through this link.If you are going to study in Palencia, Segovia, or Soria you should visit your coordinating teacher, who will register your arrival and will give you academic information. You should let your coordinating teacher know in advance by email the date on which you will be arriving. You can find their contact details in your Personal Area.If your coordinating teacher is late in answering you, you can also contact the assistant at the International Relations Office on your campus through the following email addresses:Palencia Campus: palencia@uva.es (mailto:internacional.palencia@uva.es) Segovia Campus: segovia@uva.es (mailto:internacional.segovia@uva.es) Soria Campus: soria@uva.es (mailto:internacional.soria@uva.es)
WHEN YOU GET TO THE UNIVERSITY OF VALLADOLID I STILL DO NOT HAVE MY STUDENT CARD AND I NEED IT. WHAT SHOULD I DO? You can still have access to all university services and facilities even if you are still waiting for your student card.There are two ways to access: with your enrolment sheet or downloading the UVa app for smartphones, available for Android (https://play.google.com/store/apps/details?id=com.pocketuniversity.uva) and iOS (https://itunes.apple.com/app/id1031505989) .
EXAMINATIONS AND MARKS/GRADES WHAT MARK/GRADE WILL I GET IN MY COUNTRY WITH THE EXAMINATIONS I TAKE AT THE UNIVERSITY OF VALLADOLID? Each country has a different grading system. European countries share a transfer system which you can check out in Wikipedia: ECTS (https://es.wikipedia.org/wiki/European_Credit_Transfer_and_Accumulation_System) , Grading scale (only in English) (https://en.wikipedia.org/wiki/ECTS_grading_scale) .
EXAMINATIONS AND MARKS/GRADES WHEN ARE EXAMINATIONS HELD AT THE UNIVERSITY OF VALLADOLID? First term examinations are held in January, although some teachers may bring theirs forward to late December.Second term examinations are held in June.
EXAMINATIONS AND MARKS/GRADES I AM NOT IN SPAIN ON THE DAY OF THE EXAM. CAN I TAKE THE EXAM IN MY HOME COUNTRY? You should ask your course teacher. They will tell you if there is another way for you to take the exam.
EXAMINATIONS AND MARKS/GRADES I DID NOT PASS AN EXAM. WHAT CAN I DO? In Valladolid, you have the chance to take an exam again if you do not pass. These exams are known as “extraordinarios”.
EXAMINATIONS AND MARKS/GRADES WHEN ARE THE EXTRAORDINARIO EXAMS? Extraordinario exams for the first term are held in late January or early February. The extraordinario exams for the second term are held in late June.
EXAMINATIONS AND MARKS/GRADES I PASSED AN EXAM BUT WITH A LOW MARK/GRADE AND I WANT TO IMPROVE IT. CAN I DO SO? You should ask your course teacher; some allow you to do an assignment in order to increase your mark/grade; others allow you to take the exam again, others do not allow you to improve your mark. Your teacher must tell you what will happen if they allow you to take the exam again and you fail the second time.You should never take the extraordinario exam without first speaking to your teacher.
EXAMINATIONS AND MARKS/GRADES I AM GOING TO TAKE AN EXAM AGAIN. WHAT MUST I DO? If they are first term exams and you are leaving in the second term, nothing.If they are first term exams and you are leaving in February or if they are second term exams, you should do the following:As soon as you know that you need to take at least one extraordinario exam, send an email to incoming@uva.es (mailto:incoming@uva.es) or chico@uva.es (mailto:raquel.chico@uva.es) to let us know that you will be doing extraordinario exams.During your final extraordinario exam, you should ask the teacher invigilating for a proof of attendance note (justificante de asistencia).After your final exam, you should take the proof of attendance note to the International Relations Office, or to your coordinating teacher if you are studying in Palencia, Segovia or Soria.
EXAMINATIONS AND MARKS/GRADES HOW WILL I RECEIVE MY MARKS/GRADES CERTIFICATE, TRANSCRIPT OF RECORDS, DOCUMENT AFTER THE MOBILITY? The International Relations Office will send it to you by email.
EXAMINATIONS AND MARKS/GRADES MY UNIVERSITY HAS A DOCUMENT FOR THIS MARKS/GRADES CERTIFICATE. SHOULD I TAKE IT TO MY COORDINATING TEACHER TO HAVE IT SIGNED? No. The rules in our university require us to use our own certificate. This is created following a strict and safe protocol. It also has to be signed by the university authorities, the Vice-rector for International Relations, and the General Secretary. A transcript signed by your coordinating teacher at the University of Valladolid will be not be valid.If this is a problem for your university, you should contact us directly.
BEFORE LEAVING THE UNIVERSITY OF VALLADOLID WHAT MUST I DO WHEN I FINISH MY STUDIES AT THE UNIVERSITY OF VALLADOLID? You should pick up the certificate accrediting your stay (certificado de estancia) or Letter 2 at the same place where you received your certificate of arrival or Letter 1:If you have studied in the city of Valladolid, you should go to the International Relations Office. If you have studied in Palencia, Segovia, or Soria, you should see your coordinating teacher.The International Relations Office will send you your marks/grades certificate or transcript of records directly.
EXTENDING AN EXCHANGE STUDY STAY HOW CAN I EXTEND MY STAY AT THE UVA? You should fill in the following document ( download here) (http://relint.uva.es/wp-content/uploads/2019/02/DOCUMENTO_AMPLIACION_MATRICULA.pdf) and send it by email to incoming@uva.es (mailto:incoming@uva.es) or hand it in personally at the International Relations Office.
EXTENDING AN EXCHANGE STUDY STAY MY UNIVERSITY WILL NOT GIVE ME AN EXTENSION. IS THERE ANOTHER WAY I CAN STAY AT THE UVA? Yes. Through the Visiting Students Programme, any university student may stay at the University of Valladolid for one or two terms.
[
{
"answer": "You should find out whether there is an exchange agreement between our universities. To do this, you should contact incoming@uva.es (mailto:incoming@uva.es) If there is no agreement between our universities, you can always come as a Visiting student (http://relint.uva.es/internacional/english/students/visitors-programme/) .",
"page": "relint",
"question": "CAN I DO A STUDY EXCHANGE AT THE UNIVERSITY OF VALLADOLID?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You can choose the courses you like from any academic course or academic year. You can also even take courses from various curricula and from different faculties at the same time. However, you must make sure that your coordinating teacher accepts your choices when signing your studies contract or Learning Agreement.Whatever you opt to do, you should take at least one course from the University of Valladolid faculty you have chosen.",
"page": "relint",
"question": "WHICH COURSES CAN I TAKE AT THE UNIVERSITY OF VALLADOLID?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "No, you can only choose courses taught during the time you are at our university.If you are here between September and February, you can choose courses taught in the first term or semester.If you are here between February and June, you can choose courses taught in the second term or semester.If you are here from September to June, you can choose any course, including full-year courses.",
"page": "relint",
"question": "CAN I CHOOSE COURSES FROM ANY TERM OR SEMESTER?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "No. Full-year courses are taught continuously from September until June. You are not allowed to take them if you are only going to be here during the first or second semester.",
"page": "relint",
"question": "CAN I CHOOSE FULL-YEAR COURSES IF I STUDY AT THE UVA FOR A TERM OR A SEMESTER?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Yes, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement. However, you must always take at least one course from the University of Valladolid faculty you have chosen.",
"page": "relint",
"question": "CAN I CHOOSE COURSES FROM VARIOUS FACULTIES AT THE SAME TIME?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You may only choose courses from the Valladolid and Palencia campuses at the same time, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement. All of the other combinations of campuses are over 100 kilometres away from each other.",
"page": "relint",
"question": "CAN I TAKE COURSES AT VARIOUS CAMPUSES AT THE SAME TIME?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Yes, provided that your coordinating teacher agrees to this when signing your studies contract or Learning Agreement.",
"page": "relint",
"question": "I AM A MASTER’S DEGREE STUDENT. CAN I TAKE BACHELOR’S DEGREE COURSES?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You can see the various bachelor's degree curricula here (http://www.uva.es/export/sites/uva/2.docencia/2.01.grados/2.01.02.ofertaformativagrados/2.01.02.01.alfabetica/index.html) , and the master's degree curricula here (http://www.uva.es/export/sites/uva/2.docencia/2.02.mastersoficiales/2.02.01.ofertaeducativa/2.02.01.01.alfabetica/index.html) . Choose the curriculum you are interested in, and then click on \"Asignaturas\" (courses) to see the courses. ",
"page": "relint",
"question": "WHERE CAN I SEE THE UVA CURRICULA?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Each University of Valladolid faculty has its own webpage where the calendars, timetables and classrooms for the courses are published. You can find the link to your centre’s web here (http://www.uva.es/export/sites/uva/2.docencia/2.01.grados/2.01.02.ofertaformativagrados/2.01.02.01.alfabetica/index.html) .Choose the curriculum you are interested in, and then click on \"Horarios\" (timetables) to see the times and rooms for your courses.",
"page": "relint",
"question": "WHERE CAN I FIND THE TIMETABLE AND CLASSROOMS FOR MY COURSES?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Some courses are divided into groups because not all of the students can fit into the classroom at the same time. Some courses may have more than one group for the lectures, some for practical lessons, and others for both lectures and practical lessons.Exchange students can choose whichever groups suit them best. In other words, they can choose group 1 for the lectures in one course, and group 2 for another, etc. However, once a student has chosen a particular group for a course, they should always go to the same group for that course.",
"page": "relint",
"question": "IN SOME COURSES IT MENTIONS GROUPS SUCH AS 1 T, 2 A, 1 S. WHAT DOES THIS MEAN? CAN I CHOOSE THE GROUP I WANT?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You can take a maximum of 30 ECTS (European Credit Transfer and Accumulation System).We do not set a minimum number of credits. If you need to choose a minimum number of credits you must notify your university.",
"page": "relint",
"question": "WHAT IS THE MINIMUM NUMBER AND THE MAXIMUM NUMBER OF CREDITS I CAN TAKE?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You only need to send it to us if we ask you for it. If we don’t ask you for it, it is because we don’t need it yet. Generally speaking, Erasmus+ students can fill in their Learning Agreement and obtain their coordinating teacher’s signature after they get to the University of Valladolid.",
"page": "relint",
"question": "WHEN SHOULD I SEND MY LEARNING AGREEMENT OR STUDIES PROGRAMME?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You should send it directly to your coordinating teacher at the University of Valladolid.",
"page": "relint",
"question": "I NEED TO SIGN MY LEARNING AGREEMENT. WHO DO I SEND IT TO?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "If you have any questions related to academic matters or if you need your Learning Agreement signed, you can contact your faculty’s International Relations Coordinator at the University of Valladolid.For any other kinds of question, contact incoming@uva.es (mailto:incoming@uva.es) ",
"page": "relint",
"question": "MY COORDINATING TEACHER ISN’T ANSWERING MY EMAILS. WHO CAN HELP ME?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You can find information on the general website http://www.uva.es/ (http://www.uva.es/) . The enrolment procedure is the same for Spanish students as for students of other nationalities. If you have any doubts, you should contact the Seccion de Alumnos (http://directorio.uva.es/detalle.html?id=4001004) .",
"page": "relint",
"question": "I WANT TO DO A FULL BACHELOR’S/MASTER’S/DOCTORAL DEGREE AT THE UNIVERSITY OF VALLADOLID. WHERE CAN I GET INFORMATION?",
"section": "STUDIES AT THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Approximately 90% of the lessons are in Spanish. A few courses are also in English, and there are courses in other languages as foreign languages.",
"page": "relint",
"question": "WHAT LANGUAGE OF INSTRUCTION IS USED AT THE UNIVERSITY OF VALLADOLID?",
"section": "THE LANGUAGE OF INSTRUCTION"
},
{
"answer": "Some degrees have a lot of courses in English, such as the Bachelor's Degree in English Studies. There are also courses taught in English. You can check which ones here (http://relint.uva.es/wp-content/uploads/2019/03/English18-19.pdf) .You can also take the International Semesters:https://campusvirtual.uva.es/course/index.php?categoryid=309http://www2.emp.uva.es/index.php/relaciones-internacionales-facultad-de-comercio-de-valladolid/https://campusvirtual.uva.es/course/index.php?categoryid=277http://www.feyts.uva.es/?q=node/2424",
"page": "relint",
"question": "CAN I STUDY IN ENGLISH AT THE UNIVERSITY OF VALLADOLID?",
"section": "THE LANGUAGE OF INSTRUCTION"
},
{
"answer": "You need a B1 level of Spanish (Common European Framework of Reference for Languages - CEFR) when you get to the University of Valladolid.",
"page": "relint",
"question": "WHAT LEVEL OF SPANISH DO I NEED TO STUDY AT THE UVA?",
"section": "THE LANGUAGE OF INSTRUCTION"
},
{
"answer": "Yes. We only need to be sure that you won’t have any difficulty understanding your teachers, such that we accept non-official certificates.",
"page": "relint",
"question": "I HAVE A GOOD COMMAND OF SPANISH BUT DO NOT HAVE AN OFFICIAL B1 CERTIFICATE. CAN I PRESENT OTHER CERTIFICATES OF SPANISH?",
"section": "THE LANGUAGE OF INSTRUCTION"
},
{
"answer": "You can send us a report from a Spanish language teacher at your university, or from your International Relations Office, stating that you have sufficient command of Spanish to be able to satisfactorily undertake your stay at our university.Another way to acquire a sufficient level of Spanish is to take an intensive course at a language centre or language school in Spain before you start your academic year.",
"page": "relint",
"question": "I SPEAK SPANISH BUT DO NOT HAVE CERTIFICATES. WHAT CAN I DO?",
"section": "THE LANGUAGE OF INSTRUCTION"
},
{
"answer": "If you are going to study in the city of Valladolid, you should go to the International Relations Office to register that you have arrived and we will give you information. You can find our address and the office opening hours through this link.If you are going to study in Palencia, Segovia, or Soria you should visit your coordinating teacher, who will register your arrival and will give you academic information. You should let your coordinating teacher know in advance by email the date on which you will be arriving. You can find their contact details in your Personal Area.If your coordinating teacher is late in answering you, you can also contact the assistant at the International Relations Office on your campus through the following email addresses:Palencia Campus: palencia@uva.es (mailto:internacional.palencia@uva.es) Segovia Campus: segovia@uva.es (mailto:internacional.segovia@uva.es) Soria Campus: soria@uva.es (mailto:internacional.soria@uva.es) ",
"page": "relint",
"question": "WHAT DO I HAVE TO DO THE FIRST DAY I GET TO THE UVA?",
"section": "WHEN YOU GET TO THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You can still have access to all university services and facilities even if you are still waiting for your student card.There are two ways to access: with your enrolment sheet or downloading the UVa app for smartphones, available for Android (https://play.google.com/store/apps/details?id=com.pocketuniversity.uva) and iOS (https://itunes.apple.com/app/id1031505989) .",
"page": "relint",
"question": "I STILL DO NOT HAVE MY STUDENT CARD AND I NEED IT. WHAT SHOULD I DO?",
"section": "WHEN YOU GET TO THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "Each country has a different grading system. European countries share a transfer system which you can check out in Wikipedia: ECTS (https://es.wikipedia.org/wiki/European_Credit_Transfer_and_Accumulation_System) , Grading scale (only in English) (https://en.wikipedia.org/wiki/ECTS_grading_scale) .",
"page": "relint",
"question": "WHAT MARK/GRADE WILL I GET IN MY COUNTRY WITH THE EXAMINATIONS I TAKE AT THE UNIVERSITY OF VALLADOLID?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "First term examinations are held in January, although some teachers may bring theirs forward to late December.Second term examinations are held in June.",
"page": "relint",
"question": "WHEN ARE EXAMINATIONS HELD AT THE UNIVERSITY OF VALLADOLID?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "You should ask your course teacher. They will tell you if there is another way for you to take the exam.",
"page": "relint",
"question": "I AM NOT IN SPAIN ON THE DAY OF THE EXAM. CAN I TAKE THE EXAM IN MY HOME COUNTRY?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "In Valladolid, you have the chance to take an exam again if you do not pass. These exams are known as “extraordinarios”.",
"page": "relint",
"question": "I DID NOT PASS AN EXAM. WHAT CAN I DO?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "Extraordinario exams for the first term are held in late January or early February. The extraordinario exams for the second term are held in late June.",
"page": "relint",
"question": "WHEN ARE THE EXTRAORDINARIO EXAMS?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "You should ask your course teacher; some allow you to do an assignment in order to increase your mark/grade; others allow you to take the exam again, others do not allow you to improve your mark. Your teacher must tell you what will happen if they allow you to take the exam again and you fail the second time.You should never take the extraordinario exam without first speaking to your teacher.",
"page": "relint",
"question": "I PASSED AN EXAM BUT WITH A LOW MARK/GRADE AND I WANT TO IMPROVE IT. CAN I DO SO?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "If they are first term exams and you are leaving in the second term, nothing.If they are first term exams and you are leaving in February or if they are second term exams, you should do the following:As soon as you know that you need to take at least one extraordinario exam, send an email to incoming@uva.es (mailto:incoming@uva.es) or chico@uva.es (mailto:raquel.chico@uva.es) to let us know that you will be doing extraordinario exams.During your final extraordinario exam, you should ask the teacher invigilating for a proof of attendance note (justificante de asistencia).After your final exam, you should take the proof of attendance note to the International Relations Office, or to your coordinating teacher if you are studying in Palencia, Segovia or Soria.",
"page": "relint",
"question": "I AM GOING TO TAKE AN EXAM AGAIN. WHAT MUST I DO?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "The International Relations Office will send it to you by email.",
"page": "relint",
"question": "HOW WILL I RECEIVE MY MARKS/GRADES CERTIFICATE, TRANSCRIPT OF RECORDS, DOCUMENT AFTER THE MOBILITY?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "No. The rules in our university require us to use our own certificate. This is created following a strict and safe protocol. It also has to be signed by the university authorities, the Vice-rector for International Relations, and the General Secretary. A transcript signed by your coordinating teacher at the University of Valladolid will be not be valid.If this is a problem for your university, you should contact us directly.",
"page": "relint",
"question": "MY UNIVERSITY HAS A DOCUMENT FOR THIS MARKS/GRADES CERTIFICATE. SHOULD I TAKE IT TO MY COORDINATING TEACHER TO HAVE IT SIGNED?",
"section": "EXAMINATIONS AND MARKS/GRADES"
},
{
"answer": "You should pick up the certificate accrediting your stay (certificado de estancia) or Letter 2 at the same place where you received your certificate of arrival or Letter 1:If you have studied in the city of Valladolid, you should go to the International Relations Office. If you have studied in Palencia, Segovia, or Soria, you should see your coordinating teacher.The International Relations Office will send you your marks/grades certificate or transcript of records directly. ",
"page": "relint",
"question": "WHAT MUST I DO WHEN I FINISH MY STUDIES AT THE UNIVERSITY OF VALLADOLID?",
"section": "BEFORE LEAVING THE UNIVERSITY OF VALLADOLID"
},
{
"answer": "You should fill in the following document ( download here) (http://relint.uva.es/wp-content/uploads/2019/02/DOCUMENTO_AMPLIACION_MATRICULA.pdf) and send it by email to incoming@uva.es (mailto:incoming@uva.es) or hand it in personally at the International Relations Office.",
"page": "relint",
"question": "HOW CAN I EXTEND MY STAY AT THE UVA?",
"section": "EXTENDING AN EXCHANGE STUDY STAY"
},
{
"answer": "Yes. Through the Visiting Students Programme, any university student may stay at the University of Valladolid for one or two terms. ",
"page": "relint",
"question": "MY UNIVERSITY WILL NOT GIVE ME AN EXTENSION. IS THERE ANOTHER WAY I CAN STAY AT THE UVA?",
"section": "EXTENDING AN EXCHANGE STUDY STAY"
}
]
\ No newline at end of file
%% Cell type:code id: tags:
```
import en_core_web_lg
import numpy as np
import json
from sklearn.metrics.pairwise import cosine_similarity
nlp = en_core_web_lg.load()
```
%% Cell type:code id: tags:
```
def get_response(msg):
""" Processes a message and generates a respone """
return "You said '{}'".format(msg)
def answer_question(question):
""" Determines the most similar question and provides its answer """
def most_similar(question, n=1):
""" Obtains the n most similar questins and its similarity to a given
question """
with open('./qa_pairs_em.json', 'r', encoding='utf8') as file:
qa_pairs = json.load(file)
request_embedding = sentence_embedding(question)
for pair in qa_pairs:
pair['sim'] = cosine_similarity(np.array(pair['embedding']).reshape(1, -1), request_embedding.reshape(1, -1))
sorted_qa_pairs = sorted(qa_pairs, key=lambda p: p['sim'], reverse=True)
return sorted_qa_pairs[0:n]
def sentence_embedding(question):
""" Computes the embedding os a sentence, removing the punctuation
symbols and stop words """
doc = nlp(question)
tokens = list(filter(lambda t: t.has_vector and (not t.is_punct) and (not t.is_stop), doc.doc))
vectors = list(map(lambda t: t.vector, tokens))
embedding = np.average(vectors, axis=0)
return embedding
```
%% Cell type:code id: tags:
```
most_similar('What is the minimum credists I have to course ?')
```
%% Output
[{'answer': 'You can take a maximum of 30 ECTS (European Credit Transfer and Accumulation System).We do not set a minimum number of credits. If you need to choose a minimum number of credits you must notify your university.',
'embedding': [-0.17360201478004456,
0.2857059836387634,
-0.09179359674453735,
-0.03986828029155731,
0.09077881276607513,
-0.09095919877290726,
-0.056734006851911545,
-0.08263679593801498,
0.14751499891281128,
1.6455860137939453,
-0.09618699550628662,
0.37244200706481934,
-0.26668840646743774,
-0.01920079067349434,
0.3285300135612488,
0.1448580026626587,
-0.016309011727571487,
1.9263579845428467,
-0.1175381988286972,
-0.14208020269870758,
-0.47690001130104065,
0.11448699235916138,
-0.019088000059127808,
-0.07032860070466995,
0.020871996879577637,
-0.3075757622718811,
-0.0240160021930933,
-0.19370579719543457,
0.09471800178289413,
0.19954800605773926,
0.24274274706840515,
-0.1653279960155487,
0.06869599968194962,
-0.05831500142812729,
-0.047429002821445465,
0.21814760565757751,
-0.27856120467185974,
0.1793222427368164,
0.16480259597301483,
-0.10944481194019318,
0.03280999884009361,
0.11687976121902466,
0.07233400642871857,
-0.2473059892654419,
-0.08093379437923431,
-0.012797999195754528,
0.09415080398321152,
0.3226119875907898,
0.13129059970378876,
0.33777180314064026,
-0.09521840512752533,
-0.0972302109003067,
0.42097002267837524,
-0.2178020477294922,
-0.35405200719833374,
0.2625020146369934,
0.18072399497032166,
-0.1045634001493454,
-0.022241998463869095,
0.05760600045323372,
0.11243180930614471,
-0.018262341618537903,
0.041218001395463943,
0.28095778822898865,
0.18359999358654022,
0.1079895943403244,
-0.07681719958782196,
0.44262999296188354,
0.021503198891878128,
-0.16929659247398376,
0.21874800324440002,
-0.25487199425697327,
0.24597401916980743,
-0.1666940152645111,
-0.10225560516119003,
0.08862639963626862,
0.3300279974937439,
0.27038803696632385,
0.26868799328804016,
0.3069559931755066,
0.1084074005484581,
0.0025721967685967684,
-0.12366900593042374,
-0.01648399792611599,
0.22017399966716766,
0.3083154261112213,
-0.12271080166101456,
0.0014439880615100265,
0.4134979844093323,
-0.2176080048084259,
-0.1547360122203827,
-0.031072799116373062,
0.10116299241781235,
-0.3913640081882477,
-0.2730939984321594,
-0.40087199211120605,
-0.11903717368841171,
0.30919259786605835,
-0.08509880304336548,
0.2170100212097168,
-0.3247320055961609,
0.058950792998075485,
-0.12724998593330383,
0.29962602257728577,
0.11356399208307266,
-1.3211040496826172,
0.11673639714717865,
-0.12790599465370178,
-0.276995986700058,
-0.1455100029706955,
0.18558959662914276,
-0.031009402126073837,
0.21197399497032166,
0.29686781764030457,
0.2465953826904297,
-0.22457000613212585,
0.013078195974230766,
0.21981699764728546,
0.09826799482107162,
0.02775081992149353,
0.14509379863739014,
0.1350167989730835,
-0.07278880476951599,
-0.18373680114746094,
-0.06714359670877457,
-0.03427640348672867,
-0.0044256048277020454,
-0.0026993989013135433,
-0.23584198951721191,
-0.03793000057339668,
0.28535598516464233,
0.5475040078163147,
0.3007040023803711,
0.09356200695037842,
0.3532800078392029,
0.001216998673044145,
0.177620992064476,
0.17242200672626495,
-0.1471319943666458,
0.09812700748443604,
-0.29696398973464966,
0.23708602786064148,
0.12076999992132187,
0.08454179763793945,
0.11396720260381699,
0.011809198185801506,
0.12508000433444977,
0.09127520024776459,
-0.23609140515327454,
0.11979091167449951,
0.1290608048439026,
0.10515180975198746,
-0.1819620132446289,
-0.029345199465751648,
-0.0949850082397461,
-0.13489320874214172,
0.10540719330310822,
0.3035481572151184,
-0.08335208892822266,
-0.08129139244556427,
0.27863600850105286,
-0.10348440706729889,
0.004668998531997204,
-0.1886695921421051,
-0.27368199825286865,
-0.1477540135383606,
0.19394339621067047,
-0.20967161655426025,
0.05106360465288162,
0.03730279952287674,
0.13471360504627228,
-0.09926401078701019,
0.18258564174175262,
-0.3133159875869751,
-0.24087198078632355,
0.0999160036444664,
0.04247479885816574,
-0.07674960047006607,
0.0871339961886406,
-0.17373399436473846,
0.24380400776863098,
0.2539118230342865,
0.06291340291500092,
0.11732339859008789,
-0.19952599704265594,
0.07520799338817596,
-0.2304907739162445,
-0.004106199834495783,
-0.10559400171041489,
0.27571845054626465,
0.27647361159324646,
0.239777609705925,
-0.006896001286804676,
0.1134980097413063,
0.1992587149143219,
-0.08205579966306686,
0.012253999710083008,
0.06127599626779556,
-0.13951480388641357,
0.14521659910678864,
0.25714385509490967,
-0.5186220407485962,
-0.3629215955734253,
0.047586195170879364,
-0.022932002320885658,
0.05594300106167793,
0.03171540051698685,
0.21590439975261688,
-0.06544600427150726,
0.13766399025917053,
0.2444848120212555,
0.34897738695144653,
-0.158473402261734,
-0.3224756121635437,
-0.01880520209670067,
0.37882399559020996,
-0.22200199961662292,
0.03375949710607529,
-0.11233800649642944,
0.44629397988319397,
0.0842847228050232,
0.038134194910526276,
0.10011999309062958,
-0.09800399839878082,
0.06253720074892044,
-0.03526441007852554,
0.09005999565124512,
-0.20750999450683594,
0.16696040332317352,
0.18080200254917145,
0.31518638134002686,
-0.035266004502773285,
-0.0067013963125646114,
0.20010599493980408,
-0.2820040285587311,
0.08720959722995758,
-0.027991998940706253,
-0.10632185637950897,
-0.24111399054527283,
0.3901039958000183,
-0.09296020120382309,
0.07975540310144424,
-0.08928759396076202,
0.38221877813339233,
0.1776427924633026,
-0.27977117896080017,
0.1826941967010498,
0.09810199588537216,
-0.08979939669370651,
-0.016914403066039085,
-0.12272019684314728,
0.0751442089676857,
-0.04050440713763237,
-0.12238439172506332,
-0.02614399418234825,
0.9553019404411316,
-0.17295241355895996,
0.01173519529402256,
0.2185879945755005,
0.09779399633407593,
0.18251679837703705,
0.35700997710227966,
-0.23781640827655792,
0.22407200932502747,
-0.08763179928064346,
-0.3127191960811615,
0.3250959813594818,
0.1636119931936264,
0.7351981997489929,
-0.3778315782546997,
0.1507820188999176,
0.0781099945306778,
0.21310201287269592,
-0.32892221212387085,
-0.019435999915003777,
0.03358200192451477,
-0.19427600502967834,
0.1710543930530548,
0.011434400454163551,
0.05372900515794754,
-0.005374002270400524,
0.4516007900238037,
-0.020184801891446114,
-0.07182079553604126,
0.0071439980529248714,
-0.04806799441576004,
-0.20998802781105042,
-0.04649186134338379,
0.1629486083984375,
0.42056798934936523,
-0.15683820843696594,
-0.0014477968215942383,
0.4137340188026428,
0.2308119833469391,
0.022228797897696495,
0.019019605591893196,
-0.15768960118293762,
-0.1490384042263031,
0.06764759868383408,
-0.12349740415811539],
'page': 'relint',
'question': 'WHAT IS THE MINIMUM NUMBER AND THE MAXIMUM NUMBER OF CREDITS I CAN TAKE?',
'section': 'STUDIES AT THE UNIVERSITY OF VALLADOLID',
'sim': array([[0.77149119]])}]
%% Cell type:code id: tags:
```
```
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment