Spaces:
Running
Running
File size: 1,087 Bytes
613c93d |
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 |
import urllib
import pandas as pd
from pydantic import BaseModel
class Chapter(BaseModel):
book_name: str
chapter_num: int
verses_df: pd.DataFrame
highlight_verses_df: pd.DataFrame
class Config:
arbitrary_types_allowed = True
def __str__(self) -> str:
return f"{self.book_name} {self.chapter_num}"
def get_formatted_text(self):
# Construct chapter text
texts = []
for _, row in self.verses_df.iterrows():
text = row["text"]
if text in self.highlight_verses_df["text"].tolist():
text = f"**:green[{text}]**"
text = f"<sup>{row['verse']}</sup> {text}"
texts.append(text)
chapter_text = " ".join(texts)
return chapter_text
def get_biblegateway_url(self, version="NIV"):
return f"https://www.biblegateway.com/passage/?search={urllib.parse.quote(self.book_name)}+{self.chapter_num}&version={version}"
def get_num_unique_highlight_verse(self):
return len(self.highlight_verses_df.drop_duplicates(subset="text"))
|