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_97_sum
class Words2Numbers: """ The class provides a text-to-number conversion utility, allowing conversion of written numbers (in words) to their numerical representation. """ def __init__(self): self.numwords = {} self.units = [ "zero", "one", "two", "three", "four", "five", "six...
class Words2Numbers: """ The class provides a text-to-number conversion utility, allowing conversion of written numbers (in words) to their numerical representation. """ def __init__(self): """ Initialize the word lists and dictionaries required for conversion """ self....
def text2int(self, textnum): textnum = textnum.replace('-', ' ') current = result = 0 curstring = "" onnumber = False for word in textnum.split(): if word in self.ordinal_words: scale, increment = (1, self.ordinal_words[word]) current ...
Convert the word string to the corresponding integer string
ClassEval_97_sum
class Words2Numbers: """ The class provides a text-to-number conversion utility, allowing conversion of written numbers (in words) to their numerical representation. """ def __init__(self): self.numwords = {} self.units = [ "zero", "one", "two", "three", "four", "five", "six...
class Words2Numbers: """ The class provides a text-to-number conversion utility, allowing conversion of written numbers (in words) to their numerical representation. """ def __init__(self): """ Initialize the word lists and dictionaries required for conversion """ self....
def is_valid_input(self, textnum): textnum = textnum.replace('-', ' ') for word in textnum.split(): if word in self.ordinal_words: continue else: for ending, replacement in self.ordinal_endings: if word.endswith(ending): ...
Check if the input text contains only valid words that can be converted into numbers.
ClassEval_98_sum
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): self.file_name = file_name self.root = None def write_xml(self, fil...
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): """ Initialize the XMLProcessor object with the given file name. ...
def read_xml(self): try: tree = ET.parse(self.file_name) self.root = tree.getroot() return self.root except: return None
Reads the XML file and returns the root element.
ClassEval_98_sum
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): self.file_name = file_name self.root = None def read_xml(self): ...
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): """ Initialize the XMLProcessor object with the given file name. ...
def write_xml(self, file_name): try: tree = ET.ElementTree(self.root) tree.write(file_name) return True except: return False
Writes the XML data to the specified file.
ClassEval_98_sum
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): self.file_name = file_name self.root = None def read_xml(self): ...
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): """ Initialize the XMLProcessor object with the given file name. ...
def process_xml_data(self, file_name): for element in self.root.iter('item'): text = element.text element.text = text.upper() return self.write_xml(file_name)
Modifies the data in XML elements and writes the updated XML data to a new file.
ClassEval_98_sum
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): self.file_name = file_name self.root = None def read_xml(self): ...
import xml.etree.ElementTree as ET class XMLProcessor: """ This is a class as XML files handler, including reading, writing, processing as well as finding elements in a XML file. """ def __init__(self, file_name): """ Initialize the XMLProcessor object with the given file name. ...
def find_element(self, element_name): elements = self.root.findall(element_name) return elements
Finds the XML elements with the specified name.
ClassEval_99_sum
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): self.file_name = file_name def extract_all(self, output_path): """ Extract all zip fil...
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): """ Initialize file name :param file_name:string """ self.file_name = file...
def read_zip_file(self): try: zip_file = zipfile.ZipFile(self.file_name, 'r') return zip_file except: return None
Get open file object
ClassEval_99_sum
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): self.file_name = file_name def read_zip_file(self): """ Get open file object :...
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): """ Initialize file name :param file_name:string """ self.file_name = file...
def extract_all(self, output_path): try: with zipfile.ZipFile(self.file_name, 'r') as zip_file: zip_file.extractall(output_path) return True except: return False
Extract all zip files and place them in the specified path
ClassEval_99_sum
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): self.file_name = file_name def read_zip_file(self): """ Get open file object :...
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): """ Initialize file name :param file_name:string """ self.file_name = file...
def extract_file(self, file_name, output_path): try: with zipfile.ZipFile(self.file_name, 'r') as zip_file: zip_file.extract(file_name, output_path) return True except: return False
Extract the file with the specified name from the zip file and place it in the specified path
ClassEval_99_sum
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): self.file_name = file_name def read_zip_file(self): """ Get open file object :...
import zipfile class ZipFileProcessor: """ This is a compressed file processing class that provides the ability to read and decompress compressed files """ def __init__(self, file_name): """ Initialize file name :param file_name:string """ self.file_name = file...
def create_zip_file(self, files, output_file_name): try: with zipfile.ZipFile(output_file_name, 'w') as zip_file: for file in files: zip_file.write(file) return True except: return False
Compress the specified file list into a zip file and place it in the specified path