Model: lemon-mint/gte-modernbert-base-code-3
Author: lemon-mint
Pipeline: sentence-similarity
Library: sentence-transformers
Tags: sentence-transformers, safetensors, modernbert, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:78926, loss:MultipleNegativesRankingLoss, en, dataset:lemon-mint/Magpie-Qwen2.5-Coder-Pro-300K-Query-Positive-Pair, arxiv:1908.10084, arxiv:1705.00652, base_model:Alibaba-NLP/gte-modernbert-base, base_model:finetune:Alibaba-NLP/gte-modernbert-base, license:apache-2.0, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: Alibaba-NLP/gte-modernbert-base
Card metadata: language: en
license: apache-2.0
tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:78926, loss:MultipleNegativesRankingLoss
base_model: Alibaba-NLP/gte-modernbert-base
widget: source_sentence: Can you provide a Python function that converts a given word to Pig Latin?
sentences: # Retrieve the current date and time
$currentDateTime = Get-Date

# Retrieve the timezone information
$timezoneInfo = Get-TimeZone

# Display the current date and time
Write-Output "Current Date and Time: $currentDateTime"

# Display the timezone information
Write-Output "Timezone: $($timezoneInfo.Id) - $($timezoneInfo.DisplayName)"
, import pandas as pd

# Sample data
data = {
    'date': ['2023-01-01', '2023-01-01', '2023-01-02', '2023-01-02', '2023-01-03', '2023-01-03'],
    'store_name': ['Store A', 'Store B', 'Store A', 'Store B', 'Store A', 'Store B'],
    'value': [100, 150, 200, 250, 300, 350],
    'target': [1, 0, 1, 1, 0, 1]
}

# Create DataFrame
df = pd.DataFrame(data)

# Convert 'date' column to datetime
df['date'] = pd.to_datetime(df['date'])

# Define the specific period
start_date = '2023-01-01'
end_date = '2023-01-03'

# Filter the data for the specific period
filtered_df = df[(df['date'] >= start_date) & (df['date'] <= end_date)]

# Calculate success rate for each store
success_rate = filtered_df.groupby('store_name').agg(
    total_transactions=pd.NamedAgg(column='target', aggfunc='size'),
    successful_transactions=pd.NamedAgg(column='target', aggfunc='sum')
).reset_index()

success_rate['success_rate'] = success_rate['successful_transactions'] / success_rate['total_transactions']

# Calculate total transaction amount for each store
total_amount = filtered_df.groupby('store_name')['value'].sum().reset_index()
total_amount.columns = ['store_name', 'total_transaction_amount']

# Merge the success rate and total transaction amount data
result = pd.merge(success_rate, total_amount, on='store_name')

# Sort by success rate and total transaction amount
result = result.sort_values(by=['success_rate', 'total_transaction_amount'], ascending=[False, False])

# Display the result
print(result)
, def convert_to_pig_latin(word):
    # Check if the word is empty
    if not word:
        return word
    
    # Define vowels
    vowels = "aeiouAEIOU"
    
    # Check if the first letter is a vowel
    if word[0] in vowels:
        return word + "way"
    else:
        # Find the position of the first vowel
        for i, letter in enumerate(word):
            if letter in vowels:
                # Move the initial consonant cluster to the end and add "ay"
                return word[i:] + word[:i] + "ay"
        
        # If no vowels are found, just add "ay" at the end
        return word + "ay"

# Example usage:
print(convert_to_pig_latin("hello"))  # Output: ellohay
print(convert_to_pig_latin("apple"))  # Output: appleway
print(convert_to_pig_latin("rhythm")) # Output: rhythmay
, source_sentence: I want to create a function in Python that takes in any two numbers and returns their sum. Can you provide a simple example of how to do this?
sentences: def min_operations_to_target(words, target):
    # Initialize the number of operations to 0
    total_operations = 0
    
    # Iterate over each word in the array
    for word in words:
        # Ensure the word and target are of the same length
        if len(word) != len(target):
            raise ValueError("All words must be of the same length as the target.")
        
        # Calculate the number of operations needed to convert the current word to the target
        operations = sum(1 for w_char, t_char in zip(word, target) if w_char != t_char)
        
        # Add the operations needed for this word to the total operations
        total_operations += operations
    
    # Return the total number of operations needed
    return total_operations

# Example usage:
words = ["abc", "bcd", "cde"]
target = "acd"
print(min_operations_to_target(words, target))  # Output: 3
, import re

def remove_invisible_characters(input_string):
    # Define a regular expression pattern to match invisible characters
    # This includes spaces, tabs, newlines, and other control characters
    pattern = r'[\x00-\x1F\x7F-\x9F]'
    
    # Use re.sub() to replace all matches with an empty string
    cleaned_string = re.sub(pattern, '', input_string)
    
    return cleaned_string

# Example usage
original_string = "Hello\tWorld\nThis is a test\x00string with\xA0invisible characters."
cleaned_string = remove_invisible_characters(original_string)
print("Original String:", repr(original_string))
print("Cleaned String:", repr(cleaned_string))
, def add_numbers(num1, num2):
    """Return the sum of two numbers."""
    return num1 + num2

# Example usage:
result = add_numbers(3, 5)
print("The sum is:", result)
, source_sentence: Could you provide a Python script that converts a given word to Pig Latin? The script should take a word as input and return the Pig Latin version of that word. The rules for converting to Pig Latin are as follows:
sentences: def min_steps_to_palindrome(s: str) -> int:
    # Helper function to compute the LPS array
    def compute_lps(pattern: str) -> list:
        lps = [0] * len(pattern)
        length = 0
        i = 1
        while i < len(pattern):
            if pattern[i] == pattern[length]:
                length += 1
                lps[i] = length
                i += 1
            else:
                if length != 0:
                    length = lps[length - 1]
                else:
                    lps[i] = 0
                    i += 1
        return lps

    # Create the new string by concatenating s, a special character, and the reverse of s
    special_char = '#'
    new_string = s + special_char + s[::-1]
    
    # Compute the LPS array for the new string
    lps = compute_lps(new_string)
    
    # The length of the longest palindromic prefix
    longest_palindromic_prefix_length = lps[-1]
    
    # The minimum number of characters to add
    return len(s) - longest_palindromic_prefix_length

# Example usage:
s = "abc"
print(min_steps_to_palindrome(s))  # Output: 2
, def max_crossing_sum(arr, left, mid, right):
    # Include elements on the left of mid.
    left_sum = float('-inf')
    sum = 0
    for i in range(mid, left - 1, -1):
        sum += arr[i]
        if sum > left_sum:
            left_sum = sum

    # Include elements on the right of mid.
    right_sum = float('-inf')
    sum = 0
    for i in range(mid + 1, right + 1):
        sum += arr[i]
        if sum > right_sum:
            right_sum = sum

    # Return sum of elements on the left and right of mid.
    return left_sum + right_sum

def max_subarray_sum(arr, left, right):
    # Base case: only one element
    if left == right:
        return arr[left]

    # Find middle point
    mid = (left + right) // 2

    # Return maximum of following three possible cases:
    # a) Maximum subarray sum in left half
    # b) Maximum subarray sum in right half
    # c) Maximum subarray sum such that the subarray crosses the midpoint
    return max(max_subarray_sum(arr, left, mid),
               max_subarray_sum(arr, mid + 1, right),
               max_crossing_sum(arr, left, mid, right))

# Example usage:
arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
result = max_subarray_sum(arr, 0, len(arr) - 1)
print("Maximum subarray sum is", result)
, def convert_to_pig_latin(word):
    vowels = "aeiouAEIOU"
    
    # Check if the first letter is a vowel
    if word[0] in vowels:
        return word + "way"
    else:
        # Find the position of the first vowel
        for i, letter in enumerate(word):
            if letter in vowels:
                # Move the consonant cluster to the end and add "ay"
                return word[i:] + word[:i] + "ay"
        # If no vowels are found (which is rare in English), return the word as is with "ay"
        return word + "ay"

# Example usage
word = input("Enter a word to convert to Pig Latin: ")
pig_latin_word = convert_to_pig_latin(word)
print(f"The Pig Latin version of '{word}' is '{pig_latin_word}'")
, source_sentence: Write a Python function that calculates the total cost of a list of items, where each item is represented as a dictionary with keys 'name', 'quantity', and 'price_per_unit'. The function should return the total cost of all items.
sentences: import csv

# Specify the path to your CSV file
csv_file_path = 'example.csv'

# Open the CSV file
with open(csv_file_path, mode='r', newline='', encoding='utf-8') as file:
    # Create a CSV reader object
    csv_reader = csv.reader(file)
    
    # Iterate over each row in the CSV file
    for row in csv_reader:
        # Print the row
        print(row)
, Module DiceGame
    Sub Main()
        ' Create a random number generator
        Dim rng As New Random()

        ' Variable to store the user's choice
        Dim userInput As String

        ' Loop to allow the user to roll the dice multiple times
        Do
            ' Prompt the user to roll the dice
            Console.WriteLine("Press 'R' to roll the dice or 'Q' to quit:")

            ' Get the user's input
            userInput = Console.ReadLine().ToUpper()

            ' Check if the user wants to roll the dice
            If userInput = "R" Then
                ' Roll the dice (generate random numbers between 1 and 6)
                Dim die1 As Integer = rng.Next(1, 7)
                Dim die2 As Integer = rng.Next(1, 7)

                ' Display the result
                Console.WriteLine($"You rolled a {die1} and a {die2}. Total: {die1 + die2}")
            ElseIf userInput = "Q" Then
                ' Exit the loop if the user wants to quit
                Console.WriteLine("Thanks for playing!")
                Exit Do
            Else
                ' Handle invalid input
                Console.WriteLine("Invalid input. Please press 'R' to roll or 'Q' to quit.")
            End If
        Loop

        ' Wait for the user to press a key before closing the console
        Console.WriteLine("Press any key to exit...")
        Console.ReadKey()
    End Sub
End Module
, def calculate_total_cost(items):
    """
    Calculate the total cost of a list of items.

    Args:
    items (list of dict): A list where each dictionary represents an item with keys 'name', 'quantity', and 'price_per_unit'.

    Returns:
    float: The total cost of all items.
    """
    total_cost = 0.0
    for item in items:
        # Calculate the cost for the current item and add it to the total cost
        total_cost += item['quantity'] * item['price_per_unit']
    return total_cost

# Example usage
items = [
    {'name': 'apple', 'quantity': 10, 'price_per_unit': 0.5},
    {'name': 'banana', 'quantity': 5, 'price_per_unit': 0.3},
    {'name': 'orange', 'quantity': 8, 'price_per_unit': 0.7}
]
print(calculate_total_cost(items))  # Output: 12.1
, source_sentence: Design a simple Python script to backup a database using SQL commands and save it to a file. This script should use PostgreSQL as the database management system.
sentences: def length_of_longest_substring(s: str) -> int:
    char_index_map = {}
    left = 0
    max_length = 0

    for right in range(len(s)):
        if s[right] in char_index_map and char_index_map[s[right]] >= left:
            left = char_index_map[s[right]] + 1
        char_index_map[s[right]] = right
        max_length = max(max_length, right - left + 1)

    return max_length
, import subprocess
import os
from datetime import datetime

def backup_database(db_name, db_user, db_host, db_port, backup_dir):
    # Ensure the backup directory exists
    if not os.path.exists(backup_dir):
        os.makedirs(backup_dir)

    # Create a timestamp for the backup file
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    backup_file = os.path.join(backup_dir, f"{db_name}_backup_{timestamp}.sql")

    # Construct the pg_dump command
    command = [
        "pg_dump",
        "-U", db_user,
        "-h", db_host,
        "-p", str(db_port),
        "-F", "c",  # Custom format, which is compressed
        "-b",       # Include large objects
        "-v",       # Verbose mode
        "-f", backup_file,
        db_name
    ]

    try:
        # Run the pg_dump command
        subprocess.run(command, check=True)
        print(f"Backup successful: {backup_file}")
    except subprocess.CalledProcessError as e:
        print(f"An error occurred while backing up the database: {e}")

if __name__ == "__main__":
    # Database connection details
    db_name = "your_database_name"
    db_user = "your_database_user"
    db_host = "localhost"  # or your database host
    db_port = 5432         # default PostgreSQL port
    backup_dir = "/path/to/your/backup/directory"

    # Call the backup function
    backup_database(db_name, db_user, db_host, db_port, backup_dir)
, def fibonacci_sequence(n):
    # Initialize the first two Fibonacci numbers
    fib_sequence = [0, 1]
    
    # Generate the Fibonacci sequence up to n
    while True:
        next_fib = fib_sequence[-1] + fib_sequence[-2]
        if next_fib > n:
            break
        fib_sequence.append(next_fib)
    
    # If n is less than 1, return the sequence up to n
    if n < 1:
        return fib_sequence[:n+1]
    
    return fib_sequence

# Example usage
n = int(input("Enter a number to generate the Fibonacci sequence up to: "))
sequence = fibonacci_sequence(n)
print(f"Fibonacci sequence up to {n}: {sequence}")

datasets: lemon-mint/Magpie-Qwen2.5-Coder-Pro-300K-Query-Positive-Pair
pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 0 | All-time downloads: 112
Created: 2025-01-27 10:11:40