-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
1 parent
a8216a6
commit 6d79fee
Showing
3 changed files
with
261 additions
and
28 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
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,12 +1,205 @@ | ||
import unittest | ||
|
||
from names_dataset import NameDataset | ||
from names_dataset.emails import extract_names_from_email | ||
from names_dataset.emails import extract_names_from_email, try_to_split_with_two_last_names | ||
|
||
|
||
class TestEmail(unittest.TestCase): | ||
|
||
def test_1(self): | ||
def test_with_three_3(self): | ||
inputs = [ | ||
'perezmartiisabel', | ||
'isabelmartiperez', | ||
'martiperezisabel', | ||
'isabelperezmarti', | ||
|
||
'garciafernandezmaria', | ||
'mariafernandezgarcia', | ||
|
||
'gonzalezlopezana', | ||
'analopezgonzalez', | ||
|
||
'rodriguezhernandezjuan', | ||
'juanhernandezrodriguez', | ||
|
||
'suarezdominguezcarlos', | ||
'carlosdominguezsuarez', | ||
|
||
'sanchezruizlucia', | ||
'luciaruizsanchez', | ||
|
||
'gomeznunezmiguel', | ||
'miguelnunezgomez', | ||
|
||
] | ||
|
||
outputs = [ | ||
['isabel', 'perez', 'marti'], | ||
['isabel', 'marti', 'perez'], | ||
['isabel', 'marti', 'perez'], | ||
['isabel', 'perez', 'marti'], | ||
|
||
['maria', 'garcia', 'fernandez'], | ||
['maria', 'fernandez', 'garcia'], | ||
|
||
['ana', 'gonzalez', 'lopez'], | ||
['ana', 'lopez', 'gonzalez'], | ||
|
||
['juan', 'rodriguez', 'hernandez'], | ||
['juan', 'hernandez', 'rodriguez'], | ||
|
||
['carlos', 'suarez', 'dominguez'], | ||
['carlos', 'dominguez', 'suarez'], | ||
|
||
['lucia', 'sanchez', 'ruiz'], | ||
['lucia', 'ruiz', 'sanchez'], | ||
|
||
['miguel', 'gomez', 'nunez'], | ||
['miguel', 'nunez', 'gomez'], | ||
] | ||
inputs2 = [] | ||
for i in inputs: | ||
inputs2.append(i.split('@')[0]) | ||
|
||
nd = NameDataset() | ||
for input_, output_ in zip(inputs2, outputs): | ||
first_name, last_name, last_name2 = try_to_split_with_two_last_names(nd, input_) | ||
print(input_) | ||
print('output=', first_name, last_name, last_name2) | ||
print('expected=', output_[0], output_[1], output_[2]) | ||
self.assertEqual(output_[0], first_name) | ||
self.assertEqual(output_[1], last_name) | ||
self.assertEqual(output_[2], last_name2) | ||
print('[OK]') | ||
|
||
def test_with_three_2(self): | ||
inputs = [ | ||
'torresmoralesines', | ||
|
||
'perezmartiisabel', | ||
'isabelmartiperez', | ||
'martiperezisabel', | ||
'isabelperezmarti', | ||
|
||
'garciafernandezmaria', | ||
'mariafernandezgarcia', | ||
'fernandezgarciamaria', | ||
'mariagarciafernandez', | ||
|
||
'gonzalezlopezana', | ||
'analopezgonzalez', | ||
'lopezgonzalezana', | ||
'anagonzalezlopez', | ||
|
||
'rodriguezhernandezjuan', | ||
'juanhernandezrodriguez', | ||
'hernandezrodriguezjuan', | ||
'juanrodriguezhernandez', | ||
|
||
'suarezdominguezcarlos', | ||
'carlosdominguezsuarez', | ||
'dominguezsuarezcarlos', | ||
'carlossuarezdominguez', | ||
|
||
'sanchezruizlucia', | ||
'luciaruizsanchez', | ||
'ruizsanchezlucia', | ||
'luciasanchezruiz', | ||
|
||
'gomeznunezmiguel', | ||
'miguelnunezgomez', | ||
'nunezgomezmiguel', | ||
'miguelgomeznunez', | ||
|
||
'moralestorresines', | ||
'inestorresmorales', | ||
] | ||
|
||
outputs = [ | ||
['ines', 'torres', 'morales'], | ||
|
||
['isabel', 'perez', 'marti'], | ||
['isabel', 'marti', 'perez'], | ||
['isabel', 'marti', 'perez'], | ||
['isabel', 'perez', 'marti'], | ||
|
||
['maria', 'garcia', 'fernandez'], | ||
['maria', 'fernandez', 'garcia'], | ||
['maria', 'fernandez', 'garcia'], | ||
['maria', 'garcia', 'fernandez'], | ||
|
||
['ana', 'gonzalez', 'lopez'], | ||
['ana', 'lopez', 'gonzalez'], | ||
['ana', 'lopez', 'gonzalez'], | ||
['ana', 'gonzalez', 'lopez'], | ||
|
||
['juan', 'rodriguez', 'hernandez'], | ||
['juan', 'hernandez', 'rodriguez'], | ||
['juan', 'hernandez', 'rodriguez'], | ||
['juan', 'rodriguez', 'hernandez'], | ||
|
||
['carlos', 'suarez', 'dominguez'], | ||
['carlos', 'dominguez', 'suarez'], | ||
['carlos', 'dominguez', 'suarez'], | ||
['carlos', 'suarez', 'dominguez'], | ||
|
||
['lucia', 'sanchez', 'ruiz'], | ||
['lucia', 'ruiz', 'sanchez'], | ||
['lucia', 'ruiz', 'sanchez'], | ||
['lucia', 'sanchez', 'ruiz'], | ||
|
||
['miguel', 'gomez', 'nunez'], | ||
['miguel', 'nunez', 'gomez'], | ||
['miguel', 'nunez', 'gomez'], | ||
['miguel', 'gomez', 'nunez'], | ||
|
||
['ines', 'morales', 'torres'], | ||
['ines', 'torres', 'morales'], | ||
] | ||
inputs2 = [] | ||
for i in inputs: | ||
inputs2.append(i.split('@')[0]) | ||
|
||
nd = NameDataset() | ||
for input_, output_ in zip(inputs2, outputs): | ||
first_name, last_name, last_name2 = try_to_split_with_two_last_names(nd, input_) | ||
print(input_) | ||
print('output=', first_name, last_name, last_name2) | ||
print('expected=', output_[0], output_[1], output_[2]) | ||
self.assertEqual(output_[0], first_name) | ||
self.assertEqual(output_[1], last_name) | ||
self.assertEqual(output_[2], last_name2) | ||
print('[OK]') | ||
|
||
def test_with_three_1(self): | ||
inputs = [ | ||
'perezmartiisabel', | ||
'isabelmartiperez', | ||
'martiperezisabel', | ||
'isabelperezmarti', | ||
] | ||
outputs = [ | ||
['isabel', 'perez', 'marti'], | ||
['isabel', 'marti', 'perez'], | ||
|
||
['isabel', 'marti', 'perez'], | ||
['isabel', 'perez', 'marti'], | ||
] | ||
inputs2 = [] | ||
for i in inputs: | ||
inputs2.append(i.split('@')[0]) | ||
|
||
nd = NameDataset() | ||
for input_, output_ in zip(inputs2, outputs): | ||
first_name, last_name, last_name2 = try_to_split_with_two_last_names(nd, input_) | ||
print(input_) | ||
print('output=', first_name, last_name, last_name2) | ||
self.assertEqual(output_[0], first_name) | ||
self.assertEqual(output_[1], last_name) | ||
self.assertEqual(output_[2], last_name2) | ||
print('[OK]') | ||
|
||
def test_with_two(self): | ||
inputs = [ | ||
'[email protected]', | ||
'[email protected]', | ||
|
@@ -28,6 +221,7 @@ def test_1(self): | |
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'perezmarti', | ||
] | ||
inputs2 = [] | ||
for i in inputs: | ||
|
@@ -54,6 +248,7 @@ def test_1(self): | |
['remy', None], | ||
[None, 'remy'], | ||
['philippe', 'remy'], | ||
['perez', 'marti'], | ||
] | ||
|
||
nd = NameDataset() | ||
|