Skip to content

[Back-end - API] comprehensive_results tries to access key 'results' when is not there #46

@NathanGavenski

Description

@NathanGavenski

When requesting https://kclwqt.sites.er.kcl.ac.uk/api/items/getCompResult? the api breaks. The reason for it is that the function comprehensive_results tries to access the key results that is not there.

The reason for this is because the query

entailment_results = list(mongo_handler.entailment_collection.find({
    'task_id': task_id,
    'reference_id': temp_ref_id
}))

returns an empty list, which the implementation never expected. However, the result is correct since there are no entries for the task ID in the entailment_results collection. I assume it is due to some issues with DOI URLs.

Examples:

  1. Q192309
  2. Q1756133
  3. Q29642076
  4. Q3136081

For the following URLs:

  1. https://doi.org/10.1016/S0168-5597(98)00033-1
  2. https://doi.org/10.1016/j.tins.2019.03.006
  3. https://doi.org/10.1016/j.bjorl.2015.12.006
  4. https://doi.org/10.1016/j.mcna.2021.05.003

We should change the following code:

if entailment_results:
    # Group by result type and get highest score
    supports = [r for r in entailment_results if r['result'] == 'SUPPORTS']
    nei = [r for r in entailment_results if r['result'] == 'NOT ENOUGH INFO']
    refutes = [r for r in entailment_results if r['result'] == 'REFUTES']
    
    selected_result = None
    if supports:
        selected_result = max(supports, key=lambda x: x['text_entailment_score'])
    elif nei:
        selected_result = max(nei, key=lambda x: x['text_entailment_score'])
    elif refutes:
        selected_result = max(refutes, key=lambda x: x['text_entailment_score'])
    
    if selected_result:
        item['result'] = selected_result['result']
        item['result_sentence'] = f"Source language: ({temp_lang}) / {selected_result['result_sentence']}"

result_items.append(item)

To consider that an empty list is an unknown issue with ProVe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions