instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program that analyzes the distribution of words in a given text file. Your program should read the text file and output the frequency of each word in the file, sorted in descending order based on their frequency. Additionally, the program should exclude common stop words such as "the," "a...
codefeedback
You are tasked with implementing a function that manipulates pointers and ownership in Rust. The function takes a mutable pointer to a `ValueBox` containing a `Shadow` and returns a mutable pointer to a `ValueBox` containing an `Arc` of a trait object implementing the `Layer` trait. The function signature is as follow...
codefeedback
You are tasked with implementing a Python function that validates a given URL and returns a safe URL for redirection. The function should take into account the current host and a specified login redirect URL. You are provided with a code snippet that demonstrates the use of the `is_safe_url` function and the `resolve_u...
codefeedback
You are tasked with implementing a module dependency resolution algorithm for a software project. The project consists of several modules, each of which may depend on other modules. The code snippet provided is a simplified representation of the project structure, where modules are imported and used through the `pub us...
codefeedback
You are tasked with creating a Python function that interacts with a REST API to retrieve data and perform operations based on the received information. The function will need to make a GET request to a specified URL, parse the JSON response, and extract specific data to be used in the subsequent logic. Write a functi...
codefeedback
You are tasked with implementing a function that performs a specific type of indexing operation on a multi-dimensional array. The function takes in several parameters and uses them to access and retrieve a value from the array. Your task is to understand the given code snippet and create a function that replicates the ...
codefeedback
You are tasked with creating a Python module for visualizing iterations and time-related data in the context of Lambert's problem, a classic problem in orbital mechanics. Lambert's problem deals with determining the trajectory of an object moving between two points in space under the influence of gravity. Your module s...
codefeedback
You are tasked with implementing a program to process a list of trade orders from a cryptocurrency exchange. Each trade order is represented as a JSON object with the following fields: - "id": the unique identifier of the trade order (integer) - "order_type": the type of the order, either "buy" or "sell" (string) - "ra...
codefeedback
You are tasked with implementing a Python decorator that logs the execution time and memory usage of a function. You will need to create a decorator called `performance_logger` that can be applied to any function and will print out the execution time and memory usage of that function when it is called. Your task is to...
codefeedback
You are tasked with implementing a simple TCP server in C# using the Apache Mina library. The server should listen on a specified port for incoming connections and handle them using a custom protocol codec. Additionally, the server should provide a console interface for starting, stopping, and exiting the server. Your...
codefeedback
You are tasked with creating a Python function that processes a list of dictionaries representing students' exam scores and returns a JSON response indicating whether each student has passed or failed based on a given passing threshold. You are given the following code snippet as a starting point: ```python return jso...
codefeedback
You are tasked with creating a Python function that generates HTML code for a customizable button with an icon. The function should take in the button's label, kind (type of button), and icon name, and return the corresponding HTML code. The function signature should be: ```python def generate_icon_button(label: str, ...
codefeedback
You are tasked with implementing a LazyArray class that supports lazy evaluation of mathematical expressions. The LazyArray class should allow for the creation of lazy arrays and the composition of mathematical operations on these arrays without immediately evaluating the expressions. Additionally, the class should pro...
codefeedback
You are tasked with implementing a class to manage a set of N-best lists and their associated scores and alignments. The class should support operations for storing and accessing N-best scores and alignments, as well as managing score weights and their derivatives. Your task is to implement a class called `NBestManage...
codefeedback
You are tasked with implementing a Python decorator that caches the results of a function in a specified directory. The decorator should support both positional and keyword arguments and should be able to handle explicit cache directory specification. Your task is to complete the implementation of the `permoize` decor...
codefeedback
You are tasked with implementing a custom boolean class in Python that mimics the behavior of the built-in bool class. Your custom boolean class should support logical operations such as `and`, `or`, and `not`, as well as comparison operations such as `==` and `!=`. Additionally, the custom boolean class should be able...
codefeedback
You are working on a data management system and need to create a command-line tool to migrate related items to datagatherings. The tool should also support converting notes from markdown to HTML. You are provided with a code snippet that outlines the commands and their descriptions. Your task is to implement the functi...
codefeedback
You are tasked with implementing a memory management system for a WebGL application. The system needs to handle both static and dynamic memory allocations, as well as maintain a mapping of variable names to memory locations. The memory management system is represented by the following TypeScript interface: ```typescr...
codefeedback
You are tasked with creating a program that generates unique usernames by combining first and last names. The program should take a list of first names and a list of last names as input and output a list of unique usernames. If a username is already taken, the program should append a number to the username to make it u...
codefeedback
You are given a JavaScript code snippet that includes a test suite for a function called `part1Solver`. The function is intended to solve a specific problem, but the implementation is missing. Your task is to implement the `part1Solver` function based on the provided test cases and requirements. The `part1Solver` func...
codefeedback
You are tasked with implementing a Rust module to convert a given integer into its equivalent Roman numeral representation. Roman numerals are represented by combinations of letters from the set {I, V, X, L, C, D, M}, where each letter corresponds to a specific value: I (1), V (5), X (10), L (50), C (100), D (500), M (...
codefeedback
You are tasked with implementing a class to manage member flags for a data structure. The member flags can be set to indicate whether a member is optional, must-understand, a key, or default. Additionally, the class should handle the data type of the member. Your task is to create a C++ class `MemberFlags` with the fo...
codefeedback
You are tasked with creating a shell script that simulates a simplified version of the `ddg` command, which is used to search the web using the DuckDuckGo search engine. The script should take a search query as an argument and display the search results in the terminal using the `lynx` text-based web browser. Your scr...
codefeedback
You are working on a natural language processing (NLP) project and need to implement a custom data preprocessing pipeline for a text classification task. The code snippet provided is part of a Python class that handles the preprocessing of the dataset. The `torch.save` function is used to save the preprocessed data to ...
codefeedback
You are tasked with implementing a program to generate all possible permutations of a given set of distinct integers. Your program should take an array of integers as input and return a list of all permutations of the input integers. A permutation is a rearrangement of the elements of an array. For example, given the i...
codefeedback
You are tasked with simulating the movement of a 2D object within a game environment. The object's vertical movement is controlled by the provided code snippet, which uses a `rb2d` object to manage the object's position and velocity. The object moves within a vertical range defined by `maxHeight` and `-maxHeight`, and ...
codefeedback
You are tasked with implementing a method to find the closest enemy sprite to a given position within a specified maximum radius. You are provided with a class `SpriteUtils` containing a static method `get_closest_enemy` that takes the position coordinates (x, y), a maximum radius, a list of sprites, and a metric funct...
codefeedback
You are given a class `Comparator` with a method `compareLists` that compares two lists of strings. The method iterates through the elements of the lists and compares them lexicographically. If the lists are of unequal length, the method returns the difference in length. If the lists are of equal length, the method ret...
codefeedback
You are tasked with implementing a board game where players can set the color of individual tiles on a game board. The game board is represented as a grid of tiles, each identified by a unique combination of a letter and a number (e.g., "A1", "B3", "G5"). Tiles can be colored either white or black. The code snippet pro...
codefeedback
You are tasked with creating a phishing website detection system using a custom random forest classifier. The dataset contains various features related to website characteristics, and the target variable indicates whether the website is a phishing site or not. Your goal is to train the custom random forest classifier a...
codefeedback
You are tasked with implementing a Python function that calculates the total number of occurrences of a given word in a list of strings. The function should be case-insensitive and should count partial matches as well. For example, if the word is "cat", it should count occurrences of "cat", "cats", "category", etc. Th...
codefeedback
You are tasked with implementing a JavaScript function that processes input from an input mask component and returns the unmasked value. The input mask component is designed to format user input according to a specified mask. The provided code snippet is a part of the component's implementation and extracts necessary p...
codefeedback
You are tasked with implementing a Python function that processes a given text and extracts statistics about the sentences within it. The function should take a string of text as input and return a dictionary containing the following statistics for each sentence: - The number of words in the sentence - The average word...
codefeedback
You are a cybersecurity analyst investigating a suspicious server setup. You have intercepted the following code snippet that was executed during the boot process of a server belonging to MegaMaxCorpInc, a company known for its questionable practices. Your task is to analyze the code and identify potential security vul...
codefeedback
You are working on a Python class for simulating ultrasound transducer arrays. The class contains methods for different types of transducer arrays. You need to implement the `xdc_convex_array` and `xdc_convex_focused_array` methods. The `xdc_concave` method is already implemented for reference. The `xdc_concave` metho...
codefeedback
You are working on a TypeScript project that involves using guards to validate different types of data. Guards are functions that return a boolean value based on whether the input matches a specific type or condition. In this project, you have a directory containing multiple guard files, each exporting a guard function...
codefeedback
You are tasked with implementing a Python function that processes a given string to extract specific information and perform a transformation based on the extracted data. Write a function called `extract_and_transform` that takes in a string `input_str` as input. The function should perform the following tasks: 1. Ext...
codefeedback
You are tasked with implementing a Promise class in Swift. A Promise is an object representing the eventual completion or failure of an asynchronous operation. It allows you to attach callbacks to handle the success or failure of the operation. Your task is to create a Promise class that supports the `then` and `reduce...
codefeedback
You are tasked with creating a script to simulate a progress bar in a Linux environment using bash scripting. The progress bar will be displayed using the `org.kde.kdialog.ProgressDialog` interface and updated using `dbus-send` commands. The script should take an input parameter `total` representing the total number of...
codefeedback
You are tasked with developing a configuration management system for a distributed application. The system will utilize Spring Boot and Redis for managing distributed caching. Your task is to create a class that will handle the configuration properties for the Redis cluster and ensure that the properties are properly l...
codefeedback
You are working on a software system that involves combining objects representing certain entities. The given code snippet is a method `combine` within a class, which takes two objects `n` and `m` as input, combines them, and returns the modified `n` object. The objects have attributes `temps` and `moves`, and there is...
codefeedback
You are tasked with creating a program to analyze and manipulate data from a database table. The table `realisasi` contains information about the realization of activities, with columns `id_SubKegiatan`, `id_Bulan`, and other unspecified columns. The given code snippet is a part of a PHP script that is intended to disp...
codefeedback
You are tasked with implementing a simplified version of a CSS selector evaluator. The provided code snippet demonstrates the creation of a selector and the evaluation of its value. Your task is to create a class that can handle the evaluation of selectors and their values. You are given the following classes: ```jav...
codefeedback
You are tasked with implementing a binary search tree (BST) in Python. A binary search tree is a data structure that allows for efficient insertion, deletion, and search operations. Each node in a BST has at most two child nodes, referred to as the left child and the right child. The key value of the left child is less...
codefeedback
You are tasked with creating a Python function that preprocesses and trains a deep learning model for speech synthesis using the Tacotron architecture. The provided code snippet includes loading preprocessed data, defining the model architecture, and compiling the model for training. Your task is to implement the prepr...
codefeedback
You are tasked with implementing a synchronization mechanism for a system that handles different types of configuration updates. The system supports three types of configuration operations: `ProtoconfSync`, `ProtoconfMutation`, and `ProtoconfMutationSync`. The `ProtoconfSync` operation synchronizes the configuration ac...
codefeedback
You are working on a movie database application that stores information about movies and their writers. The application has a method called `updateMovieWriterByMovieAll` which is responsible for updating the writer of a movie. The method takes two parameters: `movieId` of type Integer and `writerId` of type Integer. Yo...
codefeedback
You are working on a project that involves organizing and exporting various modules from a TypeScript application. The project structure includes multiple directories, each containing an `index.ts` file that exports specific modules. Your task is to create a script that dynamically generates a single `index.ts` file at...
codefeedback
You are given a Python class representing a disjoint set data structure with union-find operations. The class has the following attributes and methods: Attributes: - `parents`: a dictionary mapping nodes to their parent nodes - `ranks`: a dictionary mapping nodes to their ranks - `roots`: a set containing the root nod...
codefeedback
You are tasked with implementing a database migration system for a content management system (CMS). The CMS uses a schema builder to manage database changes. The given code snippet is a part of a database migration script written in C#. The `UpdateFrom1` method is responsible for updating the database schema from versi...
codefeedback
You are tasked with implementing a learning rate scheduler for a convolutional neural network (CNN) using MXNet, a popular deep learning framework. The provided code snippet is a part of the training process for a specific model, `resnet50_v2`, and it demonstrates the adjustment of learning rates for pre-trained convol...
codefeedback
You are tasked with creating a custom field class in Python that will be used for deserialization in a data processing application. The custom field, named `CronField`, should be designed to handle the deserialization of cron expressions, which are used to define time intervals for scheduling tasks. A cron expression c...
codefeedback
You are working on a project that involves processing and merging geospatial image files. Your task is to write a Python function that takes a directory path as input, locates all the GeoTIFF files within that directory, and merges them into a single output GeoTIFF file. The merging process should be performed using th...
codefeedback
You are working on a project to predict the network latency of a convolutional neural network (CNN) model. The given code snippet is part of a class that contains a method for predicting the network latency based on the architecture of the CNN model. The method `predict_network_latency` takes the CNN model `net` and an...
codefeedback
You are given a text file containing a software license agreement. Your task is to write a program that reads the file and counts the occurrences of each unique word in the document. For the purpose of this problem, a word is defined as a sequence of characters separated by spaces or punctuation marks. The program shou...
codefeedback
You are tasked with creating a SwiftUI view for displaying COVID-19 statistics for different regions in Germany. The given code snippet shows the layout of the main view, which includes subviews for displaying various statistics related to the pandemic. Your task is to implement the subviews and populate them with rele...
codefeedback
You are tasked with creating a Python unit test for a Flask web application. The application has a route that returns a JSON response containing information about a user. Your goal is to write a unit test using the `pytest` framework to test this route. You have been provided with a code snippet that sets up a fixture...
codefeedback
You are working on a web application that allows users to edit their profiles. The application uses Flask and WTForms for form validation. You need to create a form for administrators to edit user profiles, including fields for email, sports interest, and music interest. Your task is to complete the `EditProfileAdminF...
codefeedback
You are tasked with implementing a search functionality for a test application using Java. The application uses the `com.github.magrifle.data.searchapi` library to perform searches on entities of type `TestEntity`. The `TestEntity` class has the following properties: - `id` (String) - `name` (String) - `creationDate` (...
codefeedback
You are tasked with implementing a simple boid simulation using the Pygame library in Python. Boids are artificial life forms that exhibit flocking behavior. In this problem, you will create a program to simulate the movement and interaction of boids on a 2D plane. The provided code snippet is part of the visualizatio...
codefeedback
You are tasked with developing a program to process and analyze taxi trip data. The data is stored in a pandas DataFrame named `df`, and it contains information about taxi trips, including pickup and dropoff datetimes. The code snippet provided demonstrates some operations performed on the DataFrame. Your task is to im...
codefeedback
You are tasked with implementing a custom indicator logic for analyzing financial market data. The given code snippet provides a partial implementation of the indicator logic within a class. The class has two deque objects, `high` and `low`, with a specified maximum length `period`. Additionally, there is a variable `l...
codefeedback
You are tasked with creating a Java program that utilizes the Jersey framework to set up a simple RESTful web service. Your program should expose an endpoint that accepts a GET request and returns a specific response. The response should be a JSON object containing information about a book. Your task is to complete th...
codefeedback
You are tasked with creating a custom GraphQL enum type and implementing a query to retrieve data based on this custom enum input. The provided code snippet is a part of a PHP project using the `Spawnia\Sailor` library for GraphQL operations. Your task is to complete the implementation of the custom enum type and the ...
codefeedback
You are tasked with creating a program to manage the allocation of dining tables in a restaurant. The restaurant uses Apache Helix, a cluster management framework, to maintain the state of its resources. The code snippet provided is a part of the program that interacts with Helix to retrieve the external view of the di...
codefeedback
You are tasked with implementing a C++ addon for Node.js that provides bindings for elliptic curve cryptography operations. The given code snippet is a part of the initialization function for the addon, which sets up the bindings for the elliptic curve operations. Your task is to complete the implementation of the Ell...
codefeedback
You are tasked with implementing a custom charting feature for a reporting tool using Java. The reporting tool uses the net.sf.jasperreports library, and you need to create a custom chart plot using the JRCategoryPlot class. Your task is to create a Java class that extends the JRCategoryPlot class and overrides the dr...
codefeedback
You are given a directed graph with N nodes and M edges. Each edge is represented as a pair (u, v, w), where u and v are the nodes connected by the edge, and w is the weight of the edge. The graph may contain cycles and may not be strongly connected. Your task is to implement a depth-first search (DFS) algorithm to fi...
codefeedback
You are working on a web application that includes user profiles. The code snippet provided is a simplified representation of a Django model for a user profile. The `ProfileUser` model is associated with the built-in `User` model through a one-to-one relationship. Additionally, it includes two many-to-many relationship...
codefeedback
You are tasked with implementing a simplified version of a request builder for a trading platform. The provided code snippet is part of a Python script that uses a request builder to construct and send a request to the trading platform's API. Your task is to create a class that mimics the behavior of the request builde...
codefeedback
You are tasked with implementing a Python class that provides functionality for matching and extracting variables from a given pattern. The class should support matching a pattern against a given input string and extracting variables from the pattern based on the matched input. The class, named `PatternMatcher`, shoul...
codefeedback
You are tasked with creating a script to automate the setup process for a Python project. The script should perform the following tasks: 1. Create a virtual environment using Python 2.7 in the user's home directory, or exit with an error code of 1 if unsuccessful. 2. Activate the virtual environment. 3. Install the de...
codefeedback
You are tasked with creating a program to process a list of transactions in a cryptocurrency network. Each transaction consists of a sender's address, a list of recipients' addresses, and the corresponding values to be transferred. Your program needs to validate the transactions and calculate the total value sent by ea...
codefeedback
You are tasked with creating a Python script that dynamically generates a command-line interface (CLI) tool based on the entry points specified in a setup.py file. The setup.py file is a standard way of defining distribution metadata for a Python package. It includes information such as the package name, version, depen...
codefeedback
You are tasked with creating a script to manage a polling process. The script should handle starting, stopping, and checking the status of the polling process. The script should be able to start the polling process if it is not already running, stop the polling process if it is running, and check the status of the poll...
codefeedback
You are working on a project that involves processing and categorizing different types of labels. The `label_kinds` variable contains a list of label types, where each type is represented as a string. Your task is to write a Python function that takes the `label_kinds` list as input and returns a dictionary containing ...
codefeedback
You are tasked with implementing a function that will parse a given HTML code snippet and count the number of nested HTML elements within it. For the purpose of this problem, we will consider only the opening tags of HTML elements, and we will ignore any attributes or closing tags. You need to create a function `count...
codefeedback
You are tasked with implementing a decision tree node in Python for a machine learning application. The decision tree node has the following attributes: - `feature_index`: an integer representing the index of the feature used for splitting at this node. - `threshold`: a float representing the threshold value for the fe...
codefeedback
You are tasked with implementing a Python function that generates a ResNet model based on the given configuration. The ResNet model is a type of neural network commonly used for image recognition tasks. Your function should take in the model type (e.g., "resnet18" or "resnet34"), a boolean indicating whether the model ...
codefeedback
You are tasked with creating a program to analyze hand gestures captured by a camera. The program should be able to identify and count the number of fingers extended by the user's hand in the captured image. To achieve this, you need to implement a function that takes an image of a hand as input and returns the count ...
codefeedback
You are tasked with creating a class that represents transfer statistics for a journey, including the number of transfers, departure and arrival information, and walking distance. Your goal is to implement the missing methods and properties for the `TransferStats` class based on the given code snippet. The `TransferSt...
codefeedback
You are tasked with creating a Python function that processes a given series of strings representing dates in the format "YYYY/WW", where YYYY is the year and WW is the week number. The function should convert these strings into a datetime series and then extract the week number from each date. Write a function `extra...
codefeedback
You are tasked with implementing a nonlinear step function for a simulation framework. The function `nonlinear_step` takes in several parameters and performs a nonlinear step operation on a given matrix. The function signature is as follows: ```cpp void nonlinear_step(std::shared_ptr<const DefaultExecutor> exec, int n...
codefeedback
You are tasked with creating a Python function to calculate the efficiency of a Rankine cycle for a given set of parameters. The Rankine cycle is a thermodynamic cycle used in power plants to convert heat into mechanical work. The function `rankine_superheated` takes in keyword arguments representing various parameters...
codefeedback
You are tasked with creating a script to manage the lifecycle of Linux containers using the LXC (Linux Containers) tool. The script should start a specified container, wait for it to finish booting, and then restart the container. You are given a code snippet that partially implements this functionality. The snippet u...
codefeedback
You are tasked with implementing a simplified URL parser in Java. Your task is to complete the `getUrl` method in the given `UrlParser` class. The `getUrl` method should take a URL string as input and return the domain name extracted from the URL. The URL string will be in the format "http://www.example.com/path/to/re...
codefeedback
You are tasked with creating a Python program that simulates a cooperative game using the `pycoop` library. The game involves a team of players working together to achieve a common goal. Each player has a set of skills and attributes that contribute to the team's success. The goal is to optimize the team's performance ...
codefeedback
You are tasked with creating a program that simulates a simplified version control system. Your program should be able to handle importing and merging changes between different components of a software system. You are given a code snippet that includes a function `import_merge()` and some placeholder functions `update...
codefeedback
You are working on a simulation of chemotactic behavior in a biological system. In this simulation, a chemotactic synapse lag is implemented using the given code snippet. The system tracks the age of a target, the time since the last visit, and generates random numbers for comparison. The relevant variables and operat...
codefeedback
You are tasked with implementing a custom recurrent neural network (RNN) cell in Python using PyTorch. The RNN cell takes an input tensor and a hidden state tensor as input, and returns the next hidden state tensor. However, there is a bug in the code that needs to be identified and fixed. The provided code snippet co...
codefeedback
You are tasked with implementing a data structure that supports two operations: `snap()` and `set(index, val)`. The `snap()` operation captures the current state of the data structure, and the `set(index, val)` operation updates the value at the given index. After each `snap()` operation, the state of the data structur...
codefeedback
You are tasked with implementing a collaborative filtering algorithm to recommend items to users based on their past interactions. Collaborative filtering is a technique commonly used in recommendation systems to predict the interests of a user by collecting preferences from many users. In this problem, you will be wor...
codefeedback
You are tasked with creating a Python class that generates an HTML legend with a color bar for a data visualization project. The legend should display the number of matching pages in descriptive sources. Your task is to implement the `HTMLLegend` class with the following requirements: - The `HTMLLegend` class should h...
codefeedback
You are tasked with implementing a function to calculate a polynomial matrix for augmenting radial basis functions. The function should take in two arrays, `x` and `y`, representing the coordinates of points, and an integer `order` representing the order of the polynomial matrix. The polynomial matrix should be constru...
codefeedback
You are tasked with creating a program that processes a given tuple and prints out specific values from it. The tuple contains elements of various data types, including integers, arrays, floats, booleans, and string references. Your task is to extract and print specific values from the tuple according to their respecti...
codefeedback
You are tasked with implementing a web scraping algorithm to extract specific information from a website. The website contains a list of products with their names, prices, and availability. Your goal is to scrape this information and store it in a structured format for further analysis. You are provided with a Python ...
codefeedback
You are tasked with creating a Python program to manage a simple file organization system. The program should prompt the user to input the path of a directory where images are stored. If the specified directory does not exist, an error message should be displayed. If the directory exists, the program should allow the u...
codefeedback
You are tasked with implementing a parser for network-related data using the Rust programming language. The given code snippet is part of a larger Rust program that uses the `nom` crate for parsing. The `nom` crate is a parser combinator library that allows for the creation of complex parsers by combining simpler parse...
codefeedback
You are tasked with implementing a data structure to manage a messaging channel in a messaging application. The provided code snippet is a part of the implementation of the encoding process for the channel data. The `encoder` is an instance of a custom encoder, and `ChannelCodingKeys` is an enumeration defining the key...
codefeedback
You are tasked with creating a script that processes command-line arguments and executes a specific command using the provided arguments. The script should handle the execution of a command called `kmods-via-containers` with the `wrapper` option and additional arguments. Your task is to write a Bash script that takes ...
codefeedback