tomersagi commited on
Commit
dcb99e8
1 Parent(s): ecc7d89

added Siman chapter marker and relaxed language checking

Browse files
Files changed (1) hide show
  1. scrape_script.py +3 -3
scrape_script.py CHANGED
@@ -46,14 +46,14 @@ def append_to_parquet(content, file_path, lang, top_level_directory, data_dir =
46
  # Check if file_path ends with the pattern [xx].txt
47
  file_pattern = re.search(r'\[[a-zA-Z]{2}\]\.txt$', file_path)
48
  if file_pattern:
49
- print(f"Warning: File '{file_path}' was skipped due to the detected pattern.")
50
  return
51
 
52
  # Check if the content is in English when lang is "en"
53
  if lang == "en":
54
  sample_text = content[:500] if len(content) > 500 else content
55
  detected_lang = detect(sample_text)
56
- if detected_lang != 'en':
57
  print(f"Warning: Non-English content detected in file '{file_path}'. Detected language: {detected_lang}")
58
  return
59
 
@@ -66,7 +66,7 @@ def append_to_parquet(content, file_path, lang, top_level_directory, data_dir =
66
  content = re.sub(r'[\u0591-\u05AF]', '', content)
67
 
68
  # Remove chapter markers
69
- chapter_markers = ['Chapter', 'Halakhah']
70
  for marker in chapter_markers:
71
  content = re.sub(rf'^{marker} +\d+$', '', content, flags=re.MULTILINE)
72
 
 
46
  # Check if file_path ends with the pattern [xx].txt
47
  file_pattern = re.search(r'\[[a-zA-Z]{2}\]\.txt$', file_path)
48
  if file_pattern:
49
+ print(f"Warning: File '{file_path}' was skipped due to the detected [xy] pattern.")
50
  return
51
 
52
  # Check if the content is in English when lang is "en"
53
  if lang == "en":
54
  sample_text = content[:500] if len(content) > 500 else content
55
  detected_lang = detect(sample_text)
56
+ if detected_lang != 'en' and detected_lang != 'id':
57
  print(f"Warning: Non-English content detected in file '{file_path}'. Detected language: {detected_lang}")
58
  return
59
 
 
66
  content = re.sub(r'[\u0591-\u05AF]', '', content)
67
 
68
  # Remove chapter markers
69
+ chapter_markers = ['Chapter', 'Halakhah','Siman']
70
  for marker in chapter_markers:
71
  content = re.sub(rf'^{marker} +\d+$', '', content, flags=re.MULTILINE)
72