Esempio n. 1
0
def test_request_time_slot():
    """
	
	Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot

	"""
    domain = JSONLookupDomain('ImsCourses')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Request
    act_out.slot = "time_slot"

    usr_utt = nlu.extract_user_acts(nlu, user_utterance='at what time')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 2
0
def test_inform_courses_language():
    """
	
	Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot-value pair

	"""
    domain = JSONLookupDomain('ImsCourses')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Inform
    act_out.slot = "lang"
    act_out.value = "de"

    usr_utt = nlu.extract_user_acts(nlu, user_utterance='german')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 3
0
def test_inform_lecturers_name():
    """
    
    Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot-value pair

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Inform
    act_out.slot = "name"
    act_out.value = "apl. prof. dr. agatha christie"

    usr_utt = nlu.extract_user_acts(nlu, user_utterance='agatha christie')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 4
0
def test_request_lecturers_phone():
    """
    
    Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Request
    act_out.slot = "phone"

    usr_utt = nlu.extract_user_acts(
        nlu, user_utterance='can you tell me the phone number')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 5
0
def test_inform_lecturers_department():
    """

    Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot-value pair

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Inform
    act_out.slot = "department"
    act_out.value = "external"

    usr_utt = nlu.extract_user_acts(nlu, user_utterance='informatics')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 6
0
def test_request_lecturers_office_hours():
    """
    
    Tests exemplary whether a given synonym, i.e. a user utterance, is recognized as belonging to a certain slot

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    act_out = UserAct()
    act_out.type = UserActionType.Request
    act_out.slot = "office_hours"

    usr_utt = nlu.extract_user_acts(
        nlu, user_utterance='when are the consultation hours')
    assert 'user_acts' in usr_utt
    assert usr_utt['user_acts'][0] == act_out
Esempio n. 7
0
def load_lecturers_domain(backchannel: bool = False):
    from utils.domain.jsonlookupdomain import JSONLookupDomain
    from services.nlu.nlu import HandcraftedNLU
    from services.nlg.nlg import HandcraftedNLG
    from services.policy import HandcraftedPolicy
    domain = JSONLookupDomain('ImsLecturers', display_name="Lecturers")
    lect_nlu = HandcraftedNLU(domain=domain)
    lect_bst = HandcraftedBST(domain=domain)
    lect_policy = HandcraftedPolicy(domain=domain)
    lect_nlg = load_nlg(backchannel=backchannel, domain=domain)
    return domain, [lect_nlu, lect_bst, lect_policy, lect_nlg]
Esempio n. 8
0
def test_setup_of_user_informables_lecturers():
    """
    
    Tests if user informable slots are recognized as such

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    for user_informable_slot in ['name', 'department', 'position']:
        assert user_informable_slot in nlu.USER_INFORMABLE
Esempio n. 9
0
def test_multiple_user_acts_courses():
    """
    
    Tests exemplary whether a given sentence with multiple user acts is understood properly
    
    """
    domain = JSONLookupDomain('ImsCourses')
    nlu = HandcraftedNLU(domain)

    usr_utt = nlu.extract_user_acts(
        nlu,
        user_utterance='Hi, I want a course that is related to linguistics')
    assert 'user_acts' in usr_utt

    act_out = UserAct()
    act_out.type = UserActionType.Hello
    assert usr_utt['user_acts'][0] == act_out

    act_out = UserAct()
    act_out.type = UserActionType.Inform
    act_out.slot = "linguistics"
    act_out.value = "true"
    assert usr_utt['user_acts'][1] == act_out
Esempio n. 10
0
def test_setup_of_user_requestables_lecturers():
    """

    Tests if user requestable slots are recognized as such

    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    for user_requestable_slot in [
            'name', 'department', 'office_hours', 'mail', 'phone', 'room',
            'position'
    ]:
        assert user_requestable_slot in nlu.USER_REQUESTABLE
Esempio n. 11
0
def test_multiple_user_acts_lecturers():
    """
    
    Tests exemplary whether a given sentence with multiple user acts is understood properly
    
    """
    domain = JSONLookupDomain('ImsLecturers')
    nlu = HandcraftedNLU(domain)

    usr_utt = nlu.extract_user_acts(
        nlu,
        user_utterance=
        'Hi, I want a lecturer who is responsible for gender issues')
    assert 'user_acts' in usr_utt

    act_out = UserAct()
    act_out.type = UserActionType.Hello
    assert usr_utt['user_acts'][0] == act_out

    act_out = UserAct()
    act_out.type = UserActionType.Inform
    act_out.slot = "position"
    act_out.value = "gender"
    assert usr_utt['user_acts'][1] == act_out
Esempio n. 12
0
def test_setup_of_user_requestables_courses():
    """

    Tests if user requestable slots are recognized as such

    """
    domain = JSONLookupDomain('ImsCourses')
    nlu = HandcraftedNLU(domain)

    for user_requestable_slot in [
            'applied_nlp', 'bachelor', 'cognitive_science', 'course_type',
            'deep_learning', 'ects', 'elective', 'extendable', 'lecturer',
            'lang', 'linguistics', 'machine_learning', 'master', 'module_id',
            'module_name', 'name', 'obligatory_attendance', 'oral_exam',
            'participation_limit', 'presentation', 'programming', 'project',
            'report', 'semantics', 'speech', 'statistics', 'sws', 'syntax',
            'turn', 'written_exam'
    ]:
        assert user_requestable_slot in nlu.USER_REQUESTABLE
Esempio n. 13
0
def nlu(domain):
    nlu = HandcraftedNLU(domain)
    return nlu