Skip to content

Commit 2438a57

Browse files
committed
Add ability to take the ands out of the reference
or the option to leave ands in by commenting or uncommenting a line in main py search for the following comment can use either of the follwoing lines
1 parent 99145e8 commit 2438a57

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

andReplacer.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
3+
import lines
4+
5+
from lines import author
6+
7+
author=author.author()
8+
9+
# ___________________________________
10+
def andReplacer():
11+
"""
12+
encapsulate author program in a
13+
function
14+
"""
15+
# imports
16+
17+
import nltk
18+
import re
19+
20+
21+
# file
22+
23+
f_name="BibTex.bib"
24+
25+
def opener(f_name):
26+
file = open(f_name, 'r', encoding="utf8")
27+
return file
28+
29+
file=opener(f_name)
30+
31+
# end prep
32+
33+
endline=''
34+
file = opener(f_name)
35+
for line in file:
36+
if (re.search('^author',line)):
37+
# if (re.search(' and ',line)):
38+
starter=line
39+
line=line.lstrip('author = {')
40+
line=line.rstrip('},\n')
41+
42+
# line=line.lstrip(' and ')
43+
# line=line.rstrip('')
44+
45+
# splitter = re.compile(r'(\sand+|\Sand')
46+
lineList=re.split(' and ', line)
47+
# print(line2)
48+
# splitter = re.compile(r' and ')
49+
# splitter.findall(line)
50+
# print(line)
51+
# print(splitter)
52+
53+
# for x in lineList:
54+
# lineList+=x
55+
# line=lineList
56+
57+
# line=line.lstrip('[')
58+
# line=line.rstrip(']')
59+
60+
line = re.sub(r', [][][^ ][azAZ] and ', ', ', line)
61+
# line = re.sub(r'[][^ ][azAZ] and ', ', ', line)
62+
line = re.sub(r' and ', ', ', line)
63+
endline=line
64+
65+
# print(endline)
66+
67+
68+
69+
# for x in lineList:
70+
# print(x)
71+
# lineList+=x
72+
# line2=lineList
73+
74+
# return line2
75+
76+
# return type(endline[:])
77+
return endline[:]
78+
79+
80+
# andReplacer=andReplacer()
81+
# print(andReplacer)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# author and and Replacer
2+
3+
```python
4+
import re
5+
splitter = re.compile(r'(\s+|\S+)')
6+
splitter.findall(s)
7+
```
8+
9+
[how to tokenizer split line delimiter python - Google Search](https://www.google.com/search?q=how+to+tokenizer+split+line+delimiter+python&oq=how+to+tokenizer+split+line+delimiter+python&gs_lcrp=EgZjaHJvbWUyCwgAEEUYChg5GKABMgkIARAhGAoYoAHSAQkxNDY1NGowajeoAgCwAgA&sourceid=chrome&ie=UTF-8)
10+
11+
[tokenize a string keeping delimiters in Python - Stack Overflow](https://stackoverflow.com/questions/1820336/tokenize-a-string-keeping-delimiters-in-python)

main.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,26 @@
9797

9898
# __________________________________
9999

100-
reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'
100+
import andReplacer
101+
102+
andReplacer = andReplacer.andReplacer()
103+
104+
# __________________________________
105+
106+
# note on import of last or each module above:
107+
# import module (file), then do
108+
# imported_module.the_function_in_the_imported_module()
109+
# and set the name previously used for the module to be the_function_from_the_module
110+
111+
# __________________________________
112+
113+
# can use either of the following lines:
114+
115+
# reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'
116+
reference = andReplacer + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'
117+
118+
119+
# reference = andReplacer.andReplacer()
101120

102121
# print("title =", title)
103122
# print("journal", journal)

0 commit comments

Comments
 (0)