-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandReplacer.py
81 lines (55 loc) · 1.63 KB
/
andReplacer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import lines
from lines import author
author=author.author()
# ___________________________________
def andReplacer():
"""
encapsulate author program in a
function
"""
# imports
import nltk
import re
# file
f_name="BibTex.bib"
def opener(f_name):
file = open(f_name, 'r', encoding="utf8")
return file
file=opener(f_name)
# end prep
endline=''
file = opener(f_name)
for line in file:
if (re.search('^author',line)):
# if (re.search(' and ',line)):
starter=line
line=line.lstrip('author = {')
line=line.rstrip('},\n')
# line=line.lstrip(' and ')
# line=line.rstrip('')
# splitter = re.compile(r'(\sand+|\Sand')
lineList=re.split(' and ', line)
# print(line2)
# splitter = re.compile(r' and ')
# splitter.findall(line)
# print(line)
# print(splitter)
# for x in lineList:
# lineList+=x
# line=lineList
# line=line.lstrip('[')
# line=line.rstrip(']')
line = re.sub(r', [][][^ ][azAZ] and ', ', ', line)
# line = re.sub(r'[][^ ][azAZ] and ', ', ', line)
line = re.sub(r' and ', ', ', line)
endline=line
# print(endline)
# for x in lineList:
# print(x)
# lineList+=x
# line2=lineList
# return line2
# return type(endline[:])
return endline[:]
# andReplacer=andReplacer()
# print(andReplacer)