idaes_flowsheet_processor.util
Utility functions.
Module Contents
Classes
Map unique prefixes to words. |
- class idaes_flowsheet_processor.util.ShortPrefix(words, lowercase: bool = True)
Map unique prefixes to words.
Usage: >>> sp = ShortPrefix([“apple”, “banana”, “apricot”, “berry”]) >>> sp.match(“app”) # Returns “apple” >>> sp.match(“ap”) # Returns [] (ambiguous) >>> sp.match(“ban”) # Returns “banana” >>> sp.match(“b”) # Returns None (ambiguous) >>> sp.could_be(“ap”) # Returns [“apple”, “apricot”] >>> sp.could_be(“b”) # Returns [“banana”, “berry”] >>> sp.could_be(“c”) # Returns [] (no matches)
- match(s: str) str | None
Find the unique word for a given prefix string.
- Returns:
The unique word that matches the prefix, or None if no unique word, or any word, matches.
- Return type:
str or None