File size: 1,304 Bytes
930b392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import re

def validate_citation(citation_text, style):
    """Basic validation for citation format"""
    errors = []
    
    if not citation_text or len(citation_text.strip()) < 10:
        errors.append("Citation appears too short")
    
    if style == "APA7":
        # Check for basic APA7 patterns
        if not re.search(r'\(\d{4}\)', citation_text):
            errors.append("Missing year in parentheses")
        if not citation_text.strip().endswith('.'):
            errors.append("Citation should end with a period")
    
    elif style == "Chicago":
        # Check for basic Chicago patterns
        if '"' not in citation_text and '"' not in citation_text:
            errors.append("Chicago style typically includes quotation marks around titles")
    
    return errors

def format_authors(authors):
    """Format author list from Crossref data"""
    if not authors:
        return "Unknown Author"
    
    formatted_authors = []
    for author in authors[:5]:  # Limit to 5 authors
        given = author.get('given', '')
        family = author.get('family', '')
        if family:
            formatted_authors.append(f"{family}, {given}" if given else family)
    
    if len(authors) > 5:
        formatted_authors.append("et al.")
    
    return "; ".join(formatted_authors)