Code Summarization Beyond Function Level
Paper • 2502.16704 • Published
class_id stringlengths 15 16 | class_code stringlengths 519 6.03k | skeleton stringlengths 561 4.56k | method_code stringlengths 44 1.82k | method_summary stringlengths 15 540 |
|---|---|---|---|---|
ClassEval_0_sum | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def is_start_with(self, request_uri):
"""
Check if the request UR... | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def is_start_with(self, request_uri):
"""
Check if the reque... | def filter(self, request):
request_uri = request['path']
method = request['method']
if self.is_start_with(request_uri):
return True
try:
token = self.get_jwt_user(request)
user = token['user']
if user['level'] > 2:
self.se... | Filter the incoming request based on certain rules and conditions. |
ClassEval_0_sum | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based ... | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based o... | def is_start_with(self, request_uri):
start_with = ["/api", '/login']
for s in start_with:
if request_uri.startswith(s):
return True
return False | Check if the request URI starts with certain prefixes. |
ClassEval_0_sum | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based ... | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based o... | def get_jwt_user(self, request):
token = request['headers']['Authorization']
user = token['user']
if token['jwt'].startswith(user['name']):
jwt_str_date = token['jwt'].split(user['name'])[1]
jwt_date = datetime.datetime.strptime(jwt_str_date, "%Y-%m-%d")
if da... | Get the user information from the JWT token in the request. |
ClassEval_0_sum | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based ... | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based o... | def set_current_user_info_and_log(self, user):
host = user['address']
logging.log(msg=user['name'] + host + str(datetime.datetime.now()), level=1) | Set the current user information and log the access. |
ClassEval_1_sum | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
self.radius = radius
def calculate_sphere_area(self):
"""
calculate the area of sphe... | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | def calculate_circle_area(self):
return math.pi * self.radius ** 2 | calculate the area of circle based on self.radius |
ClassEval_1_sum | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
"""
calculate the area of circ... | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2 | calculate the area of sphere based on self.radius |
ClassEval_1_sum | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
"""
calculate the area of circ... | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | def calculate_cylinder_area(self, height):
return 2 * math.pi * self.radius * (self.radius + height) | calculate the area of cylinder based on self.radius and height |
ClassEval_1_sum | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
"""
calculate the area of circ... | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | def calculate_sector_area(self, angle):
return self.radius ** 2 * angle / 2 | calculate the area of sector based on self.radius and angle |
ClassEval_1_sum | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
"""
calculate the area of circ... | import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | def calculate_annulus_area(self, inner_radius, outer_radius):
return math.pi * (outer_radius ** 2 - inner_radius ** 2) | calculate the area of annulus based on inner_radius and out_radius |
ClassEval_2_sum | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def get_argument(self, key):
"""
Retrieves the value of the specified argument from... | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
"""
Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requried is a set that stores the required arguments
... | def parse_arguments(self, command_string):
args = command_string.split()[1:]
for i in range(len(args)):
arg = args[i]
if arg.startswith('--'):
key_value = arg[2:].split('=')
if len(key_value) == 2:
self.arguments[key_value[0]] =... | Parses the given command line argument string and invoke _convert_type to stores the parsed result in specific type in the arguments dictionary. Checks for missing required arguments, if any, and returns False with the missing argument names, otherwise returns True. |
ClassEval_2_sum | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
"""
Parses the given command line argume... | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
"""
Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requried is a set that stores the required arguments
... | def get_argument(self, key):
return self.arguments.get(key) | Retrieves the value of the specified argument from the arguments dictionary and returns it. |
ClassEval_2_sum | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
"""
Parses the given command line argume... | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
"""
Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requried is a set that stores the required arguments
... | def add_argument(self, arg, required=False, arg_type=str):
if required:
self.required.add(arg)
self.types[arg] = arg_type | Adds an argument to self.types and self.required. Check if it is a required argument and store the argument type. If the argument is set as required, it wull be added to the required set. The argument type and name are stored in the types dictionary as key-value pairs. |
ClassEval_2_sum | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
"""
Parses the given command line argume... | class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
"""
Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requried is a set that stores the required arguments
... | def _convert_type(self, arg, value):
try:
return self.types[arg](value)
except (ValueError, KeyError):
return value | Try to convert the type of input value by searching in self.types. |
ClassEval_3_sum | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
self.datas = datas
@staticmethod
@staticmethod
def count_all(n):
"""
... | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementCalculator.factorial(n - m) | Counts the number of arrangements by choosing m items from n items (permutations). If m is not provided or n equals m, returns factorial(n). |
ClassEval_3_sum | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
"""
Counts the num... | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | @staticmethod
def count_all(n):
total = 0
for i in range(1, n + 1):
total += ArrangementCalculator.count(n, i)
return total | Counts the total number of all possible arrangements by choosing at least 1 item and at most n items from n items. |
ClassEval_3_sum | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
"""
Counts the num... | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | def select(self, m=None):
if m is None:
m = len(self.datas)
result = []
for permutation in itertools.permutations(self.datas, m):
result.append(list(permutation))
return result | Generates a list of arrangements by selecting m items from the internal datas. If m is not provided, selects all items. |
ClassEval_3_sum | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
"""
Counts the num... | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | def select_all(self):
result = []
for i in range(1, len(self.datas) + 1):
result.extend(self.select(i))
return result | Generates a list of all arrangements by selecting at least 1 item and at most the number of internal datas. |
ClassEval_3_sum | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
"""
Counts the num... | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | @staticmethod
def factorial(n):
result = 1
for i in range(2, n + 1):
result *= i
return result | Calculates the factorial of a given number. |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_course_score(self, name, course, score):
"""
... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}} | Add a new student into self.students dict |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
"""
A... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def add_course_score(self, name, course, score):
if name in self.students:
self.students[name]['courses'][course] = score | Add score of specific course for student in self.students |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
"""
A... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def get_gpa(self, name):
if name in self.students and self.students[name]['courses']:
return sum(self.students[name]['courses'].values()) / len(self.students[name]['courses'])
else:
return None | Get average grade of one student. |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
"""
A... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def get_all_students_with_fail_course(self):
students = []
for name, student in self.students.items():
for course, score in student['courses'].items():
if score < 60:
students.append(name)
break
return students | Get all students who have any score blow 60 |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
"""
A... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def get_course_average(self, course):
total = 0
count = 0
for student in self.students.values():
if course in student['courses']:
score = student['courses'][course]
if score is not None:
total += score
count += 1... | Get the average score of a specific course. |
ClassEval_4_sum | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
"""
A... | class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self... | def get_top_student(self):
top_student = None
top_gpa = 0
for name, student in self.students.items():
gpa = self.get_gpa(name)
if gpa is not None and gpa > top_gpa:
top_gpa = gpa
top_student = name
return top_student | Calculate every student's gpa with get_gpa method, and find the student with highest gpa |
ClassEval_5_sum | class AutomaticGuitarSimulator:
"""
This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
"""
def __init__(self, text) -> None:
self.play_text = text
def display(self, key, value):
"""
Print out chord and play tune wit... | class AutomaticGuitarSimulator:
"""
This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
"""
def __init__(self, text) -> None:
"""
Initialize the score to be played
:param text:str, score to be played
"""
... | def interpret(self, display=False):
if len(self.play_text) == 0:
return
else:
play_list = []
play_segs = self.play_text.split(" ")
for play_seg in play_segs:
pos = 0
for ele in play_seg:
if ele.isalpha():... | Interpret the music score to be played |
ClassEval_5_sum | class AutomaticGuitarSimulator:
"""
This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
"""
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
"""
Interpret the music score to... | class AutomaticGuitarSimulator:
"""
This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
"""
def __init__(self, text) -> None:
"""
Initialize the score to be played
:param text:str, score to be played
"""
... | def display(self, key, value):
return "Normal Guitar Playing -- Chord: %s, Play Tune: %s" % (key, value) | Print out chord and play tune with following format: Normal Guitar Playing -- Chord: %s, Play Tune: %s |
ClassEval_6_sum | class AvgPartition:
"""
This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length.
"""
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def get(self, in... | class AvgPartition:
"""
This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length.
"""
def __init__(self, lst, limit):
"""
Initialize the class with the given list and the number of ... | def setNum(self):
size = len(self.lst) // self.limit
remainder = len(self.lst) % self.limit
return size, remainder | Calculate the size of each block and the remainder of the division. |
ClassEval_6_sum | class AvgPartition:
"""
This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length.
"""
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
... | class AvgPartition:
"""
This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length.
"""
def __init__(self, lst, limit):
"""
Initialize the class with the given list and the number of ... | def get(self, index):
size, remainder = self.setNum()
start = index * size + min(index, remainder)
end = start + size
if index + 1 <= remainder:
end += 1
return self.lst[start:end] | calculate the size of each block and the remainder of the division, and calculate the corresponding start and end positions based on the index of the partition. |
ClassEval_7_sum | class BalancedBrackets:
"""
This is a class that checks for bracket matching
"""
def __init__(self, expr):
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
self.expr = expr
def check_balanced_brackets(self):
"""
... | class BalancedBrackets:
"""
This is a class that checks for bracket matching
"""
def __init__(self, expr):
"""
Initializes the class with an expression.
:param expr: The expression to check for balanced brackets,str.
"""
self.stack = []
self.left_brackets... | def clear_expr(self):
self.expr = ''.join(c for c in self.expr if (c in self.left_brackets or c in self.right_brackets)) | Clears the expression of all characters that are not brackets. |
ClassEval_7_sum | class BalancedBrackets:
"""
This is a class that checks for bracket matching
"""
def __init__(self, expr):
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
self.expr = expr
def clear_expr(self):
"""
Clears the... | class BalancedBrackets:
"""
This is a class that checks for bracket matching
"""
def __init__(self, expr):
"""
Initializes the class with an expression.
:param expr: The expression to check for balanced brackets,str.
"""
self.stack = []
self.left_brackets... | def check_balanced_brackets(self):
self.clear_expr()
for Brkt in self.expr:
if Brkt in self.left_brackets:
self.stack.append(Brkt)
else:
Current_Brkt = self.stack.pop()
if Current_Brkt == "(":
if Brkt != ")":
... | Checks if the expression has balanced brackets. |
ClassEval_8_sum | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
self.balance = balance
def withdraw(self, amount):
"""
Withdraws a certain amount from the acco... | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
se... | def deposit(self, amount):
if amount < 0:
raise ValueError("Invalid amount")
self.balance += amount
return self.balance | Deposits a certain amount into the account, increasing the account balance, return the current account balance. If amount is negative, raise a ValueError("Invalid amount"). |
ClassEval_8_sum | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
"""
Deposits a certain amount into the accoun... | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
se... | def withdraw(self, amount):
if amount < 0:
raise ValueError("Invalid amount")
if amount > self.balance:
raise ValueError("Insufficient balance.")
self.balance -= amount
return self.balance | Withdraws a certain amount from the account, decreasing the account balance, return the current account balance. If amount is negative, raise a ValueError("Invalid amount"). If the withdrawal amount is greater than the account balance, raise a ValueError("Insufficient balance."). |
ClassEval_8_sum | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
"""
Deposits a certain amount into the accoun... | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
se... | def view_balance(self):
return self.balance | Return the account balance. |
ClassEval_8_sum | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
"""
Deposits a certain amount into the accoun... | class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
se... | def transfer(self, other_account, amount):
self.withdraw(amount)
other_account.deposit(amount) | Transfers a certain amount from the current account to another account. |
ClassEval_9_sum | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
@staticmethod
def subtract(num1, num2):
"""
Subtracts two big numbers.
:param num1: The first number to subtract,str.
... | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
@staticmethod
def subtract(num1, num2):
"""
Subtracts two big numbers.
:param num1: The first number to subtract,str... | def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
num2 = num2.zfill(max_length)
carry = 0
result = []
for i in range(max_length - 1, -1, -1):
digit_sum = int(num1[i]) + int(num2[i]) + carry
carry = digit_sum... | Adds two big numbers. |
ClassEval_9_sum | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""
Adds two big numbers.
:param num1: The first number to add,str.
:param num2: The second numbe... | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""
Adds two big numbers.
:param num1: The first number to add,str.
:param num2: The second numb... | @staticmethod
def subtract(num1, num2):
if len(num1) < len(num2):
num1, num2 = num2, num1
negative = True
elif len(num1) > len(num2):
negative = False
else:
if num1 < num2:
num1, num2 = num2, num1
negative = Tru... | Subtracts two big numbers. |
ClassEval_9_sum | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""
Adds two big numbers.
:param num1: The first number to add,str.
:param num2: The second numbe... | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""
Adds two big numbers.
:param num1: The first number to add,str.
:param num2: The second numb... | @staticmethod
def multiply(num1, num2):
len1, len2 = len(num1), len(num2)
result = [0] * (len1 + len2)
for i in range(len1 - 1, -1, -1):
for j in range(len2 - 1, -1, -1):
mul = int(num1[i]) * int(num2[j])
p1, p2 = i + j, i + j + 1
... | Multiplies two big numbers. |
ClassEval_10_sum | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
sel... | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
""... | def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string)) | Clean the binary string by removing all non 0 or 1 characters. |
ClassEval_10_sum | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
sel... | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
""... | def calculate_binary_info(self):
zeroes_count = self.binary_string.count('0')
ones_count = self.binary_string.count('1')
total_length = len(self.binary_string)
zeroes_percentage = (zeroes_count / total_length)
ones_percentage = (ones_count / total_length)
return {
... | Calculate the binary string information, including the percentage of 0 and 1, and the total length of the binary string. |
ClassEval_10_sum | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
sel... | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
""... | def convert_to_ascii(self):
byte_array = bytearray()
for i in range(0, len(self.binary_string), 8):
byte = self.binary_string[i:i+8]
decimal = int(byte, 2)
byte_array.append(decimal)
return byte_array.decode('ascii') | Convert the binary string to ascii string. |
ClassEval_10_sum | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
sel... | class BinaryDataProcessor:
"""
This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
"""
def __init__(self, binary_string):
""... | def convert_to_utf8(self):
byte_array = bytearray()
for i in range(0, len(self.binary_string), 8):
byte = self.binary_string[i:i+8]
decimal = int(byte, 2)
byte_array.append(decimal)
return byte_array.decode('utf-8') | Convert the binary string to utf-8 string. |
ClassEval_11_sum | class BitStatusUtil:
"""
This is a utility class that provides methods for manipulating and checking status using bitwise operations.
"""
@staticmethod
@staticmethod
def has(states, stat):
"""
Check if the current status contains the specified status,and check the parameters whea... | class BitStatusUtil:
"""
This is a utility class that provides methods for manipulating and checking status using bitwise operations.
"""
@staticmethod
@staticmethod
def has(states, stat):
"""
Check if the current status contains the specified status,and check the parameter... | def add(states, stat):
BitStatusUtil.check([states, stat])
return states | stat | Add a status to the current status,and check the parameters wheather they are legal. |
ClassEval_11_sum | class BitStatusUtil:
"""
This is a utility class that provides methods for manipulating and checking status using bitwise operations.
"""
@staticmethod
def add(states, stat):
"""
Add a status to the current status,and check the parameters wheather they are legal.
:param state... | class BitStatusUtil:
"""
This is a utility class that provides methods for manipulating and checking status using bitwise operations.
"""
@staticmethod
def add(states, stat):
"""
Add a status to the current status,and check the parameters wheather they are legal.
:param stat... | @staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
return (states & stat) == stat | Check if the current status contains the specified status,and check the parameters wheather they are legal. |
This dataset is a modification of the ClassEval benchmark, designed for evaluating code summarization models beyond the function level. It explores the impact of function and class contexts on summary quality. The dataset includes modifications for evaluating at both function and class levels.
Paper: Code Summarization Beyond Function Level
Dataset Structure:
The dataset contains samples with the following fields:
class_id: Identifier for the class.class_code: The code of the class.skeleton: The structured blueprint for the class, including class-level and function-level information.method_code: The code of a method within the class.method_summary: The summary of the method.Dataset Splits:
test: 410 samples (400 + 10 samples for few-shot learing)This dataset is part of a broader study investigating code summarization at various levels (function, class, and repository). The complete study details, code, and evaluation results are available on GitHub: https://github.com/kilimanj4r0/code-summarization-beyond-function-level.