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)