-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Scaffold for oo-self linking * fix: python 3.8 compatg * fix: add dep
- Loading branch information
1 parent
c546e80
commit fa7c5e2
Showing
11 changed files
with
327 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from ..scholar import get_citations_from_title | ||
from .core import self_references, self_references_paper | ||
from .self_references import self_references, self_references_paper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .paper import Paper | ||
from .researcher import Researcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from abc import abstractmethod | ||
from typing import Dict | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class EntityResult(BaseModel): | ||
num_citations: int | ||
num_references: int | ||
# keys are authors or papers and values are absolute self links | ||
self_citations: Dict[str, int] = {} | ||
self_references: Dict[str, int] = {} | ||
# aggregated results | ||
self_citation_ratio: float = 0 | ||
self_reference_ratio: float = 0 | ||
|
||
|
||
class Entity: | ||
""" | ||
An abstract entity class with a set of utilities shared by the objects that perform | ||
self-linking analyses, such as Paper and Researcher. | ||
""" | ||
|
||
@abstractmethod | ||
def self_references(self): | ||
""" | ||
Has to be implemented by the child class. Performs a self-referencing analyses | ||
for the object. | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
def self_citations(self): | ||
""" | ||
Has to be implemented by the child class. Performs a self-citation analyses | ||
for the object. | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
def get_result(self): | ||
""" | ||
Has to be implemented by the child class. Provides the result of the analysis. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from typing import List | ||
|
||
from ..self_references import self_references_paper | ||
from .core import Entity, EntityResult | ||
|
||
|
||
class PaperResult(EntityResult): | ||
title: str | ||
doi: str | ||
authors: List[str] | ||
# TODO: the ratios will be averaged across all authors | ||
|
||
|
||
class Paper(Entity): | ||
title: str | ||
doi: str | ||
authors: List[str] | ||
|
||
def __init__(self, input: str, mode): | ||
# Determine whether | ||
... | ||
|
||
def self_references(self): | ||
""" | ||
Extracts the self references of a paper, for each author. | ||
""" | ||
... | ||
|
||
def self_citations(self): | ||
""" | ||
Extracts the self citations of a paper, for each author. | ||
""" | ||
... | ||
|
||
def get_result(self) -> PaperResult: | ||
""" | ||
Provides the result of the analysis. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import Literal, Optional | ||
|
||
from semanticscholar import SemanticScholar | ||
|
||
from .core import Entity, EntityResult | ||
|
||
|
||
class ResearcherResult(EntityResult): | ||
name: str | ||
ssid: int | ||
orcid: Optional[str] = None | ||
# TODO: the ratios will be averaged across all papers for that author | ||
|
||
|
||
ModeType = Literal[tuple(MODES := ("doi", "name", "orcid", "ssid"))] | ||
|
||
sch = SemanticScholar() | ||
|
||
|
||
class Researcher(Entity): | ||
name: str | ||
ssid: int | ||
orcid: Optional[str] = None | ||
|
||
def __init__(self, input: str, mode: ModeType): | ||
if mode not in MODES: | ||
raise ValueError(f"Unknown mode {mode} chose from {MODES}.") | ||
|
||
if mode == "ssid": | ||
author = sch.get_author(input) | ||
|
||
def self_references(self): | ||
""" | ||
Sifts through all papers of a researcher and extracts the self references. | ||
""" | ||
... | ||
|
||
def self_citations(self): | ||
""" | ||
Sifts through all papers of a researcher and finds how often they are self-cited. | ||
""" | ||
... | ||
|
||
def get_result(self) -> ResearcherResult: | ||
""" | ||
Provides the result of the analysis. | ||
""" | ||
... |
Empty file.
Oops, something went wrong.