Added docstring to apply function

This commit is contained in:
Patrick Elmer 2023-02-06 16:20:34 +09:00
parent 5956894770
commit 38e3661dc5

View File

@ -1,10 +1,32 @@
import re import re
def apply(changes, strings, categories={}, ignore_errors=True, apply=True, zero_characters=['']): def apply(
changes,
strings,
apply=True,
categories={},
ignore_errors=True,
zero_characters=['']):
""" """
Applies a sound change or a list of sound changes to a string or Applies a sound change or a list of sound changes to a string or
a list of given strings. a list of given strings.
Accepts inputs of type str or list.
If the input value is of type str, the output will also be of type str.
Options:
- apply (default: True)
Whether or not the changes should be applied.
- categories (default: {})
Which categories will be detected.
For vowels it would be {'V'='aeiou'} or {'V'=['a', 'e', 'i', 'o', 'u']})
- ignore_errors (default: True)
If this option is set to `True`, any erroneous sound change will be skipped.
If set to `False`, a ValueError will be raised.
- zero_characters (default: [''])
These characters will be removed in the changed words.
For example, `apply('h>∅', 'aha')` will return 'aa', not 'a∅a'.
""" """
if not apply: if not apply:
@ -20,7 +42,6 @@ def apply(changes, strings, categories={}, ignore_errors=True, apply=True, zero_
strings = strings.copy() strings = strings.copy()
for change in changes: for change in changes:
if validate_change(change, ignore_errors=ignore_errors) == False: if validate_change(change, ignore_errors=ignore_errors) == False:
continue continue