bano1 commited on
Commit
aa1a823
·
verified ·
1 Parent(s): d404481

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -60,28 +60,26 @@ def extract_authors(text):
60
 
61
  for line in lines:
62
  line = line.strip()
63
- # Step 1: title detect karo
64
  if not found_title and len(line.split()) >= 5:
65
  found_title = True
66
  continue
67
-
68
- # Step 2: Stop at abstract/keywords
69
  if found_title:
70
  if "abstract" in line.lower() or "keywords" in line.lower():
71
  break
72
 
73
- # Step 3: Agar line me multiple authors hain
74
  if "," in line or " and " in line.lower():
75
  parts = re.split(",| and ", line)
76
  for name in parts:
77
  name = name.strip()
78
- if re.match(r"^[A-Z][a-z]+(\s[A-Z]\.?\s?[A-Z][a-z]+)?$", name):
 
79
  authors.append(name)
80
  else:
81
- # single name line
82
- if re.match(r"^[A-Z][a-z]+(\s[A-Z]\.?\s?[A-Z][a-z]+)?$", line):
83
  authors.append(line)
84
-
85
  return authors if authors else ["Unknown"]
86
 
87
 
 
60
 
61
  for line in lines:
62
  line = line.strip()
 
63
  if not found_title and len(line.split()) >= 5:
64
  found_title = True
65
  continue
66
+
 
67
  if found_title:
68
  if "abstract" in line.lower() or "keywords" in line.lower():
69
  break
70
 
71
+ # Multiple authors separated by comma / and
72
  if "," in line or " and " in line.lower():
73
  parts = re.split(",| and ", line)
74
  for name in parts:
75
  name = name.strip()
76
+ # Allow First Last or First M. Last
77
+ if re.match(r"^[A-Z][a-z]+(\s[A-Z]\.)?\s[A-Z][a-z]+$", name):
78
  authors.append(name)
79
  else:
80
+ if re.match(r"^[A-Z][a-z]+(\s[A-Z]\.)?\s[A-Z][a-z]+$", line):
 
81
  authors.append(line)
82
+
83
  return authors if authors else ["Unknown"]
84
 
85