diff --git a/tests/recipes/wrangles/test_extract.py b/tests/recipes/wrangles/test_extract.py index 9b0d4ea8..cfd46a9a 100644 --- a/tests/recipes/wrangles/test_extract.py +++ b/tests/recipes/wrangles/test_extract.py @@ -1058,7 +1058,10 @@ def test_extract_codes_wrong_params_sort(self): ) assert ( info.typename == 'ValueError' and - 'ERROR IN WRANGLE extract.codes - at line 3 - Status Code: 400 - Bad Request. {"message": "Invalid parameter sort_order. Expected longest or shortest."} \n' in info.value.args[0] + ( + 'ERROR IN WRANGLE extract.codes - at line 3 - Status Code: 400 - Bad Request. {"message": "Invalid parameter sort_order. Expected input, longest, or shortest."} \n' in info.value.args[0] + or 'ERROR IN WRANGLE extract.codes - at line 3 - Status Code: 400 - Bad Request. {"message": "Invalid parameter sort_order. Expected longest or shortest."} \n' in info.value.args[0] + ) ) diff --git a/wrangles/extract.py b/wrangles/extract.py index bfe559c4..1f5c2717 100644 --- a/wrangles/extract.py +++ b/wrangles/extract.py @@ -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: How aggressive to be at removing false positives such as + measurements. One of 'lenient', 'balanced' or 'strict'. Default is + 'balanced'. Default minimum lengths are 3 for lenient, 4 for balanced, + and 5 for strict unless min_length is provided. + :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] diff --git a/wrangles/recipe_wrangles/extract.py b/wrangles/recipe_wrangles/extract.py index 60f63c92..62b2712f 100644 --- a/wrangles/recipe_wrangles/extract.py +++ b/wrangles/recipe_wrangles/extract.py @@ -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: How aggressive to be at removing false positives such as measurements. Default is balanced. Default minimum lengths are 3 for lenient, 4 for balanced, and 5 for strict unless min_length is provided. enum: - lenient - balanced @@ -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