csv-detective 0.8.1.dev1362__py3-none-any.whl → 0.8.1.dev1416__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. csv_detective/detect_fields/other/url/__init__.py +7 -6
  2. csv_detective/detect_labels/FR/geo/adresse/__init__.py +9 -34
  3. csv_detective/detect_labels/FR/geo/code_commune_insee/__init__.py +11 -36
  4. csv_detective/detect_labels/FR/geo/code_departement/__init__.py +11 -29
  5. csv_detective/detect_labels/FR/geo/code_fantoir/__init__.py +8 -29
  6. csv_detective/detect_labels/FR/geo/code_postal/__init__.py +10 -35
  7. csv_detective/detect_labels/FR/geo/code_region/__init__.py +10 -29
  8. csv_detective/detect_labels/FR/geo/commune/__init__.py +8 -29
  9. csv_detective/detect_labels/FR/geo/departement/__init__.py +16 -41
  10. csv_detective/detect_labels/FR/geo/insee_canton/__init__.py +9 -29
  11. csv_detective/detect_labels/FR/geo/latitude_l93/__init__.py +24 -48
  12. csv_detective/detect_labels/FR/geo/latitude_wgs_fr_metropole/__init__.py +24 -49
  13. csv_detective/detect_labels/FR/geo/longitude_l93/__init__.py +15 -38
  14. csv_detective/detect_labels/FR/geo/longitude_wgs_fr_metropole/__init__.py +14 -38
  15. csv_detective/detect_labels/FR/geo/pays/__init__.py +14 -39
  16. csv_detective/detect_labels/FR/geo/region/__init__.py +14 -39
  17. csv_detective/detect_labels/FR/other/code_csp_insee/__init__.py +4 -29
  18. csv_detective/detect_labels/FR/other/code_rna/__init__.py +7 -32
  19. csv_detective/detect_labels/FR/other/code_waldec/__init__.py +4 -29
  20. csv_detective/detect_labels/FR/other/csp_insee/__init__.py +6 -30
  21. csv_detective/detect_labels/FR/other/date_fr/__init__.py +5 -29
  22. csv_detective/detect_labels/FR/other/insee_ape700/__init__.py +9 -34
  23. csv_detective/detect_labels/FR/other/sexe/__init__.py +4 -29
  24. csv_detective/detect_labels/FR/other/siren/__init__.py +10 -35
  25. csv_detective/detect_labels/FR/other/siret/__init__.py +9 -34
  26. csv_detective/detect_labels/FR/other/tel_fr/__init__.py +14 -38
  27. csv_detective/detect_labels/FR/other/uai/__init__.py +17 -42
  28. csv_detective/detect_labels/FR/temp/jour_de_la_semaine/__init__.py +10 -35
  29. csv_detective/detect_labels/FR/temp/mois_de_annee/__init__.py +4 -29
  30. csv_detective/detect_labels/geo/iso_country_code_alpha2/__init__.py +10 -35
  31. csv_detective/detect_labels/geo/iso_country_code_alpha3/__init__.py +10 -35
  32. csv_detective/detect_labels/geo/iso_country_code_numeric/__init__.py +10 -35
  33. csv_detective/detect_labels/geo/json_geojson/__init__.py +11 -36
  34. csv_detective/detect_labels/geo/latitude_wgs/__init__.py +24 -49
  35. csv_detective/detect_labels/geo/latlon_wgs/__init__.py +37 -61
  36. csv_detective/detect_labels/geo/longitude_wgs/__init__.py +14 -38
  37. csv_detective/detect_labels/other/booleen/__init__.py +4 -30
  38. csv_detective/detect_labels/other/email/__init__.py +14 -39
  39. csv_detective/detect_labels/other/float/__init__.py +4 -29
  40. csv_detective/detect_labels/other/int/__init__.py +4 -29
  41. csv_detective/detect_labels/other/money/__init__.py +5 -8
  42. csv_detective/detect_labels/other/mongo_object_id/__init__.py +3 -28
  43. csv_detective/detect_labels/other/twitter/__init__.py +4 -29
  44. csv_detective/detect_labels/other/url/__init__.py +17 -42
  45. csv_detective/detect_labels/other/uuid/__init__.py +4 -29
  46. csv_detective/detect_labels/temp/date/__init__.py +22 -47
  47. csv_detective/detect_labels/temp/datetime_iso/__init__.py +14 -39
  48. csv_detective/detect_labels/temp/datetime_rfc822/__init__.py +13 -38
  49. csv_detective/detect_labels/temp/year/__init__.py +13 -38
  50. csv_detective/parsing/text.py +42 -20
  51. csv_detective/utils.py +1 -4
  52. {csv_detective-0.8.1.dev1362.data → csv_detective-0.8.1.dev1416.data}/data/share/csv_detective/CHANGELOG.md +2 -1
  53. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/METADATA +1 -1
  54. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/RECORD +62 -63
  55. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/WHEEL +1 -1
  56. tests/test_fields.py +11 -2
  57. tests/test_labels.py +18 -2
  58. csv_detective/detect_labels/other/money/check_col_name.py +0 -8
  59. {csv_detective-0.8.1.dev1362.data → csv_detective-0.8.1.dev1416.data}/data/share/csv_detective/LICENSE.AGPL.txt +0 -0
  60. {csv_detective-0.8.1.dev1362.data → csv_detective-0.8.1.dev1416.data}/data/share/csv_detective/README.md +0 -0
  61. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/entry_points.txt +0 -0
  62. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/licenses/LICENSE.AGPL.txt +0 -0
  63. {csv_detective-0.8.1.dev1362.dist-info → csv_detective-0.8.1.dev1416.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,14 @@
1
+ import re
1
2
 
2
3
  PROPORTION = 1
4
+ url_pattern = re.compile(
5
+ r"^((https?|ftp)://|www\.)(([A-Za-z0-9-]+\.)+[A-Za-z]{2,6})"
6
+ r"(/[A-Za-z0-9._~:/?#[@!$&'()*+,;=%-]*)?$"
7
+ )
3
8
 
4
9
 
5
10
  def _is(val):
6
- '''Detects urls'''
11
+ """Detects urls"""
7
12
  if not isinstance(val, str):
8
13
  return False
9
- a = 'http://' in val
10
- b = 'www.' in val
11
- c = any([x in val for x in ['.fr', '.com', '.org', '.gouv', '.net']])
12
- d = not ('@' in val)
13
- return (a or b or c) and d
14
+ return bool(url_pattern.match(val))
@@ -1,40 +1,15 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
6
+ def _is(header: str) -> float:
13
7
  words_combinations_list = [
14
- 'adresse',
15
- 'adresse postale',
16
- 'adresse geographique',
17
- 'adr',
18
- 'adresse complete',
19
- 'adresse station'
8
+ "adresse",
9
+ "adresse postale",
10
+ "adresse geographique",
11
+ "adr",
12
+ "adresse complete",
13
+ "adresse station",
20
14
  ]
21
- processed_header = _process_text(header)
22
-
23
- header_matches_words_combination = float(
24
- any(
25
- [
26
- words_combination == processed_header for words_combination in words_combinations_list
27
- ]
28
- )
29
- )
30
- words_combination_in_header = 0.5 * float(
31
- any(
32
- [
33
- is_word_in_string(
34
- words_combination, processed_header
35
- ) for words_combination in words_combinations_list
36
- ]
37
- )
38
- )
39
-
40
- return max(header_matches_words_combination, words_combination_in_header)
15
+ return header_score(header, words_combinations_list)
@@ -1,42 +1,17 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
6
+ def _is(header: str) -> float:
13
7
  words_combinations_list = [
14
- 'code commune insee',
15
- 'code insee',
16
- 'codes insee',
17
- 'code commune',
18
- 'code insee commune',
19
- 'insee',
20
- 'code com',
21
- 'com',
8
+ "code commune insee",
9
+ "code insee",
10
+ "codes insee",
11
+ "code commune",
12
+ "code insee commune",
13
+ "insee",
14
+ "code com",
15
+ "com",
22
16
  ]
23
- processed_header = _process_text(header)
24
-
25
- header_matches_words_combination = float(
26
- any(
27
- [
28
- words_combination == processed_header for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
- words_combination_in_header = 0.5 * float(
33
- any(
34
- [
35
- is_word_in_string(
36
- words_combination, processed_header
37
- ) for words_combination in words_combinations_list
38
- ]
39
- )
40
- )
41
-
42
- return max(header_matches_words_combination, words_combination_in_header)
17
+ return header_score(header, words_combinations_list)
@@ -1,33 +1,15 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
- # 'dep': Possible confusion with dep name?
13
- words_combinations_list = ['code departement', 'code_departement', 'dep', 'departement', 'dept']
14
- processed_header = _process_text(header)
15
-
16
- header_matches_words_combination = float(
17
- any(
18
- [
19
- words_combination == processed_header for words_combination in words_combinations_list
20
- ]
21
- )
22
- )
23
- words_combination_in_header = 0.5 * float(
24
- any(
25
- [
26
- is_word_in_string(
27
- words_combination, processed_header
28
- ) for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
-
33
- return max(header_matches_words_combination, words_combination_in_header)
6
+ def _is(header: str) -> float:
7
+ # "dep": Possible confusion with dep name?
8
+ words_combinations_list = [
9
+ "code departement",
10
+ "code_departement",
11
+ "dep",
12
+ "departement",
13
+ "dept",
14
+ ]
15
+ return header_score(header, words_combinations_list)
@@ -1,33 +1,12 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
13
- words_combinations_list = ['cadastre1', 'code fantoir', 'fantoir']
14
- processed_header = _process_text(header)
15
-
16
- header_matches_words_combination = float(
17
- any(
18
- [
19
- words_combination == processed_header for words_combination in words_combinations_list
20
- ]
21
- )
22
- )
23
- words_combination_in_header = 0.5 * float(
24
- any(
25
- [
26
- is_word_in_string(
27
- words_combination, processed_header
28
- ) for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
-
33
- return max(header_matches_words_combination, words_combination_in_header)
6
+ def _is(header: str) -> float:
7
+ words_combinations_list = [
8
+ "cadastre1",
9
+ "code fantoir",
10
+ "fantoir",
11
+ ]
12
+ return header_score(header, words_combinations_list)
@@ -1,41 +1,16 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
6
+ def _is(header: str) -> float:
13
7
  words_combinations_list = [
14
- 'code postal',
15
- 'postal code',
16
- 'postcode',
17
- 'post code',
18
- 'cp',
19
- 'codes postaux',
20
- 'location postcode'
8
+ "code postal",
9
+ "postal code",
10
+ "postcode",
11
+ "post code",
12
+ "cp",
13
+ "codes postaux",
14
+ "location postcode",
21
15
  ]
22
- processed_header = _process_text(header)
23
-
24
- header_matches_words_combination = float(
25
- any(
26
- [
27
- words_combination == processed_header for words_combination in words_combinations_list
28
- ]
29
- )
30
- )
31
- words_combination_in_header = 0.5 * float(
32
- any(
33
- [
34
- is_word_in_string(
35
- words_combination, processed_header
36
- ) for words_combination in words_combinations_list
37
- ]
38
- )
39
- )
40
-
41
- return max(header_matches_words_combination, words_combination_in_header)
16
+ return header_score(header, words_combinations_list)
@@ -1,33 +1,14 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
- # 'reg' : possible confusion with region name?
13
- words_combinations_list = ['code region', 'reg', 'code insee region', 'region']
14
- processed_header = _process_text(header)
15
-
16
- header_matches_words_combination = float(
17
- any(
18
- [
19
- words_combination == processed_header for words_combination in words_combinations_list
20
- ]
21
- )
22
- )
23
- words_combination_in_header = 0.5 * float(
24
- any(
25
- [
26
- is_word_in_string(
27
- words_combination, processed_header
28
- ) for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
-
33
- return max(header_matches_words_combination, words_combination_in_header)
6
+ def _is(header: str) -> float:
7
+ # "reg" : possible confusion with region name?
8
+ words_combinations_list = [
9
+ "code region",
10
+ "reg",
11
+ "code insee region",
12
+ "region",
13
+ ]
14
+ return header_score(header, words_combinations_list)
@@ -1,33 +1,12 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
13
- words_combinations_list = ['commune', 'ville', 'libelle commune']
14
- processed_header = _process_text(header)
15
-
16
- header_matches_words_combination = float(
17
- any(
18
- [
19
- words_combination == processed_header for words_combination in words_combinations_list
20
- ]
21
- )
22
- )
23
- words_combination_in_header = 0.5 * float(
24
- any(
25
- [
26
- is_word_in_string(
27
- words_combination, processed_header
28
- ) for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
-
33
- return max(header_matches_words_combination, words_combination_in_header)
6
+ def _is(header: str) -> float:
7
+ words_combinations_list = [
8
+ "commune",
9
+ "ville",
10
+ "libelle commune",
11
+ ]
12
+ return header_score(header, words_combinations_list)
@@ -1,47 +1,22 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
6
+ def _is(header: str) -> float:
13
7
  words_combinations_list = [
14
- 'departement',
15
- 'libelle du departement',
16
- 'deplib',
17
- 'nom dept',
18
- 'dept',
19
- 'libdepartement',
20
- 'nom departement',
21
- 'libelle dep',
22
- 'libelle departement',
23
- 'lb departements',
24
- 'dep libusage',
25
- 'lb departement',
26
- 'nom dep'
8
+ "departement",
9
+ "libelle du departement",
10
+ "deplib",
11
+ "nom dept",
12
+ "dept",
13
+ "libdepartement",
14
+ "nom departement",
15
+ "libelle dep",
16
+ "libelle departement",
17
+ "lb departements",
18
+ "dep libusage",
19
+ "lb departement",
20
+ "nom dep",
27
21
  ]
28
- processed_header = _process_text(header)
29
-
30
- header_matches_words_combination = float(
31
- any(
32
- [
33
- words_combination == processed_header for words_combination in words_combinations_list
34
- ]
35
- )
36
- )
37
- words_combination_in_header = 0.5 * float(
38
- any(
39
- [
40
- is_word_in_string(
41
- words_combination, processed_header
42
- ) for words_combination in words_combinations_list
43
- ]
44
- )
45
- )
46
-
47
- return max(header_matches_words_combination, words_combination_in_header)
22
+ return header_score(header, words_combinations_list)
@@ -1,33 +1,13 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
13
- words_combinations_list = ['insee canton', 'canton', 'cant', 'nom canton']
14
- processed_header = _process_text(header)
15
-
16
- header_matches_words_combination = float(
17
- any(
18
- [
19
- words_combination == processed_header for words_combination in words_combinations_list
20
- ]
21
- )
22
- )
23
- words_combination_in_header = 0.5 * float(
24
- any(
25
- [
26
- is_word_in_string(
27
- words_combination, processed_header
28
- ) for words_combination in words_combinations_list
29
- ]
30
- )
31
- )
32
-
33
- return max(header_matches_words_combination, words_combination_in_header)
6
+ def _is(header: str) -> float:
7
+ words_combinations_list = [
8
+ "insee canton",
9
+ "canton",
10
+ "cant",
11
+ "nom canton",
12
+ ]
13
+ return header_score(header, words_combinations_list)
@@ -1,54 +1,30 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
6
+ def _is(header: str) -> float:
12
7
  # Does not always detect CRS
13
8
  words_combinations_list = [
14
- 'latitude',
15
- 'lat',
16
- 'y',
17
- 'yf',
18
- 'yd',
19
- 'y l93',
20
- 'coordonnee y',
21
- 'latitude lb93',
22
- 'coord y',
23
- 'ycoord',
24
- 'geocodage y gps',
25
- 'location latitude',
26
- 'ylatitude',
27
- 'ylat',
28
- 'latitude (y)',
29
- 'latitudeorg',
30
- 'coordinates.latitude',
31
- 'googlemap latitude',
32
- 'latitudelieu',
33
- 'latitude googlemap'
34
- ]
35
- processed_header = _process_text(header)
36
-
37
- header_matches_words_combination = float(
38
- any(
39
- [
40
- words_combination == processed_header for words_combination in words_combinations_list
41
- ]
42
- )
43
- )
44
- words_combination_in_header = 0.5 * float(
45
- any(
46
- [
47
- is_word_in_string(
48
- words_combination, processed_header
49
- ) for words_combination in words_combinations_list
50
- ]
51
- )
52
- )
53
-
54
- return max(header_matches_words_combination, words_combination_in_header)
9
+ "latitude",
10
+ "lat",
11
+ "y",
12
+ "yf",
13
+ "yd",
14
+ "y l93",
15
+ "coordonnee y",
16
+ "latitude lb93",
17
+ "coord y",
18
+ "ycoord",
19
+ "geocodage y gps",
20
+ "location latitude",
21
+ "ylatitude",
22
+ "ylat",
23
+ "latitude (y)",
24
+ "latitudeorg",
25
+ "coordinates.latitude",
26
+ "googlemap latitude",
27
+ "latitudelieu",
28
+ "latitude googlemap",
29
+ ]
30
+ return header_score(header, words_combinations_list)
@@ -1,55 +1,30 @@
1
- from csv_detective.utils import is_word_in_string
2
- from csv_detective.parsing.text import _process_text
1
+ from csv_detective.parsing.text import header_score
3
2
 
4
3
  PROPORTION = 0.5
5
4
 
6
5
 
7
- def _is(header):
8
- '''
9
- Returns 1 if the (processed) header matches one of the expected words combination,
10
- else 0
11
- '''
12
-
6
+ def _is(header: str) -> float:
13
7
  words_combinations_list = [
14
- 'latitude',
15
- 'lat',
16
- 'y',
17
- 'yf',
18
- 'yd',
19
- 'coordonnee y',
20
- 'coord y',
21
- 'ycoord',
22
- 'geocodage y gps',
23
- 'location latitude',
24
- 'ylatitude',
25
- 'ylat',
26
- 'latitude (y)',
27
- 'latitudeorg',
28
- 'coordinates.latitude',
29
- 'googlemap latitude',
30
- 'latitudelieu',
31
- 'latitude googlemap',
32
- 'latitude wgs84',
33
- 'y wgs84',
34
- 'latitude (wgs84)'
8
+ "latitude",
9
+ "lat",
10
+ "y",
11
+ "yf",
12
+ "yd",
13
+ "coordonnee y",
14
+ "coord y",
15
+ "ycoord",
16
+ "geocodage y gps",
17
+ "location latitude",
18
+ "ylatitude",
19
+ "ylat",
20
+ "latitude (y)",
21
+ "latitudeorg",
22
+ "coordinates.latitude",
23
+ "googlemap latitude",
24
+ "latitudelieu",
25
+ "latitude googlemap",
26
+ "latitude wgs84",
27
+ "y wgs84",
28
+ "latitude (wgs84)",
35
29
  ]
36
- processed_header = _process_text(header)
37
-
38
- header_matches_words_combination = float(
39
- any(
40
- [
41
- words_combination == processed_header for words_combination in words_combinations_list
42
- ]
43
- )
44
- )
45
- words_combination_in_header = 0.5 * float(
46
- any(
47
- [
48
- is_word_in_string(
49
- words_combination, processed_header
50
- ) for words_combination in words_combinations_list
51
- ]
52
- )
53
- )
54
-
55
- return max(header_matches_words_combination, words_combination_in_header)
30
+ return header_score(header, words_combinations_list)