instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a module loader for a music theory library. The given code snippet is an excerpt from the index file of the library, which exports two modules: `majorScale` and `minorScale`. Each module is expected to contain functions and data related to major and minor musical scales, respectively.
... | codefeedback |
You are tasked with creating a Python class that utilizes natural language processing (NLP) to extract named entities from text. Your task is to implement the `NeuralNER` class, which inherits from the `RuleNER` class and utilizes the `padatious` library for intent recognition. The `padatious` library is used for train... | codefeedback |
You are tasked with implementing a pattern matching algorithm using the given code snippet as a reference. The `PatternMatchUtils.simpleMatch` method takes two parameters: `pattern` and `text`, and returns a boolean value indicating whether the pattern matches the text.
Your task is to implement a custom pattern match... | codefeedback |
You are tasked with implementing a generic protocol in Swift that defines a method for calculating the area of a geometric shape. The protocol should be able to handle various types of shapes, such as rectangles, circles, and triangles. Additionally, you need to create concrete types that conform to this protocol and p... | codefeedback |
You are tasked with implementing a thread-safe lazy initialization mechanism for a singleton class in C++. The given code snippet is a part of the Singleton class and includes a method `AddCreator` that takes a `SingletonId` as a parameter and returns a `SingletonLazyCreator` object.
Your task is to complete the imple... | codefeedback |
You are tasked with creating a Rust library for managing and describing Pokémon. The provided code snippet imports the module `pokemon_description` into the current scope. Your task is to implement the `pokemon_description` module, which should include the necessary structures and traits to describe Pokémon.
Your impl... | codefeedback |
You are working on a Python project that involves a game development framework. The project structure includes several modules, each containing classes and functions for different game components. The code snippet provided is from the main module, which is responsible for importing classes and functions from other modu... | codefeedback |
You are given a binary search tree (BST) and an integer K. Your task is to write a function to find the Kth smallest element in the BST.
The function signature is as follows:
```cpp
int KthSmallestElement(Node *root, int &K);
```
The function takes in the root of the BST and an integer K. It should return the Kth sma... | codefeedback |
You are tasked with creating a script to parse a set of files and extract specific information from them. The script should iterate through the provided file names, extract the first three lines of each file, search for a line containing the word "comment", and then extract a specific substring from that line. If the e... | codefeedback |
You are tasked with creating a Python class that manages a user stream and provides a method to listen for incoming data. Your task is to implement the `UserStreamManager` class with the following requirements:
1. The class should have a property `last_recv_time` that returns the timestamp of the last received data as... | codefeedback |
You are tasked with creating a React component for a navigation link that should be disabled under certain conditions. Your task is to implement the `NavLinkClass` component, which should render a navigation link with the following properties: `target`, `disable`, `text`, `title`, `extraClass`, and `onClick`. The `disa... | codefeedback |
You are tasked with creating a program that manages dependencies for a package manager. The package manager uses a configuration file to define targets and their dependencies. Each target can be either a module or a test suite and can depend on other targets within the package or on products in external packages.
Your... | codefeedback |
You are tasked with implementing a function to serialize Python objects to JSON with the ability to specify the precision of floating-point numbers. You are given a code snippet that calls a function `js.safe_dump` with various arguments, including `float_precision`, to control the precision of floating-point numbers i... | codefeedback |
You are tasked with simulating a simple communication system between two devices using channels in Rust. The system consists of a Gameboy device and a local sender, which communicate through a serial channel. The Gameboy device can send data to the local sender, and the local sender can respond with an acknowledgment s... | codefeedback |
You are tasked with implementing a simple Generative Adversarial Network (GAN) for generating images. The GAN consists of a generator and a discriminator, and the training process involves updating the generator and discriminator alternately. The provided code snippet is a part of the training loop for the GAN. The `g_... | codefeedback |
You are tasked with implementing a function that parses a configuration object and extracts specific key-value pairs based on certain criteria. The configuration object is represented as a JavaScript object, and it contains various key-value pairs. Each key represents a configuration option, and its corresponding value... | codefeedback |
You are tasked with implementing a simple neural network training process using PyTorch. The given code snippet initializes some variables and tensors for this purpose. Your task is to complete the implementation by writing the training loop and loss calculation.
Given the following code snippet:
```python
n_samples =... | codefeedback |
You are tasked with creating a program that simulates a simple navigation system for a delivery robot. The robot is placed in a grid-like environment, and it can move in four directions: up, down, left, and right. The environment is represented as a 2D grid, where each cell can either be empty or blocked. The robot can... | codefeedback |
You are tasked with implementing a thread-safe cache data structure that supports the operations of getting a value by key and checking if a key exists in the cache. The cache should be able to handle concurrent access from multiple threads without causing data corruption or inconsistency.
You are provided with the fo... | codefeedback |
You are working on a project that involves interacting with a database system called "Alfresco." The code snippet provided is a part of a script that is supposed to connect to the Alfresco database and perform some operations. However, the snippet seems to be incomplete and lacks the necessary connection and operation ... | codefeedback |
You are tasked with creating a program to analyze the performance of a sports team based on match results. The program should take an array of match objects and a team name as input, and then calculate the number of wins for the specified team. Each match object contains information about the home team, away team, and ... | codefeedback |
You are tasked with implementing a custom floor function that rounds a given number down to the nearest integer. The standard floor function is typically available in most programming languages, but for the purpose of this problem, you are required to create your own implementation.
Your task is to write a function `c... | codefeedback |
You are tasked with creating a Python class that generates random musical phrases. The class should have methods to generate random notes and random mode types, and then combine them to form a musical phrase. The musical phrase should be a combination of a random note and a random mode type, with an optional note appen... | codefeedback |
You are tasked with creating a Java program that simulates a simple library management system. The system should allow users to borrow and return books, display available books, and display the details of a specific book.
You are provided with a partial implementation of the `Book` class and the `Library` class. Your ... | codefeedback |
You are tasked with implementing a function to process and generate output from a file descriptor set. The file descriptor set is represented by a struct `FileDescriptorSet` containing a vector of `FileDescriptorProto` instances. Each `FileDescriptorProto` instance represents a file descriptor.
Your task is to impleme... | codefeedback |
You are tasked with creating a Python program to analyze data from the Chinese social media platform Weibo. Your program should be able to retrieve and analyze user posts, comments, and other relevant data from Weibo using the `weibo` library and a configuration file.
Your program should perform the following tasks:
1... | codefeedback |
You are tasked with implementing a simple syntax tree node for a block statement in a programming language. The provided code snippet is a partial implementation of the `BlockStatement` class, which represents a block of code enclosed within curly braces. The class has private fields `_statements`, `_openBraceToken`, `... | codefeedback |
You are working on a project that involves integrating with the Windows Shell API to perform various file and system operations. As part of this project, you need to implement a function that retrieves information about a file that has been dragged and dropped onto your application's window.
You have access to the fol... | codefeedback |
You are tasked with solving a classic problem in combinatorics - the rabbit pairs problem. In this problem, you are given two positive integers, n and k, where n represents the number of months and k represents the number of offspring produced by each pair of rabbits. The problem involves calculating the total number o... | codefeedback |
You are tasked with implementing a function that calculates the total number of seconds between two given dates and times. The function should take in four parameters: the year, month, day, and time (in 24-hour format) for both the start and end dates. The time should be represented in the format "HH:MM:SS" (hours, min... | codefeedback |
You are tasked with implementing a Gaussian Mixture Model (GMM) algorithm to cluster a given dataset. A Gaussian Mixture Model is a probabilistic model that assumes all the data points are generated from a mixture of several Gaussian distributions with unknown parameters. The goal is to estimate these parameters and as... | codefeedback |
You are tasked with simulating a university's production system for generating students and scientists. The university has a set of togable productions that can be activated or deactivated. Each togable production is associated with a specific type of production, such as generating students or scientists. The code snip... | codefeedback |
You are tasked with implementing a program to process a series of input lines and perform specific operations based on the content of each line. The input consists of lines containing integers separated by spaces. Your program needs to process the input and perform the following operations:
1. If a line contains only ... | codefeedback |
You are working on a project that involves functional data analysis using the `scikit-fda` library in Python. Functional data analysis deals with data that can be represented as functions, such as curves or time series. In this problem, you are tasked with creating a function that calculates the angular distance betwee... | codefeedback |
You are given a Swift code snippet that includes some incomplete code related to extensions and collections. Your task is to complete the code and implement a custom collection type that conforms to the `RandomAccessCollection` protocol.
Your custom collection type, named `Sampling`, should be a generic collection tha... | codefeedback |
You are given a list of integers. Your task is to write a function to determine if the list contains any duplicates. If there are any duplicates in the list, the function should return True; otherwise, it should return False.
You are to implement the function `containsDuplicate(nums)` where:
- `nums`: a list of intege... | codefeedback |
You are tasked with creating a custom build tool that analyzes a given JavaScript file and extracts all the imported modules. The tool should be able to identify the imported modules and provide a count of how many times each module is imported. For this problem, you will focus on extracting the imported modules from t... | codefeedback |
You are tasked with implementing a thread pool manager in C++. The thread pool manager should be able to handle multiple tasks concurrently using a fixed number of worker threads. The code snippet provided is a part of the thread pool manager's `execute` function, which is responsible for executing tasks from a queue.
... | codefeedback |
You are tasked with implementing a simple routing system for a mobile application. The provided code snippet contains a part of a `Router` class that is responsible for instantiating view controllers based on a given path. Your task is to extend this routing system by implementing a new method that allows for passing d... | codefeedback |
You are tasked with implementing a custom data structure in Swift called `MapCursor`. The `MapCursor` is a generic type that represents a cursor over a collection of elements. Your goal is to create a method `map` within the `MapCursor` class that applies a transformation to each element in the collection and returns a... | codefeedback |
You are tasked with implementing a simplified version of the TopHitsAggregation struct in Swift. The TopHitsAggregation is a type of aggregation used in Elasticsearch to group result sets by certain fields via a bucket aggregator. Your task is to create a Swift struct that represents this aggregation and provides the n... | codefeedback |
You are tasked with creating a Python program to manage a list of people and their ages. The program should allow users to perform various operations on the list, such as adding new people, removing existing ones, and displaying specific elements. Your task is to implement the required functionality based on the given ... | codefeedback |
You are tasked with implementing a simple key-value store in Rust. The key-value store should support the following operations: inserting a key-value pair, retrieving the value associated with a given key, and removing a key-value pair from the store.
Your task is to implement the `KeyValueStore` struct and its associ... | codefeedback |
You are given the performance metrics of two machine learning models, logistic regression, and random forest, on a binary classification task. The performance metrics include the test accuracy and the confusion matrix for each model.
The confusion matrix for a binary classification task is a 2x2 matrix that represents... | codefeedback |
You are tasked with implementing a module in Rust that manages assets for a game. The provided code snippet shows the declaration of a module named `assets`. Your task is to create a struct within this module to represent an asset, and then implement methods for this struct to perform various operations related to asse... | codefeedback |
You are tasked with implementing a Python function that calculates the precision, recall, and F1-score for a given classification model. Additionally, you need to create a visualization of the loss function values during the training process using matplotlib.
Your function should take the following inputs:
- `y_true_t... | codefeedback |
You are tasked with implementing a custom sorting algorithm for a collection of `Player` objects based on their points and names. Each `Player` object has two properties: `Name` (a string) and `Points` (an integer). The sorting algorithm should first sort the players in descending order of their points and then, for pl... | codefeedback |
You are tasked with creating a Python class to represent a clinical study and its associated trial summaries. The class should have methods to calculate and retrieve various statistics related to the trials conducted within the study.
Your task is to implement the `ClinicalStudy` class with the following specificatio... | codefeedback |
You are tasked with creating a program that generates a report of the number of commits made by each user in a given Git repository. The program should parse the Git log and count the number of commits made by each user, then output the results in a tabular format.
You are given a code snippet that represents the begi... | codefeedback |
You are tasked with creating a program that simulates the behavior of a simple system with a single process and four possible states: idle, error, finished, and ok. The system is governed by a set of locations and edges, each with specific properties and conditions. The provided code snippet outlines the properties of ... | codefeedback |
You are tasked with creating a JavaScript function that processes different actions related to displaying and hiding advertisements in a mobile app. The function receives an `actionKey` and an `action` object as parameters. The `actionKey` represents the type of action to be performed, and the `action` object contains ... | codefeedback |
You are tasked with creating a Python class that simulates a simple text formatter. The class should provide methods for applying various text formatting options such as bold, italic, underline, and color to a given text. The provided code snippet is a part of the class that applies color to the text.
Your task is to ... | codefeedback |
You are tasked with implementing a dependency resolution algorithm for a software package manager. The package manager needs to resolve dependencies and perform operations in the correct order. Each dependency is represented as a tuple of the form (package_name, dependent_package_name), where package_name depends on de... | codefeedback |
You are tasked with implementing a form validation system for a user registration page in a mobile application. The system should handle error indication and keyboard focus for the input fields. The code snippet provided is a part of the validation system and is written in Swift for iOS development.
The `setErrorIndic... | codefeedback |
You are working on a deployment script for a web application, and you need to write a function to handle the file management operations. The function should take an array of file names and perform the following operations for each file:
1. Change the current directory to three levels up from the current directory.
2. ... | codefeedback |
You are tasked with creating a Python function that takes a string representing a mathematical expression as input and evaluates the expression to produce the result. The expression can contain the four basic arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/). The input expressio... | codefeedback |
You are tasked with creating a Django management command that checks for the existence of a specific permission and content type in the database. The permission is related to a model called "config" in the "constance" app. If the content type and permission do not exist, the command should create them.
Your task is to... | codefeedback |
You are tasked with creating a language translation system for a web application. The system should allow for the translation of specific site-related phrases and labels. To achieve this, you need to implement a function that takes a language code and returns a translated array of site-related phrases based on the give... | codefeedback |
You are tasked with implementing a Python function that processes a list of strings representing command-line arguments and returns a dictionary containing the parsed arguments. Each argument is in the form of "--key=value" or "--key" (for boolean flags). If an argument does not follow this format, it should be conside... | codefeedback |
You are tasked with implementing a simplified version of a dependency resolver for a command handling system. The provided code snippet is a method that attempts to create a context resolver for a given command parameter. The resolver is responsible for obtaining the value of the parameter from the command handler's de... | codefeedback |
You are tasked with implementing a custom Zuul filter in a Java application. Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more. Your task is to create a custom filter that logs information about incoming requests using the Feign client.
You are provided with a partial ... | codefeedback |
You are tasked with implementing a simplified version of a function call mechanism in Python. The provided code snippet is a part of a class method that is intended to handle function calls. The method `call` takes in the following parameters:
- `ret_type`: A string representing the expected return type of the function... | codefeedback |
You are tasked with implementing a Python class that constructs a head for a Fully Convolutional One-Stage Object Detection model. The head consists of layers for class prediction, bounding box regression, and object count prediction. Your task is to complete the implementation of the `FCOSClsRegCntHead` class by filli... | codefeedback |
You are tasked with implementing a custom debugging feature for a compiler in Rust. The given code snippet is a part of a Rust program that defines a trait and its implementation for debugging purposes. The `write!` macro is used to format and write the compiler's identifier to a formatter.
Your task is to complete th... | codefeedback |
You are tasked with creating a Java method that processes web archive entries and performs various validations on the data. The web archive entry is represented by the `ArcEntry` class, which contains information such as the status code, binary image data, URL, crawl date, and wayback date. Your task is to implement a ... | codefeedback |
You are working for a data analysis company that specializes in statistical modeling and visualization. Your task is to create a program that generates and visualizes a dataset using Python's libraries for statistical analysis and visualization. Specifically, you need to create a program that generates a dataset, fits ... | codefeedback |
You are tasked with creating a Python class that handles downloading a pretrained model from a given Google Drive link. Your class should be able to download the model file and save it to a specified location on the local file system. Additionally, the class should provide a method to check if the downloaded file exist... | codefeedback |
You are tasked with implementing a function to calculate the multiplicative inverse of a given element in a Galois field. A Galois field, denoted as GF(ORDER), is a finite field with ORDER elements, where ORDER is equal to CHARACTERISTIC raised to the power of DEGREE. The multiplicative inverse of an element a in a Gal... | codefeedback |
You are tasked with creating a Swift function that processes an array of activity items and an optional array of application activities to generate a UIActivityViewController. The UIActivityViewController is a standard view controller for presenting the user with a list of services and actions offered by the operating ... | codefeedback |
You are tasked with implementing a role-based access control system using TypeScript. The system should allow users to retrieve role information by name from a Cosmos DB metadata repository. You are provided with a code snippet that initializes the metadata repository and includes a method to retrieve role information ... | codefeedback |
You are tasked with implementing a Python function that processes a given SQL script and modifies it according to a set of rules. The function should take a string representing the SQL script as input and return the modified SQL script as output.
The rules for modifying the SQL script are as follows:
1. Remove any com... | codefeedback |
You are tasked with implementing a simple document management system in Rust. The system should consist of two modules: `iota_document` and `iota_document_metadata`. The `iota_document` module will handle the actual content of the documents, while the `iota_document_metadata` module will handle the metadata associated ... | codefeedback |
You are tasked with implementing a class hierarchy for managing Pokémon evolutions. Your goal is to create a set of classes that represent different Pokémon and their evolutions. Each Pokémon can have multiple evolutions, and you need to design a system to manage and add new evolutions for each Pokémon.
You are provid... | codefeedback |
You are tasked with creating a migration script for a database table named `LineItem`. The script should drop a foreign key constraint and an index from the `LineItem` table. The provided code snippet is a part of the migration script written in PHP using the Doctrine database abstraction layer.
Your task is to write ... | codefeedback |
You are tasked with creating a Python function that utilizes the PyPortfolioOpt library to calculate the covariance risk of a given portfolio. The PyPortfolioOpt library provides various covariance risk models, and your function should allow users to select a specific risk model and then compute the covariance risk bas... | codefeedback |
You are given a text file containing a software license agreement. Your task is to write a program that reads the file and extracts the warranty information from the license agreement. The warranty information is located between the lines containing "WITHOUT WARRANTY OF ANY KIND" and "EXPRESS OR IMPLIED". You need to e... | codefeedback |
You are tasked with developing a program to evaluate the accuracy of imputed genetic data using a specific tool called AlphaPlantImpute2. The tool has various functionalities, including creating a library of haplotypes, imputing missing data, and decoding imputed data to assess accuracy.
Your task is to implement a fu... | codefeedback |
You are tasked with implementing a session management system for a web application. The system should generate unique session IDs, store session objects, and update the "tick" attribute of each session object with the current timestamp whenever a session is accessed or created. Additionally, the system should provide a... | codefeedback |
You are tasked with implementing a more efficient algorithm to find the maximum subarray sum within a given array of integers. The maximum subarray sum is the largest possible sum of a contiguous subarray within the input array.
You are given a function `maximum_subarray_naive(data)` that takes in an array of integers... | codefeedback |
You are tasked with creating a Python function to retrieve details from a JSON file based on a given face ID. The JSON file contains information about people, including their face IDs. Your function should open the "people.json" file, parse its contents, and then search for the person with the matching face ID. Once th... | codefeedback |
You are tasked with creating a shell script that takes a directory path as an argument and recursively counts the number of files and subdirectories within that directory. Your script should output the total count of files and subdirectories in the specified directory.
Your shell script should be named `count_files.sh... | codefeedback |
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 count the occurrences of each word, ignoring case and punctuation. Additionally, the program should calculate the average word length and the most common word in the text.
Wri... | codefeedback |
You are tasked with implementing a menu system for a graphical user interface (GUI) in a software application. The menu system consists of various components such as buttons, submenus, and scrollable menus. Your goal is to design a data structure and corresponding functions to manage the menu system efficiently.
You a... | codefeedback |
You are tasked with creating a command-line translation tool using Python. Your program should utilize the `argparse` module to handle command-line arguments and the `translate_process` function to perform the actual translation.
Your task is to complete the implementation of the `main_translate` function, which will ... | codefeedback |
You are tasked with implementing a Python class that represents a mathematical field and provides methods for calculating spatial coordinates and epsilon values. The class should have the following attributes and functionalities:
Attributes:
- `mfield`: Represents the mathematical field.
- `spatial_coordinates`: Repre... | codefeedback |
You are working on a Python project that involves testing a model importer module using the pytest framework. The code snippet provided includes a function call to `testing_function(model_name)`, a test function `test_error_on_importing_model()`, and a skip marker for a test case. Your task is to create a test case for... | codefeedback |
You are working for a data analytics company that specializes in analyzing electricity outage data. Your task is to create a program that uses Apache Spark to analyze outage data within a specific time range. The outage data is stored in a distributed file system and needs to be loaded into Spark for analysis. Addition... | codefeedback |
You are tasked with implementing a function to convert a given time in seconds into a human-readable format. The function should take an integer representing the time in seconds and return a string representing the time in years, days, hours, minutes, and seconds.
You need to implement the function `convert_time(_time... | codefeedback |
You are tasked with implementing a symmetric trapezoidal filter function in Python. The function takes an input waveform array, rise time, flat top time, and outputs the filtered waveform array. The trapezoidal filter is defined by the rise time and flat top time, and it is used to smooth out the input waveform.
The t... | codefeedback |
You are tasked with implementing a function that processes an array of items and organizes them into a hierarchical structure based on their codes. Each item has a unique code, and the codes are structured hierarchically, with a prefix indicating the parent-child relationship. The function should group the items based ... | codefeedback |
You are tasked with implementing a regression testing framework in Python. The framework should include a test runner, a storage mechanism for test results, a function to clear the test registry, and a way to access the registry entries.
Your task is to create the `RegressionTestRunner` class, the `RegressionTestStora... | codefeedback |
You are tasked with implementing a function `createList` that takes in a list of parameters and returns a new list based on the following rules:
1. If the parameter is a positive integer, add it to the new list.
2. If the parameter is a string, add its length to the new list.
3. If the parameter is a list, recursively ... | codefeedback |
You are tasked with implementing a neural network class in Python using the PyTorch library. Your goal is to create a class called `Net` that inherits from `nn.Module` and initializes a multi-layer perceptron (MLP) neural network. The provided code snippet gives you a starting point, and you need to complete the `Net` ... | codefeedback |
You are tasked with implementing a Python function that converts a nested data structure into a dictionary. The function should handle various data types such as numbers, lists, and custom objects.
You are given the following code snippet as a starting point:
```python
elif isinstance(node, numbers.Number):
retur... | codefeedback |
You are tasked with implementing a PHP class method that processes permissions and roles data for rendering in a web application. The method receives a permission ID and should retrieve the corresponding permission and associated roles from the database. The retrieved data is then passed to a view for rendering.
Your ... | codefeedback |
You are tasked with implementing a C++ class that represents a 3D object within a graphics application. The class, named `Sponza`, will be a part of the Flint graphics engine and will inherit from the `Object` class. Your goal is to complete the implementation of the `Sponza` class by adding specific member functions a... | codefeedback |
You are tasked with implementing a retry mechanism for a web scraping application. The provided code snippet contains a class method `update` that is responsible for refreshing the session and obtaining the current state of a website. The `update` method uses a `get_retry` method to handle retries in case of a failed r... | codefeedback |
You are working on a deployment script for a cloud-based application. The script needs to verify the presence of a specific environment variable before proceeding with the deployment process. If the variable is present and has a non-empty value, the script should exit with a success status code (0); otherwise, it shoul... | codefeedback |
You are tasked with creating a script to automate the build process for a software library called libjpeg-turbo. The build process involves using CMake to configure the build, compiling the source code, optimizing the library for SIMD (Single Instruction, Multiple Data) processing, and finally, moving the built library... | codefeedback |
You are tasked with creating a function to calculate the impact score of opponents in a game scenario. The impact score is determined based on the size and position of both the player and the opponents. The function `compute_opponent_impact` takes in four parameters: `our_size`, `opponent_size`, `our_position`, and `op... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.