File size: 2,354 Bytes
09d9ab7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def generate_citation(style, author, title, publisher, year, city=None, url=None, access_date=None):
    """
    Generate a citation in MLA, Chicago, or APA format.
    
    :param style: Citation style ('mla', 'chicago', or 'apa')
    :param author: Author's name (last name, first name)
    :param title: Title of the work
    :param publisher: Publisher's name
    :param year: Year of publication
    :param city: City of publication (optional)
    :param url: URL of the source (optional)
    :param access_date: Date accessed for online sources (optional)
    :return: Formatted citation string
    """
    if author == None:
        author = 'Arcana'
    if title == None:
        title = ''
    if publisher == None:
        publisher = "Peer Advisor"
    if year == None:
        year = ''
    if style == None:
        style='mla'
        
    if style.lower() == 'mla':
        citation = f"{author.split(', ')[1]} {author.split(', ')[0]}. {title}. "
        if city:
            citation += f"{city}: "
        citation += f"{publisher}, {year}."
        if url:
            citation += f" {url}."
        if access_date:
            citation += f" Accessed {access_date}."
    
    elif style.lower() == 'chicago':
        citation = f"{author.split(', ')[1]} {author.split(', ')[0]}. {title}. "
        if city:
            citation += f"{city}: "
        citation += f"{publisher}, {year}."
        if url:
            citation += f" {url}."
    
    elif style.lower() == 'apa':
        citation = f"{author}. ({year}). {title}. "
        if city:
            citation += f"{city}: "
        citation += f"{publisher}."
        if url:
            citation += f" {url}"
    
    else:
        return "Invalid citation style. Please choose 'mla', 'chicago', or 'apa'."
    
    return citation
'''
# MLA citation
mla_citation = generate_citation('mla', 'Doe, John', 'The Great Book', 'Awesome Publishers', '2023', 'New York', 'https://example.com', 'July 20, 2024')
print(mla_citation)

# Chicago citation
chicago_citation = generate_citation('chicago', 'Smith, Jane', 'An Amazing Study', 'Academic Press', '2022', 'London')
print(chicago_citation)

# APA citation
apa_citation = generate_citation('apa', 'Johnson, Robert', 'The Future of Technology', 'Tech Books Inc.', '2024', url='https://techbooks.com/future')
print(apa_citation)
'''