-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from . import airports, countries | ||
from .isbn import ISBN | ||
from .phone_numbers import PhoneNumber | ||
from .zip_codes import ZipCode | ||
from .locales import locale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from dataclasses import dataclass | ||
|
||
from outlines.types.phone_numbers import USPhoneNumber | ||
from outlines.types.zip_codes import USZipCode | ||
|
||
|
||
@dataclass | ||
class US: | ||
ZipCode = USZipCode | ||
PhoneNumber = USPhoneNumber | ||
|
||
|
||
def locale(locale_str: str): | ||
locales = {"us": US} | ||
|
||
if locale_str not in locales: | ||
raise NotImplementedError( | ||
f"The locale {locale_str} is not supported yet. Please don't hesitate to create custom types for you locale and open a Pull Request." | ||
) | ||
|
||
return locales[locale_str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters