MCPcopy Create free account
hub / github.com/InternScience/SciReason / code_extract

Function code_extract

opencompass/datasets/bigcodebench/extractor.py:31–46  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

29
30
31def code_extract(text: str) -> str:
32 lines = text.split('\n')
33 longest_line_pair = (0, 0)
34 longest_so_far = 0
35
36 for i in range(len(lines)):
37 for j in range(i + 1, len(lines)):
38 current_lines = '\n'.join(lines[i:j + 1])
39 if syntax_check(current_lines):
40 current_length = sum(1 for line in lines[i:j + 1]
41 if line.strip())
42 if current_length > longest_so_far:
43 longest_so_far = current_length
44 longest_line_pair = (i, j)
45
46 return '\n'.join(lines[longest_line_pair[0]:longest_line_pair[1] + 1])
47
48
49def get_deps(nodes: List[Tuple[str, Node]]) -> Dict[str, Set[str]]:

Callers 2

extract_code_generationFunction · 0.85

Calls 1

syntax_checkFunction · 0.85

Tested by

no test coverage detected