# ＊ DomainBasedMapper

{% hint style="info" %}
**＊SDV Enterprise Feature.** This feature is available to our licensed users and is not currently in our public library. For more information, visit our page to [Explore SDV](https://docs.sdv.dev/sdv/explore/sdv-enterprise/compare-features).
{% endhint %}

The `DomainBasedMapper` creates and applies a consistent mapping between real emails and fake, synthetic emails. The mapping preserves the domain of the email. That is, emails belonging to a domain are mapped to fake emails in the same domain.

```python
from rdt.transformers.email import DomainBasedMapper

mapper = DomainBasedMapper()
```

## Parameters

**`preserved_domain`**: Which parts of the overall email domain to preserve during the transformation phase

<table data-header-hidden><thead><tr><th width="186"></th><th></th></tr></thead><tbody><tr><td>(default) <code>'full'</code></td><td>Preserve the full domain, which is everything after the <strong>@</strong> sign. For example if the email is <code>'info@datacebo.com'</code>, it will be mapped to a fake email that also ends with <code>'datacebo.com'</code>.</td></tr><tr><td><code>'top'</code></td><td>Extract only the top domain, which is everything after the <strong>.</strong> character. For example if the email is <code>'info@datacebo.com'</code>, it will be mapped a fake email that also ends with <code>'.com'</code>.</td></tr></tbody></table>

**`obfuscate_emails`**: Control whether the synthetic email looks realistic or follows random patterns.

<table data-header-hidden><thead><tr><th width="185"></th><th></th></tr></thead><tbody><tr><td>(default) <code>False</code></td><td>Create realistic-looking usernames and emails such as <code>'johndoe@gmail.com'</code>.</td></tr><tr><td><code>True</code></td><td>Obfuscate the usernames and emails to create random values such as <code>'dkep22ocp2@sdv-example.com'</code>.</td></tr></tbody></table>

{% hint style="warning" %}
Setting this to `False` may result in emails that correspond to real user emails by complete coincidence. If you are worried about creating emails that accidentally correspond to real users, please set this to`True`.
{% endhint %}

### Examples

```python
from rdt.transformers.email import DomainBasedMapper

mapper = DomainBasedMapper(
    preserved_domain='full',
    obfuscate_emails=True
)
```

## Attributes

After fitting the transformer, you can access the learned values through the attributes.

**`mapping`**: A dictionary that maps the original, real emails to the new, fake email

```python
>>> transformer.mapping
{
    'info@datacebo.com': 'dkep22ocp2@datacebo.com',
    'admissions@mit.edu': '9p3ocoo1pf@mit.edu',
    ...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/email/domainbasedmapper.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
