in webhook/utils.py [0:0]
def truncate_complete_text(complete_text: str, logger_name: str) -> str:
"""Extracts the abstract and conclusion from an academic paper.
Uses a heuristics to approximate the extent of the abstract and conclusion.
For abstract: assumes beginning after the string `abstract` and extends for 6-7 sentences
For conclusion: assumes beginning after the string `conclusion` and extends for 7-9 sentences
#56 : Improve this function
Args:
complete_text (str): the complete text of the academic paper
Returns
str: the truncated paper
"""
complete_text = complete_text.lower()
abstract_start = complete_text.find(ABSTRACT_H1)
# If no "Abstract" heading found, produce the entire text
if abstract_start == -1:
abstract_start = 0
log_content_error(logger_name=logger_name)
conclusion_start = complete_text.find(CONCLUSION_H1)
# If no "Conclusion" heading found, produce the last little bit
# of the text
if conclusion_start == -1:
conclusion_start = len(complete_text) - (CONCLUSION_LENGTH)
log_content_error(logger_name=logger_name)
abstract = complete_text[abstract_start:ABSTRACT_LENGTH]
conclusion = complete_text[conclusion_start:]
if len(conclusion) > CONCLUSION_LENGTH:
conclusion = conclusion[:CONCLUSION_LENGTH]
return f"""