Skip to content

Commit

Permalink
Add ability to take the ands out of the reference
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CoderSales committed Dec 21, 2024
1 parent 99145e8 commit 2438a57
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
81 changes: 81 additions & 0 deletions andReplacer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
11 changes: 11 additions & 0 deletions documentation/02nd20docs/31authorAndReplacer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# author and and Replacer

```python
import re
splitter = re.compile(r'(\s+|\S+)')
splitter.findall(s)
```

[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)

[tokenize a string keeping delimiters in Python - Stack Overflow](https://stackoverflow.com/questions/1820336/tokenize-a-string-keeping-delimiters-in-python)
21 changes: 20 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,26 @@

# __________________________________

reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'
import andReplacer

andReplacer = andReplacer.andReplacer()

# __________________________________

# note on import of last or each module above:
# import module (file), then do
# imported_module.the_function_in_the_imported_module()
# and set the name previously used for the module to be the_function_from_the_module

# __________________________________

# can use either of the following lines:

# reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'
reference = andReplacer + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed ' + date + '].'


# reference = andReplacer.andReplacer()

# print("title =", title)
# print("journal", journal)
Expand Down

0 comments on commit 2438a57

Please sign in to comment.