MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / clean_abstract

Function clean_abstract

skills/paper-processor/scripts/embed.py:65–96  ·  view source on GitHub ↗

Clean abstract text Args: abstract_text: Raw abstract Returns: Cleaned abstract

(abstract_text: str)

Source from the content-addressed store, hash-verified

63
64
65def clean_abstract(abstract_text: str) -> str:
66 """
67 Clean abstract text
68
69 Args:
70 abstract_text: Raw abstract
71
72 Returns:
73 Cleaned abstract
74 """
75 text = abstract_text
76
77 # Remove LaTeX formulas
78 text = re.sub(r'\$[^$]+\$', '[FORMULA]', text)
79 text = re.sub(r'\\\[.*?\\\]', '[FORMULA]', text, flags=re.DOTALL)
80 text = re.sub(r'\\begin\{.*?\}.*?\\end\{.*?\}', '[FORMULA]', text, flags=re.DOTALL)
81
82 # Remove citation markers
83 text = re.sub(r'\[\d+\]', '', text)
84 text = re.sub(r'\(\d+\)', '', text)
85
86 # Compress whitespace
87 text = re.sub(r'\s+', ' ', text)
88
89 # Remove special characters
90 text = re.sub(r'[^\w\s.,;:!?()\-\']', '', text)
91
92 # Truncate if too long
93 if len(text) > 5000:
94 text = text[:4997] + "..."
95
96 return text.strip()
97
98
99def extract_keywords(text: str, top_k: int = 5) -> List[str]:

Callers 2

process_paperFunction · 0.85
embed.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected