Skip to content

Commit

Permalink
moved code around to fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
AntounMichael committed Nov 12, 2023
1 parent dbe4cf5 commit b567551
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions VectorDatabase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
import psycopg2
from database_entities import Fragment, Publication


# Class to represent a publication with attributes id, title, pmc, pubmed, and doi
class Publication:
id = ""
title = ""
pmc = ""
pubmed = ""
doi = ""

def __init__(self, id, title, pmc, pubmed, doi):
self.id = id # (DOI) Unique identifier for the publication
self.title = title # Title of the publication
self.pmc = pmc # PubMed Central (PMC) Link
self.pubmed = pubmed # PubMed Link
self.doi = doi # Digital Object Identifier (DOI) Link for the publication


# Class to represent a fragment of a publication with attributes id, header, content, and vector
class Fragment:
# Class variables to store default values for attributes
id = ""
header = ""
content = ""
vector = ""

def __init__(self, id, header, content, vector):
# Constructor to initialize the attributes of the Fragment object

# Set the attributes of the object with the values provided during instantiation
self.id = id # (DOI) Unique identifier for the fragment
self.header = header # Header or title of the fragment
self.content = content # Content or text of the fragment
self.vector = vector # Vector representation of the fragment


# Lantern class that exposes functionality of database to application
class Lantern:
Expand Down Expand Up @@ -249,7 +283,7 @@ def getUnreadPublications(self, delete_unread_entries=True):

if delete_unread_entries:
cursor.execute('DELETE FROM unread;')

conn.commit()
cursor.close()

Expand Down Expand Up @@ -292,49 +326,15 @@ def publicationExists(self, id):
- [(text, embedding)] content of a publication's embeddings
Notes:
"""

def get_embeddings_for_pub(self, id):
texts = []
embeddings = []
if not self.publicationExists(id):
return
return
fragments = self.getAllFragmentsOfPublication(id)
for fragment in fragments:
texts.append(fragment.content)
embeddings.append(fragment.vector)
text_embeddings = list(zip(texts, embeddings))
return text_embeddings

# Class to represent a publication with attributes id, title, pmc, pubmed, and doi
class Publication:

id = ""
title = ""
pmc = ""
pubmed = ""
doi = ""

def __init__(self, id, title, pmc, pubmed, doi):
self.id = id # (DOI) Unique identifier for the publication
self.title = title # Title of the publication
self.pmc = pmc # PubMed Central (PMC) Link
self.pubmed = pubmed # PubMed Link
self.doi = doi # Digital Object Identifier (DOI) Link for the publication

# Class to represent a fragment of a publication with attributes id, header, content, and vector
class Fragment:


# Class variables to store default values for attributes
id = ""
header = ""
content = ""
vector = ""

def __init__(self, id, header, content, vector):
# Constructor to initialize the attributes of the Fragment object

# Set the attributes of the object with the values provided during instantiation
self.id = id # (DOI) Unique identifier for the fragment
self.header = header # Header or title of the fragment
self.content = content # Content or text of the fragment
self.vector = vector # Vector representation of the fragment

0 comments on commit b567551

Please sign in to comment.