Skip to content

paper

Database Models and Paper Representation Handles data models, database operations, and caching for literature search.

Paper dataclass

Paper(title: str, authors: List[str], abstract: str = '', year: int = 0, venue: str = '', doi: str = '', arxiv_id: str = '', url: str = '', citations: int = 0, keywords: List[str] = None, database_source: str = '', pdf_url: str = '', publication_type: str = '', issue: str = '', volume: str = '', pages: str = '', publisher: str = '')

A research paper with standardized metadata.

Examples:

>>> from ures.literature import Paper
>>> paper = Paper(title="CXL memory", authors=["Doe, J."], year=2024)
>>> paper.title
'CXL memory'

get_canonical_id

get_canonical_id() -> str

Generate a canonical identifier for deduplication.

Source code in ures/literature/search/paper.py
108
109
110
111
112
113
114
115
116
117
118
def get_canonical_id(self) -> str:
    """Generate a canonical identifier for deduplication."""
    if self.doi:
        return f"doi:{self.doi}"
    elif self.arxiv_id:
        return f"arxiv:{self.arxiv_id}"
    else:
        title_norm = re.sub(r"[^\w\s]", "", self.title.lower()).strip()
        first_author = self.authors[0] if self.authors else ""
        content = f"{title_norm}|{first_author}|{self.year}"
        return f"hash:{hashlib.md5(content.encode()).hexdigest()}"

to_dict

to_dict() -> Dict

Convert to dictionary representation.

Source code in ures/literature/search/paper.py
120
121
122
def to_dict(self) -> Dict:
    """Convert to dictionary representation."""
    return asdict(self)

from_dict classmethod

from_dict(data: Dict) -> Paper

Create Paper instance from dictionary.

Source code in ures/literature/search/paper.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@classmethod
def from_dict(cls, data: Dict) -> "Paper":
    """Create Paper instance from dictionary."""
    defaults = {
        "title": "",
        "authors": [],
        "abstract": "",
        "year": 0,
        "venue": "",
        "doi": "",
        "arxiv_id": "",
        "url": "",
        "citations": 0,
        "keywords": [],
        "database_source": "",
        "pdf_url": "",
        "publication_type": "",
        "issue": "",
        "volume": "",
        "pages": "",
        "publisher": "",
    }
    paper_data = {**defaults, **data}
    return cls(**paper_data)

similarity_score

similarity_score(other: Paper) -> float

Calculate similarity score with another paper (0-1).

Source code in ures/literature/search/paper.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def similarity_score(self, other: "Paper") -> float:
    """Calculate similarity score with another paper (0-1)."""
    if not isinstance(other, Paper):
        return 0.0

    score = 0.0

    # Title similarity (highest weight)
    if self.title and other.title:
        title1 = re.sub(r"[^\w\s]", "", self.title.lower())
        title2 = re.sub(r"[^\w\s]", "", other.title.lower())
        if title1 == title2:
            score += 0.5
        elif title1 in title2 or title2 in title1:
            score += 0.3

    # Author overlap
    if self.authors and other.authors:
        common_authors = set(self.authors) & set(other.authors)
        if common_authors:
            score += 0.2 * (
                len(common_authors) / max(len(self.authors), len(other.authors))
            )

    # DOI or arXiv ID match
    if self.doi and other.doi and self.doi == other.doi:
        score += 0.3
    elif self.arxiv_id and other.arxiv_id and self.arxiv_id == other.arxiv_id:
        score += 0.3

    # Year proximity
    if self.year and other.year:
        year_diff = abs(self.year - other.year)
        if year_diff == 0:
            score += 0.1
        elif year_diff <= 1:
            score += 0.05

    return min(score, 1.0)

CacheManager

CacheManager(cache_dir: str = './lit_cache')

Manages local caching of search results and paper metadata.

Source code in ures/literature/search/paper.py
193
194
195
196
197
198
def __init__(self, cache_dir: str = "./lit_cache"):
    self.cache_dir = Path(cache_dir)
    self.cache_dir.mkdir(exist_ok=True)
    self.db_path = self.cache_dir / "papers.db"
    self.logger = logging.getLogger(__name__)
    self._init_database()

cache_paper

cache_paper(paper: Paper) -> bool

Cache a paper in the database.

Parameters:

  • paper (Paper) –

    Paper object to cache

Returns:

  • bool ( bool ) –

    Success status

Source code in ures/literature/search/paper.py
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
def cache_paper(self, paper: Paper) -> bool:
    """
    Cache a paper in the database.

    Args:
            paper: Paper object to cache

    Returns:
            bool: Success status
    """
    try:
        paper_id = self._generate_paper_id(paper)
        with sqlite3.connect(self.db_path) as conn:
            conn.execute(
                """
                INSERT OR REPLACE INTO papers
                (id, title, authors, abstract, year, venue, doi, arxiv_id, url, citations,
                 keywords, database_source, pdf_url, publication_type, issue, volume, pages, publisher, updated_at)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
            """,
                (
                    paper_id,
                    paper.title,
                    json.dumps(paper.authors),
                    paper.abstract,
                    paper.year,
                    paper.venue,
                    paper.doi,
                    paper.arxiv_id,
                    paper.url,
                    paper.citations,
                    json.dumps(paper.keywords),
                    paper.database_source,
                    paper.pdf_url,
                    paper.publication_type,
                    paper.issue,
                    paper.volume,
                    paper.pages,
                    paper.publisher,
                ),
            )
        return True
    except Exception as e:
        self.logger.error(f"Failed to cache paper: {e}")
        return False

get_cached_papers

get_cached_papers(query: str = None, year_min: int = None, database_source: str = None, limit: int = None) -> List[Paper]

Retrieve cached papers with optional filtering.

Parameters:

  • query (str, default: None ) –

    Search within title and abstract

  • year_min (int, default: None ) –

    Minimum publication year

  • database_source (str, default: None ) –

    Filter by database source

  • limit (int, default: None ) –

    Maximum number of results

Returns:

  • List[Paper] –

    List[Paper]: List of matching papers

Source code in ures/literature/search/paper.py
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    def get_cached_papers(
        self,
        query: str = None,
        year_min: int = None,
        database_source: str = None,
        limit: int = None,
    ) -> List[Paper]:
        """
        Retrieve cached papers with optional filtering.

        Args:
                query: Search within title and abstract
                year_min: Minimum publication year
                database_source: Filter by database source
                limit: Maximum number of results

        Returns:
                List[Paper]: List of matching papers
        """
        try:
            with sqlite3.connect(self.db_path) as conn:
                sql = """
                      SELECT id, \
                             title, \
                             authors, \
                             abstract, year, venue, doi, arxiv_id, url, citations, keywords, database_source, pdf_url, publication_type, issue, volume, pages, publisher
                      FROM papers \
                      WHERE 1=1 \
				      """
                params = []

                if query:
                    sql += " AND (title LIKE ? OR abstract LIKE ?)"
                    params.extend([f"%{query}%", f"%{query}%"])

                if year_min:
                    sql += " AND year >= ?"
                    params.append(year_min)

                if database_source:
                    sql += " AND database_source = ?"
                    params.append(database_source)

                sql += " ORDER BY year DESC, citations DESC"

                if limit:
                    sql += " LIMIT ?"
                    params.append(limit)

                cursor = conn.execute(sql, params)
                papers = []
                for row in cursor.fetchall():
                    paper_data = {
                        "title": row[1] or "",
                        "authors": json.loads(row[2]) if row[2] else [],
                        "abstract": row[3] or "",
                        "year": row[4] or 0,
                        "venue": row[5] or "",
                        "doi": row[6] or "",
                        "arxiv_id": row[7] or "",
                        "url": row[8] or "",
                        "citations": row[9] or 0,
                        "keywords": json.loads(row[10]) if row[10] else [],
                        "database_source": row[11] or "",
                        "pdf_url": row[12] or "",
                        "publication_type": row[13] or "",
                        "issue": row[14] or "",
                        "volume": row[15] or "",
                        "pages": row[16] or "",
                        "publisher": row[17] or "",
                    }
                    papers.append(Paper.from_dict(paper_data))

                return papers
        except Exception as e:
            self.logger.error(f"Failed to retrieve cached papers: {e}")
            return []

cache_search_results

cache_search_results(query: str, databases: List[str], results: List[Paper]) -> bool

Cache search results with metadata.

Parameters:

  • query (str) –

    Search query

  • databases (List[str]) –

    List of databases searched

  • results (List[Paper]) –

    List of paper results

Returns:

  • bool ( bool ) –

    Success status

Source code in ures/literature/search/paper.py
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
    def cache_search_results(
        self, query: str, databases: List[str], results: List[Paper]
    ) -> bool:
        """
        Cache search results with metadata.

        Args:
                query: Search query
                databases: List of databases searched
                results: List of paper results

        Returns:
                bool: Success status
        """
        try:
            query_hash = self._generate_query_hash(query, databases)

            with sqlite3.connect(self.db_path) as conn:
                # First cache all papers
                for paper in results:
                    self.cache_paper(paper)

                # Insert or update search record
                cursor = conn.execute(
                    """
                    INSERT OR REPLACE INTO searches (query_hash, query, databases, total_results)
                    VALUES (?, ?, ?, ?)
                """,
                    (query_hash, query, json.dumps(databases), len(results)),
                )

                search_id = cursor.lastrowid

                # Clear existing search results
                conn.execute(
                    "DELETE FROM search_results WHERE search_id = ?", (search_id,)
                )

                # Insert search results
                for i, paper in enumerate(results):
                    paper_id = self._generate_paper_id(paper)
                    relevance_score = 1.0 - (
                        i / len(results)
                    )  # Simple relevance based on order

                    conn.execute(
                        """
                                 INSERT INTO search_results (search_id, paper_id, relevance_score)
                                 VALUES (?, ?, ?)
					             """,
                        (search_id, paper_id, relevance_score),
                    )

            return True
        except Exception as e:
            self.logger.error(f"Failed to cache search results: {e}")
            return False
get_cached_search(query: str, databases: List[str], max_age_hours: int = 24) -> Optional[List[Paper]]

Get cached search results if recent enough.

Parameters:

  • query (str) –

    Search query

  • databases (List[str]) –

    List of databases

  • max_age_hours (int, default: 24 ) –

    Maximum age in hours

Returns:

Source code in ures/literature/search/paper.py
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
    def get_cached_search(
        self, query: str, databases: List[str], max_age_hours: int = 24
    ) -> Optional[List[Paper]]:
        """
        Get cached search results if recent enough.

        Args:
                query: Search query
                databases: List of databases
                max_age_hours: Maximum age in hours

        Returns:
                Optional[List[Paper]]: Cached results or None
        """
        try:
            query_hash = self._generate_query_hash(query, databases)

            with sqlite3.connect(self.db_path) as conn:
                # Find recent search
                cursor = conn.execute(
                    """
                    SELECT id FROM searches
                    WHERE query_hash = ? AND searched_at > datetime('now', '-{} hours')
                    ORDER BY searched_at DESC LIMIT 1
                """.format(
                        max_age_hours
                    ),
                    (query_hash,),
                )

                row = cursor.fetchone()
                if not row:
                    return None

                search_id = row[0]

                # Get papers from search results
                cursor = conn.execute(
                    """
                                      SELECT p.id,
                                             p.title,
                                             p.authors,
                                             p.abstract,
                                             p.year,
                                             p.venue,
                                             p.doi,
                                             p.arxiv_id,
                                             p.url,
                                             p.citations,
                                             p.keywords,
                                             p.database_source,
                                             p.pdf_url,
                                             p.publication_type,
                                             p.issue,
                                             p.volume,
                                             p.pages,
                                             p.publisher
                                      FROM papers p
                                               JOIN search_results sr ON p.id = sr.paper_id
                                      WHERE sr.search_id = ?
                                      ORDER BY sr.relevance_score DESC
				                      """,
                    (search_id,),
                )

                papers = []
                for row in cursor.fetchall():
                    paper_data = {
                        "title": row[1] or "",
                        "authors": json.loads(row[2]) if row[2] else [],
                        "abstract": row[3] or "",
                        "year": row[4] or 0,
                        "venue": row[5] or "",
                        "doi": row[6] or "",
                        "arxiv_id": row[7] or "",
                        "url": row[8] or "",
                        "citations": row[9] or 0,
                        "keywords": json.loads(row[10]) if row[10] else [],
                        "database_source": row[11] or "",
                        "pdf_url": row[12] or "",
                        "publication_type": row[13] or "",
                        "issue": row[14] or "",
                        "volume": row[15] or "",
                        "pages": row[16] or "",
                        "publisher": row[17] or "",
                    }
                    papers.append(Paper.from_dict(paper_data))

                return papers
        except Exception as e:
            self.logger.error(f"Failed to get cached search: {e}")
            return None

get_cache_stats

get_cache_stats() -> Dict[str, Any]

Get cache statistics.

Source code in ures/literature/search/paper.py
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
    def get_cache_stats(self) -> Dict[str, Any]:
        """Get cache statistics."""
        try:
            with sqlite3.connect(self.db_path) as conn:
                stats = {}

                # Paper stats
                cursor = conn.execute("SELECT COUNT(*) FROM papers")
                stats["total_papers"] = cursor.fetchone()[0]

                cursor = conn.execute(
                    "SELECT COUNT(DISTINCT database_source) FROM papers"
                )
                stats["unique_sources"] = cursor.fetchone()[0]

                cursor = conn.execute(
                    "SELECT database_source, COUNT(*) FROM papers GROUP BY database_source"
                )
                stats["papers_by_source"] = dict(cursor.fetchall())

                # Search stats
                cursor = conn.execute("SELECT COUNT(*) FROM searches")
                stats["total_searches"] = cursor.fetchone()[0]

                cursor = conn.execute(
                    """
                                      SELECT COUNT(*)
                                      FROM searches
                                      WHERE searched_at > datetime('now', '-24 hours')
				                      """
                )
                stats["recent_searches"] = cursor.fetchone()[0]

                # Year distribution
                cursor = conn.execute(
                    """
                                      SELECT year, COUNT (*)
                                      FROM papers
                                      WHERE year > 0
                                      GROUP BY year
                                      ORDER BY year DESC
                                          LIMIT 10
				                      """
                )
                stats["recent_years"] = dict(cursor.fetchall())

                return stats
        except Exception as e:
            self.logger.error(f"Failed to get cache stats: {e}")
            return {}

cleanup_cache

cleanup_cache(days_old: int = 30) -> bool

Clean up old cache entries.

Parameters:

  • days_old (int, default: 30 ) –

    Remove entries older than this many days

Returns:

  • bool ( bool ) –

    Success status

Source code in ures/literature/search/paper.py
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
def cleanup_cache(self, days_old: int = 30) -> bool:
    """
    Clean up old cache entries.

    Args:
            days_old: Remove entries older than this many days

    Returns:
            bool: Success status
    """
    try:
        with sqlite3.connect(self.db_path) as conn:
            # Remove old searches (cascade will remove search_results)
            cursor = conn.execute(
                """
                DELETE FROM searches
                WHERE searched_at < datetime('now', '-{} days')
            """.format(
                    days_old
                )
            )

            searches_removed = cursor.rowcount

            # Remove orphaned papers (not referenced by any recent search)
            cursor = conn.execute(
                """
                DELETE FROM papers
                WHERE id NOT IN (
                    SELECT DISTINCT sr.paper_id
                    FROM search_results sr
                    JOIN searches s ON sr.search_id = s.id
                    WHERE s.searched_at > datetime('now', '-{} days')
                )
                AND cached_at < datetime('now', '-{} days')
            """.format(
                    days_old, days_old
                )
            )

            papers_removed = cursor.rowcount

            # Vacuum database to reclaim space
            conn.execute("VACUUM")

            self.logger.info(
                f"Cache cleanup: removed {searches_removed} searches, {papers_removed} papers"
            )
            return True
    except Exception as e:
        self.logger.error(f"Failed to cleanup cache: {e}")
        return False

find_duplicates

find_duplicates(similarity_threshold: float = 0.8) -> List[List[Paper]]

Find potential duplicate papers in cache.

Parameters:

  • similarity_threshold (float, default: 0.8 ) –

    Minimum similarity score to consider duplicates

Returns:

  • List[List[Paper]] –

    List[List[Paper]]: Groups of similar papers

Source code in ures/literature/search/paper.py
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
def find_duplicates(self, similarity_threshold: float = 0.8) -> List[List[Paper]]:
    """
    Find potential duplicate papers in cache.

    Args:
            similarity_threshold: Minimum similarity score to consider duplicates

    Returns:
            List[List[Paper]]: Groups of similar papers
    """
    try:
        papers = self.get_cached_papers()
        duplicates = []
        processed = set()

        for i, paper1 in enumerate(papers):
            if i in processed:
                continue

            similar_group = [paper1]
            for j, paper2 in enumerate(papers[i + 1 :], i + 1):
                if j in processed:
                    continue

                similarity = paper1.similarity_score(paper2)
                if similarity >= similarity_threshold:
                    similar_group.append(paper2)
                    processed.add(j)

            if len(similar_group) > 1:
                duplicates.append(similar_group)

            processed.add(i)

        return duplicates
    except Exception as e:
        self.logger.error(f"Failed to find duplicates: {e}")
        return []

export_papers

export_papers(format: str = 'json', filename: str = None) -> Optional[str]

Export all cached papers to file.

Parameters:

  • format (str, default: 'json' ) –

    Export format ('json', 'csv')

  • filename (str, default: None ) –

    Output filename

Returns:

  • Optional[str] –

    Optional[str]: Filename if successful

Source code in ures/literature/search/paper.py
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
def export_papers(
    self, format: str = "json", filename: str = None
) -> Optional[str]:
    """
    Export all cached papers to file.

    Args:
            format: Export format ('json', 'csv')
            filename: Output filename

    Returns:
            Optional[str]: Filename if successful
    """
    try:
        papers = self.get_cached_papers()

        if not filename:
            timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
            filename = f"cached_papers_{timestamp}.{format}"

        if format == "json":
            data = [paper.to_dict() for paper in papers]
            with open(filename, "w", encoding="utf-8") as f:
                json.dump(data, f, indent=2, ensure_ascii=False)

        elif format == "csv":
            import csv

            if papers:
                with open(filename, "w", newline="", encoding="utf-8") as f:
                    fieldnames = [
                        "title",
                        "authors",
                        "year",
                        "venue",
                        "abstract",
                        "doi",
                        "url",
                        "citations",
                        "database_source",
                        "publication_type",
                    ]
                    writer = csv.DictWriter(f, fieldnames=fieldnames)
                    writer.writeheader()

                    for paper in papers:
                        writer.writerow(
                            {
                                "title": paper.title,
                                "authors": "; ".join(paper.authors),
                                "year": paper.year,
                                "venue": paper.venue,
                                "abstract": paper.abstract,
                                "doi": paper.doi,
                                "url": paper.url,
                                "citations": paper.citations,
                                "database_source": paper.database_source,
                                "publication_type": paper.publication_type,
                            }
                        )
        else:
            raise ValueError(f"Unsupported format: {format}")

        return filename
    except Exception as e:
        self.logger.error(f"Failed to export papers: {e}")
        return None

PaperFormatter

Unified formatter for normalizing papers from different database sources.

format_arxiv_paper staticmethod

format_arxiv_paper(entry_data: Dict) -> Paper

Format arXiv entry data into standardized Paper object.

Source code in ures/literature/search/paper.py
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
@staticmethod
def format_arxiv_paper(entry_data: Dict) -> Paper:
    """Format arXiv entry data into standardized Paper object."""
    title = entry_data.get("title", "").strip().replace("\n", " ")
    title = re.sub(r"\s+", " ", title)

    authors = []
    for author in entry_data.get("authors", []):
        if isinstance(author, dict):
            name = author.get("name", "")
        else:
            name = str(author)
        if name.strip():
            authors.append(name.strip())

    abstract = entry_data.get("summary", "").strip().replace("\n", " ")
    abstract = re.sub(r"\s+", " ", abstract)

    arxiv_id = entry_data.get("id", "").split("/")[-1]
    year = PaperFormatter._extract_arxiv_year(arxiv_id)

    keywords = []
    categories = entry_data.get("categories", [])
    if isinstance(categories, str):
        keywords = [categories]
    elif isinstance(categories, list):
        keywords = categories

    return Paper(
        title=title,
        authors=authors,
        abstract=abstract,
        year=year,
        venue="arXiv",
        arxiv_id=arxiv_id,
        url=entry_data.get("id", ""),
        keywords=keywords,
        database_source="arxiv",
        pdf_url=entry_data.get("pdf_url", ""),
        publication_type="preprint",
    )

format_ieee_paper staticmethod

format_ieee_paper(entry_data: Dict) -> Paper

Format IEEE entry data into standardized Paper object.

Source code in ures/literature/search/paper.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
@staticmethod
def format_ieee_paper(entry_data: Dict) -> Paper:
    """Format IEEE entry data into standardized Paper object."""
    title = entry_data.get("title", "")

    authors = []
    if "authors" in entry_data:
        if isinstance(entry_data["authors"], list):
            authors = [
                author.get("full_name", "") for author in entry_data["authors"]
            ]
        elif isinstance(entry_data["authors"], dict):
            authors = [entry_data["authors"].get("full_name", "")]

    return Paper(
        title=title,
        authors=authors,
        abstract=entry_data.get("abstract", ""),
        year=int(entry_data.get("publication_year", 0)),
        venue=entry_data.get("publication_title", ""),
        doi=entry_data.get("doi", ""),
        url=entry_data.get("pdf_url", ""),
        citations=int(entry_data.get("citing_paper_count", 0)),
        database_source="ieee",
        pdf_url=entry_data.get("pdf_url", ""),
        publication_type="article",
        volume=entry_data.get("volume", ""),
        issue=entry_data.get("issue", ""),
        pages=PaperFormatter._format_pages(
            entry_data.get("start_page", ""), entry_data.get("end_page", "")
        ),
        publisher="IEEE",
    )

format_elsevier_paper staticmethod

format_elsevier_paper(entry_data: Dict) -> Paper

Format Elsevier/ScienceDirect entry data.

Source code in ures/literature/search/paper.py
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
@staticmethod
def format_elsevier_paper(entry_data: Dict) -> Paper:
    """Format Elsevier/ScienceDirect entry data."""
    title = entry_data.get("dc:title", "")

    authors = []
    if "authors" in entry_data and "author" in entry_data["authors"]:
        author_list = entry_data["authors"]["author"]
        if isinstance(author_list, list):
            for author in author_list:
                if isinstance(author, dict):
                    given = author.get("ce:given-name", "")
                    surname = author.get("ce:surname", "")
                    full_name = f"{given} {surname}".strip()
                    if full_name:
                        authors.append(full_name)

    return Paper(
        title=title,
        authors=authors,
        abstract=entry_data.get("dc:description", ""),
        year=(
            int(entry_data.get("prism:coverDate", "").split("-")[0])
            if entry_data.get("prism:coverDate")
            else 0
        ),
        venue=entry_data.get("prism:publicationName", ""),
        doi=entry_data.get("prism:doi", ""),
        url=(
            entry_data.get("link", [{}])[0].get("@href", "")
            if entry_data.get("link")
            else ""
        ),
        database_source="elsevier",
        publication_type="article",
        volume=entry_data.get("prism:volume", ""),
        issue=entry_data.get("prism:issueIdentifier", ""),
        pages=entry_data.get("prism:pageRange", ""),
        publisher="Elsevier",
    )

format_springer_paper staticmethod

format_springer_paper(entry_data: Dict) -> Paper

Format Springer entry data.

Source code in ures/literature/search/paper.py
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
@staticmethod
def format_springer_paper(entry_data: Dict) -> Paper:
    """Format Springer entry data."""
    title = entry_data.get("title", "")

    authors = []
    if "creators" in entry_data:
        for creator in entry_data["creators"]:
            if isinstance(creator, dict):
                name = creator.get("creator", "")
            else:
                name = str(creator)
            if name:
                authors.append(name)

    return Paper(
        title=title,
        authors=authors,
        abstract=entry_data.get("abstract", ""),
        year=(
            int(entry_data.get("publicationDate", "").split("-")[0])
            if entry_data.get("publicationDate")
            else 0
        ),
        venue=entry_data.get("publicationName", ""),
        doi=entry_data.get("doi", ""),
        url=(
            entry_data.get("url", [{}])[0].get("value", "")
            if entry_data.get("url")
            else ""
        ),
        database_source="springer",
        publication_type=entry_data.get("contentType", "article").lower(),
        publisher="Springer",
    )

format_wiley_paper staticmethod

format_wiley_paper(entry_data: Dict) -> Paper

Format Wiley entry data.

Source code in ures/literature/search/paper.py
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
@staticmethod
def format_wiley_paper(entry_data: Dict) -> Paper:
    """Format Wiley entry data."""
    return Paper(
        title=entry_data.get("title", ""),
        authors=entry_data.get("authors", []),
        abstract=entry_data.get("abstract", ""),
        year=int(entry_data.get("publicationYear", 0)),
        venue=entry_data.get("source", ""),
        doi=entry_data.get("doi", ""),
        url=entry_data.get("onlineLibraryUrl", ""),
        database_source="wiley",
        publication_type="article",
        publisher="Wiley",
    )