Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions wrangles/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,20 @@ def codes(

e.g. 'Something ABC123ZZ something' -> 'ABC123ZZ'

:param input: A string or list of strings to search for codes.
:param first_element: Get the first element from results.
:param min_length: Minimum length of allowed results.
:param max_length: Maximum length of allowed results.
:param strategy: Controls filtering of likely false positives such as measurements.
'lenient' skips this filter, while 'balanced' and 'strict' currently apply
the same filter. Default is 'balanced'. Unless min_length is provided,
minimum lengths default to 3 for lenient, 4 for balanced, and 5 for strict.
:param sort_order: Default is input order. Also allows 'longest' or 'shortest'.
:param disallowed_patterns: A pattern or JSON array of regex patterns to not include in the found codes.
:param include_multi_part_tokens: Whether to include multi-part tokens that have a space. Default True.
:param extract_raw: Whether to return tokens with their adjacent non-whitespace characters
included, rather than the cleaned token. Default False.
:return: A list of codes found.
"""
if isinstance(input, str):
json_data = [input]
Expand Down
4 changes: 2 additions & 2 deletions wrangles/recipe_wrangles/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def codes(
description: Maximum length of allowed results
strategy:
type: string
description: How aggressive to be at removing false positives such as measurements.
description: Controls filtering of likely false positives such as measurements. Lenient skips this filter; balanced and strict currently apply the same filter. Default is balanced. Unless min_length is provided, minimum lengths default to 3 for lenient, 4 for balanced, and 5 for strict.
enum:
- lenient
- balanced
Expand All @@ -876,7 +876,7 @@ def codes(
description: Whether to include multi-part tokens that have a space. Default True.
extract_raw:
type: boolean
description: Whether to return tokens with their adjacent non-whitespace characters. Default False.
description: Whether to return tokens with their adjacent non-whitespace characters included, rather than the cleaned token. Default False.
"""
# If output is not specified, overwrite input columns in place
if output is None: output = input
Expand Down