get_webapp_dir
def get_webapp_dir():Get the webapp directory path
Get the data directory path, optionally with a subfolder. Creates the main data dir and any requested subfolder if they don’t exist.
Args: subfolder: Optional subfolder name to append to the data directory path
Returns: Path to the data directory or subfolder
Extracts noun phrases from text, including coordinated phrases like “generative AI and live fire testing”, and removes subphrases like “AI” if “generative AI” is also found. Example: text = “Natural language processing (NLP) is a field of computer science, artificial intelligence,” “and computational linguistics concerned with the interactions between computers and human” “(natural) languages.” extract_noun_phrases(text) [‘Natural language processing’, ‘NLP’, ‘field’, ‘computer science’, ‘artificial intelligence’, ‘computational linguistics’, ‘interactions’, ‘computers’, ‘languages’, ‘human’]
Returns True if sentence is contained in text ignoring whether tokens are delmited by spaces or newlines or tabs.
Removes a sentence or phrase from text ignoring whether tokens are delimited by spaces or newlines or tabs.
If remove_follow=True, then subsequent text until the first newline is also removed.
Segments text into a list of paragraphs or sentences depending on value of unit (one of {'paragraph', 'sentence'}. The maxchars parameter is the maximum size of any unit of text.
Filters a generator based on a given predicate function.
Args: generator: The generator to filter. criteria: List of functions that take an element from the generator and return True if the element should be included, False otherwise.
Yields: Elements from the original generator that satisfy the predicate.
Get template variables from a template string.
Format a string with kwargs
Safe string formatter that does not raise KeyError if key is missing. Adapted from llama_index.