Skip to content

Core Functions

Rose Heart edited this page Feb 22, 2026 · 2 revisions

Introcuction

Imagine you have a helpful assistant that quietly takes care of many small but important tasks behind the scenes whenever you work with text or your computer system. This library is like that assistant, designed to make everyday digital chores simpler and more reliable without requiring any special technical knowledge. It handles the kind of routine work that often gets overlooked but can cause headaches if done poorly, like making sure text looks clean and consistent no matter where it comes from. Whether you're dealing with messy documents, preparing information for reports, or just trying to keep your computer running smoothly, this tool works in the background to save you time and frustration.

One of its main jobs is to tidy up text in ways that feel almost magical. Picture copying a paragraph from a website only to find strange quotation marks, unexpected symbols, or inconsistent spacing that makes the words hard to read. This library gently transforms all that into neat, uniform text that looks the way you'd expect-replacing odd characters with familiar ones, removing distracting punctuation, and breaking things down into clear words. It's like having an invisible editor that polishes your content without changing its meaning, so you can focus on what the words say rather than how they appear.

Beyond text, the library also helps your computer manage its workload wisely, especially when it's busy with many tasks at once. Think of it as a thoughtful coordinator that notices when your system is under pressure and automatically adjusts how it handles requests-slowing down slightly during peak times to avoid overwhelming things, then speeding back up when there's more room to breathe. This keeps everything running steadily whether you're working on a simple project or something more demanding, all without you needing to lift a finger or understand how it's done.

At its heart, this library is about removing small obstacles that slow people down. It doesn't require you to learn complex commands or wrestle with technical details; it simply works quietly to handle the fiddly parts of digital work. By taking care of text cleanup, system balancing, and other everyday essentials, it lets you move forward with your real tasks-writing, analyzing, creating-without getting stuck on the background noise of computing. It's the kind of practical help that makes technology feel more like a seamless partner than a puzzle to solve.


Functions

def DecodeHashCodes(input_string):

The DecodeHashCodes function serves as a helpful translator for text that contains special numeric codes. Imagine you receive a message where certain letters or symbols appear as mysterious sequences like ampersand hash sixty five semicolon. These codes are actually digital placeholders used in web content and documents to represent characters safely. The function quietly examines any text you provide and automatically converts these numeric sequences back into their intended visible characters. This makes the text readable again without requiring manual intervention or technical expertise from the user.

When processing your input, the function carefully identifies each numeric code pattern within the text. It recognizes these patterns by their distinctive structure starting with an ampersand followed by a hash mark, then a series of numbers, and ending with a semicolon. For each identified pattern, it calculates what actual character the numbers represent using standard digital encoding rules. If the numbers correspond to a valid character like a letter or symbol, it seamlessly substitutes the code with that character. Should it encounter an invalid or problematic code, it thoughtfully leaves the original sequence intact rather than causing errors or unexpected results.

This capability proves particularly valuable when handling text extracted from websites or digital documents where special characters often appear in encoded form. By transforming these numeric references into regular readable characters, the function ensures your text displays correctly across different applications and devices. It operates unobtrusively in the background, requiring no special instructions or configuration from you while reliably producing clean, human-friendly text ready for everyday use. The entire process happens instantly and smoothly, turning what might look like computer gibberish into clear, understandable language.


def DecodeUnicode(text):

The DecodeUnicode function serves as a helpful tool for making text more universally compatible across different computer systems. It takes any given piece of writing and quietly transforms certain special characters into simpler, more common alternatives that work reliably almost everywhere. Think of it as a translator that converts fancy or unusual punctuation marks into their straightforward cousins that every device and program recognizes without trouble. This ensures your words stay clear and readable whether they're being processed by an old system, shared online, or prepared for printing.

Many documents contain decorative characters like curly quotation marks, elegant long dashes, or special spacing symbols that look polished in professional typesetting. While these elements enhance visual appeal in printed materials, they often cause unexpected hiccups when text moves between digital platforms. A curly quote might turn into a strange symbol on someone else's screen, or a special dash could disrupt data processing. The function gently smooths out these inconsistencies by swapping such characters for their basic keyboard equivalents, preventing those little frustrations that make text appear broken or behave unpredictably.

This process happens quietly behind the scenes without altering the actual meaning of your words. The function carefully scans through your text, noticing specific special characters like the curved single quotes used in publishing or the three-dot ellipsis symbol. Each time it finds one of these, it substitutes a plain straight quote, a regular hyphen, or three simple periods instead. It handles dozens of these subtle conversions automatically, working through the entire passage to replace every instance while leaving ordinary letters and numbers completely untouched. The result is clean, dependable text that maintains its integrity across emails, databases, and everyday software.

Using this function means your writing travels smoothly from one context to another without losing its message. It's particularly valuable when handling text from diverse sources like copied web content, scanned documents, or international files where character sets might clash. By converting those specialized symbols into universal standards, it removes hidden obstacles that could otherwise cause errors in search functions, data analysis, or simple readability. This quiet cleanup step ultimately helps your words communicate effectively no matter where they end up, saving time and headaches while keeping communication clear and consistent.


def Yesterday(ds=None):

The Yesterday function serves as a simple tool for determining the date that comes immediately before a specified day. Its primary purpose is to help users quickly identify what the calendar showed on the previous day without requiring manual calculations. This can be particularly useful in situations where tracking time-sensitive information is important, such as reviewing daily records, analyzing trends over consecutive days, or preparing reports that reference recent dates. The function operates quietly in the background, handling the complexities of date arithmetic so that users receive a clear and consistent result.

When no specific date is provided to the function, it automatically uses the current day as its starting point. It intelligently checks the system's clock to understand today's date and then steps back exactly one full day to determine yesterday's date. This makes it effortless to obtain yesterday's date at any moment, whether you're working on a report first thing in the morning or late at night. The function ensures the result always appears in a standardized year-month-day format, making it easy to read and incorporate into other documents or systems without further adjustment.

If you do provide a particular date to the function, it treats that date as the reference point for its calculation. For instance, if you supply a date from last week, the function will determine what the date was the day before that specific reference. It expects the provided date to follow a clear year-month-day structure, allowing it to accurately process the information and compute the preceding day. This flexibility means the function can help with historical date calculations just as easily as it handles the immediate past, making it a versatile helper for any task that involves moving backward through calendar dates.


def GetLoadAVG():

The GetLoadAVG function serves as a simple yet vital tool for understanding how busy a computer system currently is. Imagine it as a digital pulse check for your machine, quietly peeking at a special file that the operating system maintains to track overall activity levels. This function doesn't require any input from the user and works automatically by accessing a standard location where Linux-based systems record workload statistics. When called, it retrieves a snapshot of the system's recent performance burden, presenting it in an easy-to-use format that other programs can interpret. It's designed to be lightweight and efficient, completing its task almost instantly without adding noticeable strain to the system it's monitoring.

At its core, this function reveals what system administrators often call the "load average" - a numerical representation of how much work the computer has been handling over specific time intervals. Think of it like measuring how many people are actively using a shared kitchen: a low number means plenty of room to maneuver, while a high number suggests everyone might be bumping into each other. The function provides three related numbers showing this workload over the past one minute, five minutes, and fifteen minutes. These figures help determine whether the system is resting comfortably, working steadily, or feeling overwhelmed by too many simultaneous tasks. For everyday users, this information remains mostly invisible, but it becomes crucial when building applications that need to adapt to current system conditions.

This capability proves especially valuable in programs that manage resources intelligently. Software using GetLoadAVG can make thoughtful decisions, like pausing non-urgent tasks when the computer is busy or speeding up operations when resources are plentiful. It's the kind of behind-the-scenes helper that prevents your device from slowing to a crawl when multiple applications compete for attention. By providing this real-time insight into system demands, the function supports smoother overall performance without requiring manual intervention. It represents one of those unassuming but essential building blocks that help modern software coexist harmoniously with the physical hardware it runs on, ensuring your digital experience remains responsive and reliable throughout the day.


def renice(n):

The renice function serves as a gentle regulator for how much attention a computer program demands from the system's resources. Imagine a busy household where multiple people need to use shared appliances like the microwave or washing machine. This function allows a program to voluntarily adjust its own behavior, becoming either more patient or more assertive about when it gets to use the computer's processing power. By setting a specific value, the program communicates whether it should wait quietly in line behind other tasks or move toward the front when resources become available. This subtle adjustment happens without disrupting the program's main purpose, much like someone in that household might choose to wait their turn or politely request priority based on urgency.

This function operates quietly in the background, focusing solely on the program that calls it. It doesn't interfere with other applications or require special permissions beyond what the program already has. When activated, it sends a simple request to the computer's core management system, asking to shift its position in the resource queue. A higher number makes the program more yielding, like stepping back to let others go first during a busy moment. A lower number makes it slightly more insistent, similar to mentioning you're in a hurry when waiting in line. The beauty lies in its simplicity-it's a single adjustment that helps balance the program's needs with the overall health of the computer environment.

What makes this function particularly thoughtful is how gracefully it handles limitations. If the computer refuses the request perhaps because the program lacks sufficient privileges it simply moves on without fuss. There are no error messages to confuse users or cause the program to stall. This silent resilience ensures that whether the adjustment succeeds or not, the program continues its work uninterrupted. It's designed to be a cooperative tool that respects the computer's rules while helping the program adapt its behavior. In essence, renice acts like a quiet diplomat within the digital ecosystem, fostering harmony between competing tasks through modest, voluntary adjustments to its own demands.


def ElasticSleep(s,Fuzzy=True):

The ElasticSleep function offers a thoughtful way to pause a program's activity while being mindful of the computer's current workload. Instead of rigidly waiting for a fixed amount of time, it intelligently adjusts the pause duration based on how busy the system happens to be at that moment. This approach helps prevent the program from adding unnecessary strain when the computer is already handling many tasks, allowing other important processes to run smoothly. It's like a considerate guest who adjusts their behavior based on how crowded a room is, stepping back when things get hectic to avoid causing congestion.

When operating in its default mode, the function first checks the computer's overall busyness by examining how many tasks are queued up for the processor compared to the available processing power. If the system appears overwhelmed, it gently reduces the program's priority so that more urgent activities can take precedence. The pause time then extends beyond the requested duration, with the extension growing proportionally to the severity of the overload. This extra breathing room gives the computer space to catch up with its existing responsibilities. Even during moderate activity levels, the function adds a small, proportional adjustment to the pause, ensuring the program remains a cooperative participant in the system's ecosystem.

The function also includes a subtle but important gesture of cooperation by momentarily yielding control to the operating system right after adjusting priorities. This allows immediate attention to other waiting tasks before the pause even begins, much like holding a door open for others before stepping through yourself. The entire mechanism works quietly in the background, dynamically calculating the appropriate pause length without requiring constant supervision. This adaptability makes it particularly valuable for background processes that should avoid interfering with the user's primary activities or other critical system functions.

For situations where precise timing is essential, the function can switch to a straightforward mode that ignores system conditions entirely. By disabling the adaptive behavior, it simply waits for the exact duration specified, behaving like a traditional pause command. While this might be necessary for certain time-sensitive operations, it lacks the awareness that makes the default approach so effective in shared computing environments. The adaptive mode shines brightest in scenarios where multiple processes compete for resources, such as servers handling many users or desktop systems running several applications simultaneously.

This thoughtful design reflects an understanding that programs should respond to their environment rather than blindly follow fixed schedules. By dynamically adjusting its behavior based on real-time system conditions, ElasticSleep helps maintain overall system responsiveness and prevents background tasks from inadvertently making the computer feel sluggish. It represents a small but meaningful step toward more cooperative software that respects the shared nature of computing resources, ultimately contributing to a smoother experience for both the system and its users without demanding special attention or configuration.


def ElasticDelay():

The ElasticDelay function serves as a smart timing mechanism that automatically adjusts how long a program should pause based on the current workload of the computer. Instead of using a fixed waiting period, it dynamically calculates this pause by examining the system's overall busyness. This approach helps prevent the computer from becoming overwhelmed when it's already handling many tasks, while allowing operations to proceed more quickly during quieter moments. The function essentially acts like a considerate neighbor who times their activities to avoid adding stress to an already busy household.

At its core, ElasticDelay checks how much work the computer is currently managing by looking at the system's load average. This metric represents the average number of processes competing for processing power over recent minutes. The function then compares this value to the number of available processing units in the machine. When the workload exceeds what the computer can comfortably handle, the function increases the waiting period proportionally. This intelligent adjustment ensures that resource-intensive operations don't pile up during peak usage times, giving the system breathing room to catch up with existing tasks.

The calculated delay transforms abstract system metrics into practical waiting times measured in milliseconds. During periods of normal activity, the pause remains minimal, allowing programs to operate efficiently without unnecessary interruptions. However, when the computer shows signs of strain-such as when too many applications are running simultaneously-the delay grows longer to prevent further congestion. This self-regulating behavior makes the function particularly valuable for background processes that need to run reliably without disrupting the user's primary activities or other critical system functions.

By implementing this adaptive timing strategy, ElasticDelay contributes to smoother overall system performance and stability. It helps maintain a balanced computing environment where different tasks can coexist without causing slowdowns or crashes. This thoughtful approach to resource management reflects an understanding that computers function best when their workload is carefully monitored and adjusted in real-time, rather than following rigid schedules that ignore current conditions. The result is a more responsive and resilient computing experience that automatically accommodates varying demands throughout the day.


def NumberOnly(s):

The NumberOnly function serves as a practical tool for determining whether a given piece of text represents a valid numerical value. Its primary role is to examine any string input and decide if it can reasonably be interpreted as a number, accommodating various real-world formatting quirks people might use. This is especially helpful in situations where users might enter data in slightly inconsistent ways, such as including extra spaces, using different symbols that resemble numbers, or mixing in certain punctuation marks commonly found in numerical expressions. The function aims to be flexible while still maintaining reasonable standards for what constitutes an acceptable number representation.

When processing text, the function first addresses common visual substitutions where letters might be mistaken for digits. For instance, it recognizes that someone might accidentally type a capital O instead of zero or use a lowercase L in place of the number one. It quietly corrects these look-alike characters to their proper numerical equivalents before proceeding. The function then tidies up the input by removing any leading or trailing spaces and eliminating regular spaces within the text, ensuring the focus remains solely on the essential characters. It carefully checks every remaining symbol against an extensive collection of valid numerical components, including standard digits, decimal points, commas used as thousand separators, and even special digit forms from other writing systems that might appear in international contexts.

The function ultimately verifies whether the cleaned text meets basic numerical criteria by confirming it contains actual digits after setting aside commas and decimal points. It ensures the input isn't just punctuation like multiple commas or periods without any real numbers present. This approach allows it to accept properly formatted whole numbers, decimals, and comma-separated values while rejecting text containing letters, unusual symbols, or nonsensical combinations. The result is a straightforward yes-or-no determination that helps applications handle user input more gracefully, reducing errors when processing numerical data from diverse sources without requiring perfect formatting from users.


def StripPunctuation(text):

The StripPunctuation function serves as a text cleanup tool that prepares written content for smoother processing. Imagine you have a block of text filled with various symbols like commas, exclamation points, question marks, or even less common special characters. This function gently removes all those distracting marks by replacing them with simple spaces. Instead of deleting the punctuation entirely, it leaves behind a space where each symbol used to be, which helps maintain the natural flow of words without awkward gaps or merged terms. This approach ensures that sentences transform into clean sequences of words separated only by spaces, making the text more uniform and predictable for whatever comes next in the processing pipeline.

When you feed text into this function, it carefully examines every character to identify anything that isn't a standard letter or number. This includes not just obvious punctuation like periods and hyphens but also symbols from extended character sets that might appear in documents using non-English languages or special formatting. Each of these identified characters gets swapped out for a space, so a phrase like "Wait-did you see that?!" would become "Wait did you see that ". The result feels like someone carefully erased all the tiny marks between words while keeping the words themselves intact and properly spaced. This is particularly helpful when preparing text for tasks where symbols might interfere, such as counting words or analyzing language patterns.

The real value of this function shines when working with messy real-world text that comes from emails, social media, or scanned documents. These sources often contain inconsistent symbols, decorative marks, or foreign language characters that could confuse simpler processing tools. By converting all these elements into neutral spaces, StripPunctuation creates a level playing field where only the core words remain visible. It's like giving the text a gentle bath that washes away the clutter without altering the essential meaning. The output becomes reliably tidy, ready for further steps like breaking the text into individual words or feeding it into systems that expect clean, symbol-free language. This quiet cleanup work happens quickly and efficiently, making it an unobtrusive but essential helper in any text-handling workflow.


def jsonFilter(s,FilterSpace=True):

The jsonFilter function serves as a helpful tool for preparing text to work smoothly with structured data formats like JSON. It takes any piece of text and cleans it up by removing certain characters that might cause problems later. Think of it as a careful editor that tidies up messy writing before it gets used in important documents. By default, it focuses on eliminating invisible characters that often sneak into text from different sources, ensuring the final result stays neat and consistent.

When you use this function, it automatically strips away line breaks, tabs, and other hidden formatting marks that can disrupt how information flows in digital systems. If you want it to also remove regular spaces between words, you can keep the default setting active. But if spaces are important for your needs, you can adjust the setting to preserve them while still clearing out the problematic characters. This flexibility makes it useful for different situations where text might come from emails, web pages, or user inputs that contain unexpected formatting.

This cleanup process matters because structured data formats like JSON have strict rules about how information should appear. Extra spaces or invisible characters might make the data unreadable or cause errors when programs try to process it. By using jsonFilter, you create cleaner, more reliable text that fits seamlessly into these systems. It quietly handles the messy details so you can focus on the actual content without worrying about hidden formatting issues that might otherwise cause headaches down the line.


def GetWordList(text):

The GetWordList function transforms any block of written content into a clean collection of individual words ready for straightforward analysis. Imagine you have a paragraph from a book, a social media post, or even a messy document filled with extra spaces and mixed capitalization. This tool takes that jumble of text and gently prepares it by making everything lowercase so that "Hello" and "hello" are treated as the same word. It then carefully separates the text into distinct words by recognizing natural breaks where spaces occur, ensuring that punctuation attached to words doesn't interfere with the separation process.

This function works quietly behind the scenes to handle common imperfections in everyday writing. It automatically skips over any empty spaces that might accidentally create blank entries, such as when there are multiple spaces between words or spaces at the very beginning or end of the text. By focusing only on meaningful word fragments, it prevents the output from containing useless empty slots that could complicate further processing. The result is a tidy sequence where each entry represents an actual word from the original material, all uniformly presented in lowercase letters without any distracting extras.

The final output becomes a dependable foundation for many practical applications where understanding word patterns matters. Whether someone is counting how often certain terms appear, studying language habits, or building simple tools that respond to specific vocabulary, having words in this standardized format makes the next steps much smoother. It quietly handles the groundwork of text preparation so that other processes can focus on meaningful interpretation without getting tripped up by inconsistent capitalization or stray spaces. This makes it a helpful starting point for anyone working with written language in a digital context.


def IsSTDIN():

The IsSTDIN function serves as a simple yet practical tool for determining whether a program has immediate input waiting to be processed from the user or another source. Imagine you're building a program that might receive data either through direct typing at the keyboard or by having information piped in from another process. This function helps the program decide how to proceed without getting stuck waiting indefinitely for input that might never arrive. It acts like a quick check to see if someone is actively trying to send data right now, similar to glancing at your door to see if a visitor is standing there before deciding whether to keep waiting or move on to other tasks.

At its core, this function operates by listening for just one second to see if any input is actively being sent to the program. It doesn't actually read or consume the input-instead, it politely checks if something is available to read during that brief window. If data appears within that second, the function signals that input is ready and waiting. If nothing arrives in that time, it quietly reports that no input is currently present. This approach prevents the program from freezing in situations where it might otherwise wait forever for user interaction, allowing it to handle both interactive and automated scenarios gracefully without unnecessary delays.

This capability proves especially valuable in flexible command-line tools that need to adapt to different usage patterns. For instance, when someone types a command directly and expects to type more, the program can pause appropriately for their input. Conversely, when the command is part of an automated script sending data through pipes, the program can immediately process the incoming information without hesitation. By making this distinction seamlessly, IsSTDIN helps create more responsive and user-friendly applications that work well whether they're being used interactively by a person or integrated into larger automated workflows where timing matters.

Clone this wiki locally