Repository: sdv-dev/RDT (language: python)

Issue:
Add utility functions to `AnonymizedFaker`
### Problem Description

In order to work directly with an `sdtype` (eg: 'job' as sdtype), it would be usefull to have the following two utility functions in `AnonymizedFaker`:
* `is_faker_function`: A function that returns `True` or `False` whether or not the provided `sdtype` is considered a `faker` function.
* `get_provider_name`: A function that returns the `provider_name` for the given `sdtype`.

With the following functions we would be able to support wider range of `sdtypes`.

### Expected behavior

```python
from rdt.transformers.pii.utilis import get_provider_name, is_faker_function

is_faker_function('job')
True

get_provider_name('job')
job

get_provider_name('lexify'):
BaseProvider
```

### Additional context

By adding this two features we will be able to remove `faker` dependency from https://github.com/sdv-dev/SDV



Discussion / hints:

Fix patch:
diff --git a/rdt/transformers/pii/utils.py b/rdt/transformers/pii/utils.py
new file mode 100644
index 000000000..855033c48
--- /dev/null
+++ b/rdt/transformers/pii/utils.py
@@ -0,0 +1,43 @@
+"""Utility functions for anonymization."""
+
+import inspect
+
+from faker import Faker
+
+
+def is_faker_function(function_name):
+    """Return whether or not the function name is a valid Faker function.
+
+    Args:
+        function_name (str):
+            String representing a ``faker`` function.
+
+    Returns:
+        True if the ``function_name`` is know to ``Faker``, otherwise False.
+    """
+    try:
+        getattr(Faker(), function_name)
+    except AttributeError:
+        return False
+
+    return True
+
+
+def get_provider_name(function_name):
+    """Return the ``faker`` provider name for a given ``function_name``.
+
+    Args:
+        function_name (str):
+            String representing a ``faker`` function.
+
+    Returns:
+        provider_name (str):
+            String representing the provider name of the faker function.
+    """
+    function_name = getattr(Faker(), function_name)
+    module = inspect.getmodule(function_name).__name__
+    module = module.split('.')
+    if len(module) == 2:
+        return 'BaseProvider'
+
+    return module[-1]


Test patch:
diff --git a/tests/unit/transformers/pii/test_utils.py b/tests/unit/transformers/pii/test_utils.py
new file mode 100644
index 000000000..3e98dfc86
--- /dev/null
+++ b/tests/unit/transformers/pii/test_utils.py
@@ -0,0 +1,34 @@
+from rdt.transformers.pii.utils import get_provider_name, is_faker_function
+
+
+def test_get_provider_name():
+    """Test the ``get_provider_name`` method.
+
+    Test that the function returns an expected provider name from the ``faker.Faker`` instance.
+    If this is from the ``BaseProvider`` it should also return that name.
+    """
+    # Run
+    email_provider = get_provider_name('email')
+    lexify_provider = get_provider_name('lexify')
+
+    # Assert
+    assert email_provider == 'internet'
+    assert lexify_provider == 'BaseProvider'
+
+
+def test_is_faker_function():
+    """Test that the method returns True if the ``function_name`` is a valid faker function."""
+    # Run
+    result = is_faker_function('address')
+
+    # Assert
+    assert result is True
+
+
+def test_is_faker_function_error():
+    """Test that the method returns False if ``function_name`` is not a valid faker function."""
+    # Run
+    result = is_faker_function('blah')
+
+    # Assert
+    assert result is False