Spaces:
Sleeping
Sleeping
Refactor faculty scraping functionality and add new scrapers for various departments. Update main.py to comment out sum calculations and chart plotting. Introduce profile_to_vector_database notebook for faculty data processing. Remove simple.ipynb as it is no longer needed.
Browse files- main.py +11 -9
- profile_to_vector_database.ipynb +533 -0
- simple.ipynb +0 -0
- src/{GSBS_faculty_scraper.py → scraper/GSBS_faculty_scraper.py} +1 -2
- src/{faculty_scraper.py → scraper/faculty_scraper.py} +7 -7
- src/{profile_scraper.py → scraper/profile_scraper.py} +0 -0
- src/{sbmi_faculty_scraper.py → scraper/sbmi_faculty_scraper.py} +72 -134
- src/{sph_faculty_scraper.py → scraper/sph_faculty_scraper.py} +4 -7
- src/summarize.py +16 -11
main.py
CHANGED
|
@@ -15,17 +15,19 @@ df = pd.DataFrame(data)
|
|
| 15 |
|
| 16 |
df
|
| 17 |
#%%
|
| 18 |
-
# Calculate the sums
|
| 19 |
-
sum_apples = df['Apples'].sum()
|
| 20 |
-
sum_bananas = df['Bananas'].sum()
|
| 21 |
|
| 22 |
-
# Create a bar chart
|
| 23 |
-
plt.bar(['Apples', 'Bananas'], [sum_apples, sum_bananas], color=['red', 'blue'])
|
| 24 |
|
| 25 |
-
# Set a title
|
| 26 |
-
plt.title('Comparison of total Apples and Bananas')
|
| 27 |
|
| 28 |
-
# Show the plot
|
| 29 |
-
plt.show()
|
| 30 |
|
| 31 |
# See DataSpell help at https://www.jetbrains.com/help/dataspell/
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
df
|
| 17 |
#%%
|
| 18 |
+
# # Calculate the sums
|
| 19 |
+
# sum_apples = df['Apples'].sum()
|
| 20 |
+
# sum_bananas = df['Bananas'].sum()
|
| 21 |
|
| 22 |
+
# # Create a bar chart
|
| 23 |
+
# plt.bar(['Apples', 'Bananas'], [sum_apples, sum_bananas], color=['red', 'blue'])
|
| 24 |
|
| 25 |
+
# # Set a title
|
| 26 |
+
# plt.title('Comparison of total Apples and Bananas')
|
| 27 |
|
| 28 |
+
# # Show the plot
|
| 29 |
+
# plt.show()
|
| 30 |
|
| 31 |
# See DataSpell help at https://www.jetbrains.com/help/dataspell/
|
| 32 |
+
|
| 33 |
+
# %%
|
profile_to_vector_database.ipynb
ADDED
|
@@ -0,0 +1,533 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "8a77807f92f26ee",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# Jupyter notebook sample"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"cell_type": "code",
|
| 13 |
+
"execution_count": 1,
|
| 14 |
+
"id": "fc944c6d",
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"%matplotlib inline\n",
|
| 19 |
+
"%load_ext autoreload\n",
|
| 20 |
+
"%autoreload 2"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"cell_type": "code",
|
| 25 |
+
"execution_count": 2,
|
| 26 |
+
"id": "7df9140457caed5e",
|
| 27 |
+
"metadata": {
|
| 28 |
+
"ExecuteTime": {
|
| 29 |
+
"end_time": "2025-05-05T16:47:28.619918Z",
|
| 30 |
+
"start_time": "2025-05-05T16:47:28.611208Z"
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"outputs": [],
|
| 34 |
+
"source": [
|
| 35 |
+
"# imports\n",
|
| 36 |
+
"\n",
|
| 37 |
+
"import os\n",
|
| 38 |
+
"from tqdm import tqdm\n",
|
| 39 |
+
"from dotenv import load_dotenv\n",
|
| 40 |
+
"from huggingface_hub import login\n",
|
| 41 |
+
"from datasets import load_dataset\n",
|
| 42 |
+
"import chromadb\n",
|
| 43 |
+
"from sklearn.manifold import TSNE\n",
|
| 44 |
+
"from openai import OpenAI\n",
|
| 45 |
+
"from langchain_openai import OpenAIEmbeddings\n"
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"cell_type": "code",
|
| 50 |
+
"execution_count": null,
|
| 51 |
+
"id": "c4c650bb",
|
| 52 |
+
"metadata": {},
|
| 53 |
+
"outputs": [],
|
| 54 |
+
"source": []
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"cell_type": "code",
|
| 58 |
+
"execution_count": 3,
|
| 59 |
+
"id": "ca866defaf4e79ba",
|
| 60 |
+
"metadata": {
|
| 61 |
+
"ExecuteTime": {
|
| 62 |
+
"end_time": "2025-05-05T16:44:41.846756Z",
|
| 63 |
+
"start_time": "2025-05-05T16:44:41.841991Z"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"outputs": [],
|
| 67 |
+
"source": [
|
| 68 |
+
"load_dotenv(override=True)\n",
|
| 69 |
+
"api_key = os.getenv('OPENAI_API_KEY')"
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"cell_type": "code",
|
| 74 |
+
"execution_count": 4,
|
| 75 |
+
"id": "aa576312",
|
| 76 |
+
"metadata": {},
|
| 77 |
+
"outputs": [
|
| 78 |
+
{
|
| 79 |
+
"data": {
|
| 80 |
+
"text/plain": [
|
| 81 |
+
"<src.scraper.profile_scraper.FacultyProfileScraper at 0x1b95fcc50>"
|
| 82 |
+
]
|
| 83 |
+
},
|
| 84 |
+
"execution_count": 4,
|
| 85 |
+
"metadata": {},
|
| 86 |
+
"output_type": "execute_result"
|
| 87 |
+
}
|
| 88 |
+
],
|
| 89 |
+
"source": [
|
| 90 |
+
"import src.scraper.profile_scraper as profile_scraper\n",
|
| 91 |
+
"faculty = profile_scraper.FacultyProfileScraper(\"https://sph.uth.edu/faculty/?fac=O5VHhdEYnwuzkAQcMguuOA==\")\n",
|
| 92 |
+
"faculty"
|
| 93 |
+
]
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"cell_type": "code",
|
| 97 |
+
"execution_count": 5,
|
| 98 |
+
"id": "9378963b",
|
| 99 |
+
"metadata": {},
|
| 100 |
+
"outputs": [
|
| 101 |
+
{
|
| 102 |
+
"name": "stdout",
|
| 103 |
+
"output_type": "stream",
|
| 104 |
+
"text": [
|
| 105 |
+
"API key found and looks good so far!\n"
|
| 106 |
+
]
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"data": {
|
| 110 |
+
"text/plain": [
|
| 111 |
+
"'Sure! Here is the processed text file content based on the provided website information for the faculty member, Yunxin Fu:\\n\\n---\\n\\n**Yunxin Fu** \\nProfessor \\nBiostatistics \\n713/500-9813 \\nReuel Stallones Building \\n1200 Pressler Street, Houston, TX 77030 \\n[View CV]\\n\\n**About** \\nI was trained as a biostatistician specialized in computational biology, and have spent much of my career in developing population genetics theory and statistical methods for analyzing population samples of DNA sequences, including algorithms for simulating samples for the analysis of large scale data. Recently I have been involved in the analysis of polymorphism data from the 1000 Genomes Project and related large data sets. In addition to my continuous work on population genetics theory and evolution, my recent interests include within-individual polymorphism generated by both classical experiments and next generation sequencing for the purpose of understanding the mutational process during individual development, and population genetics of T. thermorphila.\\n\\n**Center Affiliation** \\nHuman Genetics Center\\n\\n**Research Interests** \\n- Big Data/Data Science \\n- Biostatistics \\n- Genetics and -omics \\n- Infectious Disease \\n\\n--- \\n\\nFeel free to let me know if you need any further modifications!'"
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
"execution_count": 5,
|
| 115 |
+
"metadata": {},
|
| 116 |
+
"output_type": "execute_result"
|
| 117 |
+
}
|
| 118 |
+
],
|
| 119 |
+
"source": [
|
| 120 |
+
"from src.summarize import summarize\n",
|
| 121 |
+
"summarize(faculty.text)"
|
| 122 |
+
]
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"cell_type": "code",
|
| 126 |
+
"execution_count": 6,
|
| 127 |
+
"id": "ce7fe0fa",
|
| 128 |
+
"metadata": {},
|
| 129 |
+
"outputs": [
|
| 130 |
+
{
|
| 131 |
+
"data": {
|
| 132 |
+
"text/plain": [
|
| 133 |
+
"{'image_url': 'https://web.sph.uth.edu/thumbs/addy.jpg',\n",
|
| 134 |
+
" 'name': 'Robert Addy',\n",
|
| 135 |
+
" 'profile': '<< Back\\nRobert Addy\\nFaculty Associate\\nHealth Promotion & Behavioral Sciences\\n713/500-9758\\nView CV\\nAbout\\nDr. Addy has over 25 years of research experience, including collecting, managing, and analyzing data in multiple contexts. He has served as data manager for multiple projects involving single and multiple sites, as well as cross-sectional and longitudinal community-based studies in diverse settings (e.g. children, adolescents, adults, schools, clinics, and communities) and with diverse populations, including Hispanic, African-American, American Indian and Alaska Native populations. He has extensive experience in compiling, cleaning, and processing data in preparation for analysis and distribution. He is part of a teaching team that provides graduate level classes in program evaluation and data management at UTSPH.\\nCenter Affiliation\\nCenter for Health Promotion and Prevention Research\\nResearch Interests\\nAdolescent Health\\nBiostatistics\\nHealth Education/Behavioral Sciences\\nProgram Evaluation\\nSexual Health',\n",
|
| 136 |
+
" 'profile_url': 'https://sph.uth.edu/faculty/?fac=RxApW409EWwpnikiXFRn8g=='}"
|
| 137 |
+
]
|
| 138 |
+
},
|
| 139 |
+
"execution_count": 6,
|
| 140 |
+
"metadata": {},
|
| 141 |
+
"output_type": "execute_result"
|
| 142 |
+
}
|
| 143 |
+
],
|
| 144 |
+
"source": [
|
| 145 |
+
"# load json into python dictionary\n",
|
| 146 |
+
"import json \n",
|
| 147 |
+
"input_files = ['data/sph_faculty_list.jsonl', \n",
|
| 148 |
+
" 'data/gsbs_faculty_list.jsonl', \n",
|
| 149 |
+
" 'data/sbmi_faculty_list.jsonl']\n",
|
| 150 |
+
"faculty_list = []\n",
|
| 151 |
+
"for input_file in input_files:\n",
|
| 152 |
+
" with open(input_file, 'r', encoding='utf-8') as f:\n",
|
| 153 |
+
" for line in f:\n",
|
| 154 |
+
" faculty_list.append(json.loads(line.strip()))\n",
|
| 155 |
+
"\n",
|
| 156 |
+
"len(faculty_list)\n",
|
| 157 |
+
"faculty_list[0]"
|
| 158 |
+
]
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"cell_type": "markdown",
|
| 162 |
+
"id": "26d52ec1",
|
| 163 |
+
"metadata": {},
|
| 164 |
+
"source": []
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"cell_type": "code",
|
| 168 |
+
"execution_count": 7,
|
| 169 |
+
"id": "1b5eb8bb",
|
| 170 |
+
"metadata": {},
|
| 171 |
+
"outputs": [],
|
| 172 |
+
"source": [
|
| 173 |
+
"# vectorize the faculty documents\n",
|
| 174 |
+
"# vectorizer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')\n",
|
| 175 |
+
"vectorizer = OpenAIEmbeddings(model=\"text-embedding-ada-002\", \n",
|
| 176 |
+
" openai_api_key=os.getenv('OPENAI_API_KEY'))"
|
| 177 |
+
]
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"cell_type": "code",
|
| 181 |
+
"execution_count": 8,
|
| 182 |
+
"id": "6c24c978",
|
| 183 |
+
"metadata": {},
|
| 184 |
+
"outputs": [],
|
| 185 |
+
"source": [
|
| 186 |
+
"DB = \"faculties_vectorstore\""
|
| 187 |
+
]
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"cell_type": "code",
|
| 191 |
+
"execution_count": 9,
|
| 192 |
+
"id": "163fcada",
|
| 193 |
+
"metadata": {},
|
| 194 |
+
"outputs": [],
|
| 195 |
+
"source": [
|
| 196 |
+
"client = chromadb.PersistentClient(path=DB)"
|
| 197 |
+
]
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"cell_type": "code",
|
| 201 |
+
"execution_count": 10,
|
| 202 |
+
"id": "e5cffaf8",
|
| 203 |
+
"metadata": {},
|
| 204 |
+
"outputs": [],
|
| 205 |
+
"source": [
|
| 206 |
+
"# Check if the collection exists and delete it if it does\n",
|
| 207 |
+
"collection_name = \"faculties\"\n",
|
| 208 |
+
"\n",
|
| 209 |
+
"# For old versions of Chroma, use this line instead of the subsequent one\n",
|
| 210 |
+
"# existing_collection_names = [collection.name for collection in client.list_collections()]\n",
|
| 211 |
+
"existing_collection_names = client.list_collections()\n",
|
| 212 |
+
"\n",
|
| 213 |
+
"# if collection_name in [c.name for c in existing_collection_names]:\n",
|
| 214 |
+
"# client.delete_collection(collection_name)\n",
|
| 215 |
+
"# print(f\"Deleted existing collection: {collection_name}\")\n",
|
| 216 |
+
" \n",
|
| 217 |
+
"# collection = client.create_collection(collection_name)"
|
| 218 |
+
]
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"cell_type": "code",
|
| 222 |
+
"execution_count": 11,
|
| 223 |
+
"id": "8e835462",
|
| 224 |
+
"metadata": {},
|
| 225 |
+
"outputs": [],
|
| 226 |
+
"source": [
|
| 227 |
+
"# # Uncomment if you'd rather not wait for the full 400,000\n",
|
| 228 |
+
"# # NUMBER_OF_DOCUMENTS = 20000\n",
|
| 229 |
+
"# # vectors = vectorizer.encode(faculty_documents).astype(float).tolist()\n",
|
| 230 |
+
"# faculty_profile = []\n",
|
| 231 |
+
"# for faculty in faculty_list:\n",
|
| 232 |
+
"# faculty_profile.append(faculty['profile'])\n",
|
| 233 |
+
"# vectors = vectorizer.embed_documents(faculty_profile)\n",
|
| 234 |
+
"# # metadata is everything except the about field\n",
|
| 235 |
+
"# metadatas = [{\"name\": faculty['name'], 'url': faculty['profile_url']} for faculty in faculty_list]\n",
|
| 236 |
+
"# ids = [f\"doc_{j}\" for j in range(len(faculty_profile))]\n",
|
| 237 |
+
"# collection.add(\n",
|
| 238 |
+
"# ids=ids,\n",
|
| 239 |
+
"# documents=faculty_profile,\n",
|
| 240 |
+
"# embeddings=vectors,\n",
|
| 241 |
+
"# metadatas=metadatas\n",
|
| 242 |
+
"# )"
|
| 243 |
+
]
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"cell_type": "code",
|
| 247 |
+
"execution_count": 12,
|
| 248 |
+
"id": "8636a3a3",
|
| 249 |
+
"metadata": {},
|
| 250 |
+
"outputs": [],
|
| 251 |
+
"source": [
|
| 252 |
+
"collection = client.get_or_create_collection('faculties')"
|
| 253 |
+
]
|
| 254 |
+
},
|
| 255 |
+
{
|
| 256 |
+
"cell_type": "code",
|
| 257 |
+
"execution_count": 13,
|
| 258 |
+
"id": "7132cf50",
|
| 259 |
+
"metadata": {},
|
| 260 |
+
"outputs": [],
|
| 261 |
+
"source": [
|
| 262 |
+
"result = collection.get(include=['embeddings', 'documents', 'metadatas'])"
|
| 263 |
+
]
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"cell_type": "code",
|
| 267 |
+
"execution_count": 14,
|
| 268 |
+
"id": "ef088dc7",
|
| 269 |
+
"metadata": {},
|
| 270 |
+
"outputs": [],
|
| 271 |
+
"source": [
|
| 272 |
+
"def find_similars(description):\n",
|
| 273 |
+
" results = collection.query(query_embeddings=vectorizer.embed_query(description), n_results=10)\n",
|
| 274 |
+
" documents = results['documents'][0][:]\n",
|
| 275 |
+
" name = [m['name'] for m in results['metadatas'][0][:]]\n",
|
| 276 |
+
" link = [m['url'] for m in results['metadatas'][0][:]]\n",
|
| 277 |
+
" return documents, name, link"
|
| 278 |
+
]
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"cell_type": "code",
|
| 282 |
+
"execution_count": 15,
|
| 283 |
+
"id": "925c3625",
|
| 284 |
+
"metadata": {},
|
| 285 |
+
"outputs": [
|
| 286 |
+
{
|
| 287 |
+
"data": {
|
| 288 |
+
"text/plain": [
|
| 289 |
+
"(['<< Back\\nElena Feofanova\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9827\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nResearch Interests\\nEpidemiology',\n",
|
| 290 |
+
" '<< Back\\nEric Jones\\nAssociate Professor\\nEpidemiology\\n915/975-8528\\nMCA Medical Center of the Americas Foundation\\n5130 Gateway East Blvd. MCA 308\\nView CV\\nAbout\\nAs a social epidemiologist, I conduct research on social aspects of wellbeing. A major focus of my studies is on human behavior and wellbeing in extreme circumstances (like disasters, warfare. Migration, cancer), focusing on the role of relationships in stress, depression, anxiety, and functioning. My broad interest in collective action and social support, often using social network analysis, has also led me recently to study health care coordination, drug and violence prevention coalitions, informal and formal science education, and interorganizational dynamics. I continue to be involved in creating and maintaining online and desktop social network analysis software Most of my research takes place in Mexico, Ecuador, and the United States.\\nMajor Research Programs\\n* Comparative Disaster Recovery - Variation in how individuals and families recover from disasters (Ecuador, Mexico, US, involving over 10 disasters).\\n* Hazards and Cultural Transformations - Variation in how leaders and their subjects have dealt with disasters in 98 societies around the world in the past 200 years, including sharing, land tenure, ideology, economics, politics, rules/restrictions, etc.\\n* Cultural Models of Nature – Variation in the way different cultural groups understand their relationships to the biophysical environment and changes in weather affecting their food production (Ecuador, with colleague sites in 12+ other countries).\\nCenter Affiliation\\nCenter for Health Promotion and Prevention Research\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nEpidemiology\\nGlobal Health\\nHealth Equity\\nSocial Determinants of Health\\nPersonal Links\\nhttp://tmc.academia.edu/EricJones\\nhttps://www.researchgate.net/profile/Eric_Jones14',\n",
|
| 291 |
+
" '<< Back\\nSusan Fisher-Hoch\\nProfessor Non-Tenure Research\\nEpidemiology\\n956/755-0635\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nI am trained as a physician with a doctoral degree in epidemiology from London University with Membership of the Royal College of Pathology in virology. After a long career at the Centers for Disease Control and Prevention working with viral hemorrhagic fevers, in poor communities in developing countries. I designed and directed the French Biosafety 4 Level principally for studies of Ebola and Lassa fever for which I received the Légion d’Honneur. I joined the Brownsville campus of the School of Public Health to work in health disparity population health in 2001. In 2004 I helped found the Cameron County Hispanic Cohort (n=5000) which I direct. This is a randomly selected community based cohort of health disparity Mexican Americans. Using these data I have collaborative programs in diabetes, cardiovascular disease and cancers understudied minorities with a wide range of collaborators from major institutions across the country, funded by several NIH and CPRIT grants, and having produced more than 60 publications. I teach international epidemic investigation course on line based on real life outbreaks.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nInfectious Disease\\nPersonal Links\\nhttps://sph.uth.edu/research/centers/hispanic-health/about.htm',\n",
|
| 292 |
+
" '<< Back\\nLu-Yu Hwang\\nProfessor Non-Tenure Instruction\\nEpidemiology\\n713/500-9382\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nPediatrics; infectious disease; perinatal transmission; viral epidemiology; cancer epidemiology; hepatitis virus/liver cancer; HIV/AIDS, HTLV/leukemia; EBV/nasopharyngeal cancer; viral oncology.',\n",
|
| 293 |
+
" 'Fuqing Wu\\nRegular Member\\nAssistant Professor\\n713-500-9319\\n713-500-9319\\n[email\\xa0protected]\\nRAS - E703\\nThe University of Texas\\xa0 Health Science Center at Houston\\nDepartment of Environmental and Occupational Health Sciences\\nInfectious viral diseases remain one of the leading causes of mortality worldwide. Our group focuses on developing innovative environmental and genomic surveillance systems to understand population health and monitor the spread of infectious diseases. Using molecular virology, genomic sequencing, and mathematical modeling, our research works advance wastewater-based surveillance to track zoonotic pathogens, analyze the evolution of genomic variants, and forecast infection transmission dynamics. By integrating these tools, we aim to create early-warning systems for viral outbreaks and uncover key insights into pathogenic agents’ transmission and public health.\\nCurrent projects in my lab include:\\nWastewater-based Epidemiology: Developing methodologies for detecting pathogenic agents in community wastewater, capturing infection trends over time and space, and integrating surveillance data with mathematical models to predict outbreak dynamics and track viral evolution.\\nViral Metagenomics and Discovery: Employing cutting-edge metagenomic sequencing to explore human viral diversity, with the ultimate goal of creating a comprehensive global map of human viruses.\\nMicrobiome and Medicine: Investigating the interactions between viral infections, antiviral treatments, and the gut microbiome. Questions include how antibiotics affect gut microbiota and how everyday medications alter the microbiome.\\nStudents participating in tutorials/research in our lab will gain hands-on experience in molecular biology, genomic sequencing, bioinformatics, and mathematical modeling.\\nPubMed\\nMcGovern Medical School Faculty\\nEducation & Training\\nPh.D. - University of Arizona, 2017\\nResearch Opportunities\\nSeeking MS Students\\nSeeking PhD Students\\nPrograms\\nMicrobiology and Infectious Diseases\\nFaculty Development\\nMentoring Works\\nBack',\n",
|
| 294 |
+
" '<< Back\\nHeather Essigmann\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9280\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV',\n",
|
| 295 |
+
" 'Paul Scheet\\nRegular Member\\nProfessor\\n713.745.2470\\n713.745.2470\\n[email\\xa0protected]\\nMDA CPB4.3301 (Unit 1340)\\nThe University of Texas\\xa0MD Anderson Cancer Center\\nDepartment of Epidemiology\\nMy main research involves the development of statistical methods for the analysis of population genetic data. Specifically, I work with models for linkage disequilibrium (LD), and develop applications for taking proper account of the dependence among nearby loci. These applications include haplotype inference, missing genotype imputation, disease mapping, genotype error detection and correction, the visualization of haplotype variation, and the integration of emerging data types such as next generation DNA sequencing. For these applications I maintain a widely-used software package called fastPHASE.\\nA rotation in my lab could provide a student with exposure to several state-of-the-art haplotype-based software packages (such as PHASE, fastPHASE, Beagle, and Mach) and, in the process, could help evaluate different models for LD for various applications and settings. These models rely on hidden Markov model (HMM) techniques and implicitly a student would gain some introduction to these as well as algorithms, such as Baum-Welch, Markov chain Monte Carlo and Expectation-Maximization. In addition, the student could perform hands-on data analyses and would gain experience in working with Perl and the statistical software R. A student with strong C programming skills could develop, test, and add a function for analysis to an existing software package.\\nThe Department of Epidemiology has space for students and postdocs and provides a rich academic atmosphere with a large number of faculty in the section of Computational Genetic Epidemiology. Ample computational support exists, including processors which support programs for genetic analysis, as well as standard programming and database management languages.\\nPubMed\\nMDACC Faculty\\nEducation & Training\\nPh.D. - University of Washington - 2006\\nPrograms\\nGenetics and Epigenetics\\nQuantitative Sciences\\nFaculty Development\\nMentoring Works\\nBack',\n",
|
| 296 |
+
" '<< Back\\nCharles Darkoh\\nProfessor and R. Palmer Beasley, M.D. & Lu-Yu Hwang, M.D. Chair\\nEpidemiology\\n713/500-9368\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nAbout\\nMy laboratory focuses on the epidemiology, pathogenesis, and molecular basis of enteric infectious diseases with the goal to identify and understand mechanisms of action of novel bacterial virulence factors, pathways, and unique microbial products that can be harnessed for diagnostics and therapeutics. My long-term research interests include investigating the role of small molecules and other metabolites produced by the gut microbiota in the pathogenesis of enteric infectious diseases, mechanisms of host-pathogen interactions, antimicrobial resistance, host genetics and susceptibility to bacterial infections, and global health. I have active lines of research on Clostridium (Clostridioides) difficile infections, drug discovery, diagnostics, antimicrobial resistance, and global health.\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nEpidemiology\\nGenetics and -omics\\nGlobal Health\\nInfectious Disease',\n",
|
| 297 |
+
" '<< Back\\nJoseph McCormick\\nProfessor & James H. Steele, D.V.M. Professorship\\nEpidemiology\\n956/755-0605\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nRaised on a farm in Indiana, I graduated from Florida Southern College in chemistry and mathematics and attended the Free University in Brussels in preparation for teaching sciences and mathematics in French in the Congo where I was also introduced to medicine. I obtained my MD at Duke in 1971 and an MS from Harvard (1970) under Dr. Weller (Nobel Laureate 1954). I trained at CHOP under Dr. Koop (later US Surgeon General). I joined the CDC EIS and worked in Brazil as a PAHO/CDC consultant for the meningitis outbreaks of 1974-6. In 1977 I founded the CDC Lassa fever project in Sierra Leone. I investigated the first Ebola epidemic in 1976 and led the one in 1979. In Sierra Leone I conducted definitive studies of the epidemiology and antiviral treatment of Lassa fever. As Chief, Special Pathogens Branch, Viral Diseases, CDC in 1982, I ran the Biosafety level 4 lab for 9 years. I organized and led the first AIDS investigation in Africa in 1983 and established the Project SIDA in Kinshasa, Congo. In 1983 I isolated the virus that causes Hemorrhagic Fever with Renal Syndrome (Hantavirus) at CDC.\\nIn 1993, I became Chairman, CHS at the Aga Khan University Medical School where I established a CDC EIS like program, an MS in Epidemiology, and a family Medicine Residency. I founded the UT Houston School of Public Health campus in Brownsville in 2001. The campus has published over300 peer reviewed articles characterizing the extraordinary level of health disparities in the region. I was instrumental in bringing in over $100 million in external funding.\\nI now research chronic and infectious diseases in the LRGV in a cohort of 5000 people with over 30 research collaborators. I am featured in several books for the lay reader (e.g.,The Coming Plague, The Hot Zone). My wife, Sue Fisher-Hoch and I wrote a popular account (Level 4, Virus Hunters of the CDC) of our professional adventures translated into 7 languages. I am an amateur pianist, and enjoy many outdoor activities.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nGlobal Health\\nInfectious Disease\\nPersonal Links\\nhttp://www.ncbi.nlm.nih.gov/myncbi/browse/collection/40492151/?sort=date&direction=ascending\\nhttps://en.wikipedia.org/wiki/Joseph_B._McCormick\\nhttps://scholar.google.com/citations?user=xgV24roAAAAJ\\nhttps://www.pbs.org/wgbh/pages/frontline/aids/interviews/mccormick.html',\n",
|
| 298 |
+
" '<< Back\\nMicaela Sandoval\\nAssistant Professor Non-Tenure Research\\nEpidemiology\\n713/500-9000\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases'],\n",
|
| 299 |
+
" ['Elena Feofanova',\n",
|
| 300 |
+
" 'Eric Jones',\n",
|
| 301 |
+
" 'Susan Fisher-Hoch',\n",
|
| 302 |
+
" 'Lu-Yu Hwang',\n",
|
| 303 |
+
" 'Fuqing Wu',\n",
|
| 304 |
+
" 'Heather Essigmann',\n",
|
| 305 |
+
" 'Paul Scheet',\n",
|
| 306 |
+
" 'Charles Darkoh',\n",
|
| 307 |
+
" 'Joseph McCormick',\n",
|
| 308 |
+
" 'Micaela Sandoval'],\n",
|
| 309 |
+
" ['https://sph.uth.edu/faculty/?fac=K2vQLVh2UlsEfc/vmmpr1Fs/4u7UYh/Fv1JRv6tu3Cw=',\n",
|
| 310 |
+
" 'https://sph.uth.edu/faculty/?fac=cR7MFX%2B3Wde9%2BEMVGY1Tr7oQx%2BsGhAOuruLsHO7UHu8=',\n",
|
| 311 |
+
" 'https://sph.uth.edu/faculty/?fac=L7LDTUNsMRSWWMc72/M6BszFbk4rvzn/sjkju%2BFRSyg=',\n",
|
| 312 |
+
" 'https://sph.uth.edu/faculty/?fac=rmT1omzsPnVmTSI/j5K7WQ==',\n",
|
| 313 |
+
" 'https://gsbs.uth.edu/directory/profile?id=3247cf0b-e4ab-4f46-be9a-17c4bfaad784',\n",
|
| 314 |
+
" 'https://sph.uth.edu/faculty/?fac=cl6ZUp8M430eVKolh7L3tysX2yOqWaMt/aVHwKhTm/g=',\n",
|
| 315 |
+
" 'https://gsbs.uth.edu/directory/profile?id=e2296b7d-017f-42c3-a45d-62339c0f2668',\n",
|
| 316 |
+
" 'https://sph.uth.edu/faculty/?fac=0Oe7NOsP%2Bwqxzm8fNMAyFA==',\n",
|
| 317 |
+
" 'https://sph.uth.edu/faculty/?fac=b0beWb7l7z1FViVZQPFKTm1SaQ3glg/R65TV2Px4lDs=',\n",
|
| 318 |
+
" 'https://sph.uth.edu/faculty/?fac=7easTM9ILRE6auEurA/AUCTpx%2BnpUB%2BOCR2rrOuQ6tg='])"
|
| 319 |
+
]
|
| 320 |
+
},
|
| 321 |
+
"execution_count": 15,
|
| 322 |
+
"metadata": {},
|
| 323 |
+
"output_type": "execute_result"
|
| 324 |
+
}
|
| 325 |
+
],
|
| 326 |
+
"source": [
|
| 327 |
+
"find_similars(\"I am looking for a faculty member who is an expert in epidemiology.\")"
|
| 328 |
+
]
|
| 329 |
+
},
|
| 330 |
+
{
|
| 331 |
+
"cell_type": "code",
|
| 332 |
+
"execution_count": 16,
|
| 333 |
+
"id": "4b24eae0",
|
| 334 |
+
"metadata": {},
|
| 335 |
+
"outputs": [
|
| 336 |
+
{
|
| 337 |
+
"data": {
|
| 338 |
+
"text/plain": [
|
| 339 |
+
"'To provide some context, here are some faculty members that might be relevant to your description.\\n\\nPotentially related faculty:\\nElena Feofanova\\n\\n website: https://sph.uth.edu/faculty/?fac=K2vQLVh2UlsEfc/vmmpr1Fs/4u7UYh/Fv1JRv6tu3Cw=\\n\\n << Back\\nElena Feofanova\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9827\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nResearch Interests\\nEpidemiology\\n\\nPotentially related faculty:\\nEric Jones\\n\\n website: https://sph.uth.edu/faculty/?fac=cR7MFX%2B3Wde9%2BEMVGY1Tr7oQx%2BsGhAOuruLsHO7UHu8=\\n\\n << Back\\nEric Jones\\nAssociate Professor\\nEpidemiology\\n915/975-8528\\nMCA Medical Center of the Americas Foundation\\n5130 Gateway East Blvd. MCA 308\\nView CV\\nAbout\\nAs a social epidemiologist, I conduct research on social aspects of wellbeing. A major focus of my studies is on human behavior and wellbeing in extreme circumstances (like disasters, warfare. Migration, cancer), focusing on the role of relationships in stress, depression, anxiety, and functioning. My broad interest in collective action and social support, often using social network analysis, has also led me recently to study health care coordination, drug and violence prevention coalitions, informal and formal science education, and interorganizational dynamics. I continue to be involved in creating and maintaining online and desktop social network analysis software Most of my research takes place in Mexico, Ecuador, and the United States.\\nMajor Research Programs\\n* Comparative Disaster Recovery - Variation in how individuals and families recover from disasters (Ecuador, Mexico, US, involving over 10 disasters).\\n* Hazards and Cultural Transformations - Variation in how leaders and their subjects have dealt with disasters in 98 societies around the world in the past 200 years, including sharing, land tenure, ideology, economics, politics, rules/restrictions, etc.\\n* Cultural Models of Nature – Variation in the way different cultural groups understand their relationships to the biophysical environment and changes in weather affecting their food production (Ecuador, with colleague sites in 12+ other countries).\\nCenter Affiliation\\nCenter for Health Promotion and Prevention Research\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nEpidemiology\\nGlobal Health\\nHealth Equity\\nSocial Determinants of Health\\nPersonal Links\\nhttp://tmc.academia.edu/EricJones\\nhttps://www.researchgate.net/profile/Eric_Jones14\\n\\nPotentially related faculty:\\nSusan Fisher-Hoch\\n\\n website: https://sph.uth.edu/faculty/?fac=L7LDTUNsMRSWWMc72/M6BszFbk4rvzn/sjkju%2BFRSyg=\\n\\n << Back\\nSusan Fisher-Hoch\\nProfessor Non-Tenure Research\\nEpidemiology\\n956/755-0635\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nI am trained as a physician with a doctoral degree in epidemiology from London University with Membership of the Royal College of Pathology in virology. After a long career at the Centers for Disease Control and Prevention working with viral hemorrhagic fevers, in poor communities in developing countries. I designed and directed the French Biosafety 4 Level principally for studies of Ebola and Lassa fever for which I received the Légion d’Honneur. I joined the Brownsville campus of the School of Public Health to work in health disparity population health in 2001. In 2004 I helped found the Cameron County Hispanic Cohort (n=5000) which I direct. This is a randomly selected community based cohort of health disparity Mexican Americans. Using these data I have collaborative programs in diabetes, cardiovascular disease and cancers understudied minorities with a wide range of collaborators from major institutions across the country, funded by several NIH and CPRIT grants, and having produced more than 60 publications. I teach international epidemic investigation course on line based on real life outbreaks.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nInfectious Disease\\nPersonal Links\\nhttps://sph.uth.edu/research/centers/hispanic-health/about.htm\\n\\nPotentially related faculty:\\nLu-Yu Hwang\\n\\n website: https://sph.uth.edu/faculty/?fac=rmT1omzsPnVmTSI/j5K7WQ==\\n\\n << Back\\nLu-Yu Hwang\\nProfessor Non-Tenure Instruction\\nEpidemiology\\n713/500-9382\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nPediatrics; infectious disease; perinatal transmission; viral epidemiology; cancer epidemiology; hepatitis virus/liver cancer; HIV/AIDS, HTLV/leukemia; EBV/nasopharyngeal cancer; viral oncology.\\n\\nPotentially related faculty:\\nFuqing Wu\\n\\n website: https://gsbs.uth.edu/directory/profile?id=3247cf0b-e4ab-4f46-be9a-17c4bfaad784\\n\\n Fuqing Wu\\nRegular Member\\nAssistant Professor\\n713-500-9319\\n713-500-9319\\n[email\\xa0protected]\\nRAS - E703\\nThe University of Texas\\xa0 Health Science Center at Houston\\nDepartment of Environmental and Occupational Health Sciences\\nInfectious viral diseases remain one of the leading causes of mortality worldwide. Our group focuses on developing innovative environmental and genomic surveillance systems to understand population health and monitor the spread of infectious diseases. Using molecular virology, genomic sequencing, and mathematical modeling, our research works advance wastewater-based surveillance to track zoonotic pathogens, analyze the evolution of genomic variants, and forecast infection transmission dynamics. By integrating these tools, we aim to create early-warning systems for viral outbreaks and uncover key insights into pathogenic agents’ transmission and public health.\\nCurrent projects in my lab include:\\nWastewater-based Epidemiology: Developing methodologies for detecting pathogenic agents in community wastewater, capturing infection trends over time and space, and integrating surveillance data with mathematical models to predict outbreak dynamics and track viral evolution.\\nViral Metagenomics and Discovery: Employing cutting-edge metagenomic sequencing to explore human viral diversity, with the ultimate goal of creating a comprehensive global map of human viruses.\\nMicrobiome and Medicine: Investigating the interactions between viral infections, antiviral treatments, and the gut microbiome. Questions include how antibiotics affect gut microbiota and how everyday medications alter the microbiome.\\nStudents participating in tutorials/research in our lab will gain hands-on experience in molecular biology, genomic sequencing, bioinformatics, and mathematical modeling.\\nPubMed\\nMcGovern Medical School Faculty\\nEducation & Training\\nPh.D. - University of Arizona, 2017\\nResearch Opportunities\\nSeeking MS Students\\nSeeking PhD Students\\nPrograms\\nMicrobiology and Infectious Diseases\\nFaculty Development\\nMentoring Works\\nBack\\n\\nPotentially related faculty:\\nHeather Essigmann\\n\\n website: https://sph.uth.edu/faculty/?fac=cl6ZUp8M430eVKolh7L3tysX2yOqWaMt/aVHwKhTm/g=\\n\\n << Back\\nHeather Essigmann\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9280\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\n\\nPotentially related faculty:\\nPaul Scheet\\n\\n website: https://gsbs.uth.edu/directory/profile?id=e2296b7d-017f-42c3-a45d-62339c0f2668\\n\\n Paul Scheet\\nRegular Member\\nProfessor\\n713.745.2470\\n713.745.2470\\n[email\\xa0protected]\\nMDA CPB4.3301 (Unit 1340)\\nThe University of Texas\\xa0MD Anderson Cancer Center\\nDepartment of Epidemiology\\nMy main research involves the development of statistical methods for the analysis of population genetic data. Specifically, I work with models for linkage disequilibrium (LD), and develop applications for taking proper account of the dependence among nearby loci. These applications include haplotype inference, missing genotype imputation, disease mapping, genotype error detection and correction, the visualization of haplotype variation, and the integration of emerging data types such as next generation DNA sequencing. For these applications I maintain a widely-used software package called fastPHASE.\\nA rotation in my lab could provide a student with exposure to several state-of-the-art haplotype-based software packages (such as PHASE, fastPHASE, Beagle, and Mach) and, in the process, could help evaluate different models for LD for various applications and settings. These models rely on hidden Markov model (HMM) techniques and implicitly a student would gain some introduction to these as well as algorithms, such as Baum-Welch, Markov chain Monte Carlo and Expectation-Maximization. In addition, the student could perform hands-on data analyses and would gain experience in working with Perl and the statistical software R. A student with strong C programming skills could develop, test, and add a function for analysis to an existing software package.\\nThe Department of Epidemiology has space for students and postdocs and provides a rich academic atmosphere with a large number of faculty in the section of Computational Genetic Epidemiology. Ample computational support exists, including processors which support programs for genetic analysis, as well as standard programming and database management languages.\\nPubMed\\nMDACC Faculty\\nEducation & Training\\nPh.D. - University of Washington - 2006\\nPrograms\\nGenetics and Epigenetics\\nQuantitative Sciences\\nFaculty Development\\nMentoring Works\\nBack\\n\\nPotentially related faculty:\\nCharles Darkoh\\n\\n website: https://sph.uth.edu/faculty/?fac=0Oe7NOsP%2Bwqxzm8fNMAyFA==\\n\\n << Back\\nCharles Darkoh\\nProfessor and R. Palmer Beasley, M.D. & Lu-Yu Hwang, M.D. Chair\\nEpidemiology\\n713/500-9368\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nAbout\\nMy laboratory focuses on the epidemiology, pathogenesis, and molecular basis of enteric infectious diseases with the goal to identify and understand mechanisms of action of novel bacterial virulence factors, pathways, and unique microbial products that can be harnessed for diagnostics and therapeutics. My long-term research interests include investigating the role of small molecules and other metabolites produced by the gut microbiota in the pathogenesis of enteric infectious diseases, mechanisms of host-pathogen interactions, antimicrobial resistance, host genetics and susceptibility to bacterial infections, and global health. I have active lines of research on Clostridium (Clostridioides) difficile infections, drug discovery, diagnostics, antimicrobial resistance, and global health.\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nEpidemiology\\nGenetics and -omics\\nGlobal Health\\nInfectious Disease\\n\\nPotentially related faculty:\\nJoseph McCormick\\n\\n website: https://sph.uth.edu/faculty/?fac=b0beWb7l7z1FViVZQPFKTm1SaQ3glg/R65TV2Px4lDs=\\n\\n << Back\\nJoseph McCormick\\nProfessor & James H. Steele, D.V.M. Professorship\\nEpidemiology\\n956/755-0605\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nRaised on a farm in Indiana, I graduated from Florida Southern College in chemistry and mathematics and attended the Free University in Brussels in preparation for teaching sciences and mathematics in French in the Congo where I was also introduced to medicine. I obtained my MD at Duke in 1971 and an MS from Harvard (1970) under Dr. Weller (Nobel Laureate 1954). I trained at CHOP under Dr. Koop (later US Surgeon General). I joined the CDC EIS and worked in Brazil as a PAHO/CDC consultant for the meningitis outbreaks of 1974-6. In 1977 I founded the CDC Lassa fever project in Sierra Leone. I investigated the first Ebola epidemic in 1976 and led the one in 1979. In Sierra Leone I conducted definitive studies of the epidemiology and antiviral treatment of Lassa fever. As Chief, Special Pathogens Branch, Viral Diseases, CDC in 1982, I ran the Biosafety level 4 lab for 9 years. I organized and led the first AIDS investigation in Africa in 1983 and established the Project SIDA in Kinshasa, Congo. In 1983 I isolated the virus that causes Hemorrhagic Fever with Renal Syndrome (Hantavirus) at CDC.\\nIn 1993, I became Chairman, CHS at the Aga Khan University Medical School where I established a CDC EIS like program, an MS in Epidemiology, and a family Medicine Residency. I founded the UT Houston School of Public Health campus in Brownsville in 2001. The campus has published over300 peer reviewed articles characterizing the extraordinary level of health disparities in the region. I was instrumental in bringing in over $100 million in external funding.\\nI now research chronic and infectious diseases in the LRGV in a cohort of 5000 people with over 30 research collaborators. I am featured in several books for the lay reader (e.g.,The Coming Plague, The Hot Zone). My wife, Sue Fisher-Hoch and I wrote a popular account (Level 4, Virus Hunters of the CDC) of our professional adventures translated into 7 languages. I am an amateur pianist, and enjoy many outdoor activities.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nGlobal Health\\nInfectious Disease\\nPersonal Links\\nhttp://www.ncbi.nlm.nih.gov/myncbi/browse/collection/40492151/?sort=date&direction=ascending\\nhttps://en.wikipedia.org/wiki/Joseph_B._McCormick\\nhttps://scholar.google.com/citations?user=xgV24roAAAAJ\\nhttps://www.pbs.org/wgbh/pages/frontline/aids/interviews/mccormick.html\\n\\nPotentially related faculty:\\nMicaela Sandoval\\n\\n website: https://sph.uth.edu/faculty/?fac=7easTM9ILRE6auEurA/AUCTpx%2BnpUB%2BOCR2rrOuQ6tg=\\n\\n << Back\\nMicaela Sandoval\\nAssistant Professor Non-Tenure Research\\nEpidemiology\\n713/500-9000\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases\\n\\n'"
|
| 340 |
+
]
|
| 341 |
+
},
|
| 342 |
+
"execution_count": 16,
|
| 343 |
+
"metadata": {},
|
| 344 |
+
"output_type": "execute_result"
|
| 345 |
+
}
|
| 346 |
+
],
|
| 347 |
+
"source": [
|
| 348 |
+
"def make_context(similars):\n",
|
| 349 |
+
" message = \"To provide some context, here are some faculty members that might be relevant to your description.\\n\\n\"\n",
|
| 350 |
+
" documents, names, links = similars\n",
|
| 351 |
+
" for similar, name, link in zip(documents, names, links):\n",
|
| 352 |
+
" message += f'''Potentially related faculty:\\n{name}\\n\n",
|
| 353 |
+
" website: {link}\\n\n",
|
| 354 |
+
" {similar}\\n\\n'''\n",
|
| 355 |
+
" return message\n",
|
| 356 |
+
"make_context(find_similars(\"I am looking for a faculty member who is an expert in epidemiology.\"))"
|
| 357 |
+
]
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"cell_type": "code",
|
| 361 |
+
"execution_count": 17,
|
| 362 |
+
"id": "044b9390",
|
| 363 |
+
"metadata": {},
|
| 364 |
+
"outputs": [
|
| 365 |
+
{
|
| 366 |
+
"data": {
|
| 367 |
+
"text/plain": [
|
| 368 |
+
"{'role': 'user',\n",
|
| 369 |
+
" 'content': 'Here is my description: I am looking for a faculty member who is an expert in epidemiology.\\n\\nTo provide some context, here are some faculty members that might be relevant to your description.\\n\\nPotentially related faculty:\\nElena Feofanova\\n\\n website: https://sph.uth.edu/faculty/?fac=K2vQLVh2UlsEfc/vmmpr1Fs/4u7UYh/Fv1JRv6tu3Cw=\\n\\n << Back\\nElena Feofanova\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9827\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nResearch Interests\\nEpidemiology\\n\\nPotentially related faculty:\\nEric Jones\\n\\n website: https://sph.uth.edu/faculty/?fac=cR7MFX%2B3Wde9%2BEMVGY1Tr7oQx%2BsGhAOuruLsHO7UHu8=\\n\\n << Back\\nEric Jones\\nAssociate Professor\\nEpidemiology\\n915/975-8528\\nMCA Medical Center of the Americas Foundation\\n5130 Gateway East Blvd. MCA 308\\nView CV\\nAbout\\nAs a social epidemiologist, I conduct research on social aspects of wellbeing. A major focus of my studies is on human behavior and wellbeing in extreme circumstances (like disasters, warfare. Migration, cancer), focusing on the role of relationships in stress, depression, anxiety, and functioning. My broad interest in collective action and social support, often using social network analysis, has also led me recently to study health care coordination, drug and violence prevention coalitions, informal and formal science education, and interorganizational dynamics. I continue to be involved in creating and maintaining online and desktop social network analysis software Most of my research takes place in Mexico, Ecuador, and the United States.\\nMajor Research Programs\\n* Comparative Disaster Recovery - Variation in how individuals and families recover from disasters (Ecuador, Mexico, US, involving over 10 disasters).\\n* Hazards and Cultural Transformations - Variation in how leaders and their subjects have dealt with disasters in 98 societies around the world in the past 200 years, including sharing, land tenure, ideology, economics, politics, rules/restrictions, etc.\\n* Cultural Models of Nature – Variation in the way different cultural groups understand their relationships to the biophysical environment and changes in weather affecting their food production (Ecuador, with colleague sites in 12+ other countries).\\nCenter Affiliation\\nCenter for Health Promotion and Prevention Research\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nEpidemiology\\nGlobal Health\\nHealth Equity\\nSocial Determinants of Health\\nPersonal Links\\nhttp://tmc.academia.edu/EricJones\\nhttps://www.researchgate.net/profile/Eric_Jones14\\n\\nPotentially related faculty:\\nSusan Fisher-Hoch\\n\\n website: https://sph.uth.edu/faculty/?fac=L7LDTUNsMRSWWMc72/M6BszFbk4rvzn/sjkju%2BFRSyg=\\n\\n << Back\\nSusan Fisher-Hoch\\nProfessor Non-Tenure Research\\nEpidemiology\\n956/755-0635\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nI am trained as a physician with a doctoral degree in epidemiology from London University with Membership of the Royal College of Pathology in virology. After a long career at the Centers for Disease Control and Prevention working with viral hemorrhagic fevers, in poor communities in developing countries. I designed and directed the French Biosafety 4 Level principally for studies of Ebola and Lassa fever for which I received the Légion d’Honneur. I joined the Brownsville campus of the School of Public Health to work in health disparity population health in 2001. In 2004 I helped found the Cameron County Hispanic Cohort (n=5000) which I direct. This is a randomly selected community based cohort of health disparity Mexican Americans. Using these data I have collaborative programs in diabetes, cardiovascular disease and cancers understudied minorities with a wide range of collaborators from major institutions across the country, funded by several NIH and CPRIT grants, and having produced more than 60 publications. I teach international epidemic investigation course on line based on real life outbreaks.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nInfectious Disease\\nPersonal Links\\nhttps://sph.uth.edu/research/centers/hispanic-health/about.htm\\n\\nPotentially related faculty:\\nLu-Yu Hwang\\n\\n website: https://sph.uth.edu/faculty/?fac=rmT1omzsPnVmTSI/j5K7WQ==\\n\\n << Back\\nLu-Yu Hwang\\nProfessor Non-Tenure Instruction\\nEpidemiology\\n713/500-9382\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nPediatrics; infectious disease; perinatal transmission; viral epidemiology; cancer epidemiology; hepatitis virus/liver cancer; HIV/AIDS, HTLV/leukemia; EBV/nasopharyngeal cancer; viral oncology.\\n\\nPotentially related faculty:\\nFuqing Wu\\n\\n website: https://gsbs.uth.edu/directory/profile?id=3247cf0b-e4ab-4f46-be9a-17c4bfaad784\\n\\n Fuqing Wu\\nRegular Member\\nAssistant Professor\\n713-500-9319\\n713-500-9319\\n[email\\xa0protected]\\nRAS - E703\\nThe University of Texas\\xa0 Health Science Center at Houston\\nDepartment of Environmental and Occupational Health Sciences\\nInfectious viral diseases remain one of the leading causes of mortality worldwide. Our group focuses on developing innovative environmental and genomic surveillance systems to understand population health and monitor the spread of infectious diseases. Using molecular virology, genomic sequencing, and mathematical modeling, our research works advance wastewater-based surveillance to track zoonotic pathogens, analyze the evolution of genomic variants, and forecast infection transmission dynamics. By integrating these tools, we aim to create early-warning systems for viral outbreaks and uncover key insights into pathogenic agents’ transmission and public health.\\nCurrent projects in my lab include:\\nWastewater-based Epidemiology: Developing methodologies for detecting pathogenic agents in community wastewater, capturing infection trends over time and space, and integrating surveillance data with mathematical models to predict outbreak dynamics and track viral evolution.\\nViral Metagenomics and Discovery: Employing cutting-edge metagenomic sequencing to explore human viral diversity, with the ultimate goal of creating a comprehensive global map of human viruses.\\nMicrobiome and Medicine: Investigating the interactions between viral infections, antiviral treatments, and the gut microbiome. Questions include how antibiotics affect gut microbiota and how everyday medications alter the microbiome.\\nStudents participating in tutorials/research in our lab will gain hands-on experience in molecular biology, genomic sequencing, bioinformatics, and mathematical modeling.\\nPubMed\\nMcGovern Medical School Faculty\\nEducation & Training\\nPh.D. - University of Arizona, 2017\\nResearch Opportunities\\nSeeking MS Students\\nSeeking PhD Students\\nPrograms\\nMicrobiology and Infectious Diseases\\nFaculty Development\\nMentoring Works\\nBack\\n\\nPotentially related faculty:\\nHeather Essigmann\\n\\n website: https://sph.uth.edu/faculty/?fac=cl6ZUp8M430eVKolh7L3tysX2yOqWaMt/aVHwKhTm/g=\\n\\n << Back\\nHeather Essigmann\\nAssistant Professor Non-Tenure Instruction\\nEpidemiology\\n713/500-9280\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\n\\nPotentially related faculty:\\nPaul Scheet\\n\\n website: https://gsbs.uth.edu/directory/profile?id=e2296b7d-017f-42c3-a45d-62339c0f2668\\n\\n Paul Scheet\\nRegular Member\\nProfessor\\n713.745.2470\\n713.745.2470\\n[email\\xa0protected]\\nMDA CPB4.3301 (Unit 1340)\\nThe University of Texas\\xa0MD Anderson Cancer Center\\nDepartment of Epidemiology\\nMy main research involves the development of statistical methods for the analysis of population genetic data. Specifically, I work with models for linkage disequilibrium (LD), and develop applications for taking proper account of the dependence among nearby loci. These applications include haplotype inference, missing genotype imputation, disease mapping, genotype error detection and correction, the visualization of haplotype variation, and the integration of emerging data types such as next generation DNA sequencing. For these applications I maintain a widely-used software package called fastPHASE.\\nA rotation in my lab could provide a student with exposure to several state-of-the-art haplotype-based software packages (such as PHASE, fastPHASE, Beagle, and Mach) and, in the process, could help evaluate different models for LD for various applications and settings. These models rely on hidden Markov model (HMM) techniques and implicitly a student would gain some introduction to these as well as algorithms, such as Baum-Welch, Markov chain Monte Carlo and Expectation-Maximization. In addition, the student could perform hands-on data analyses and would gain experience in working with Perl and the statistical software R. A student with strong C programming skills could develop, test, and add a function for analysis to an existing software package.\\nThe Department of Epidemiology has space for students and postdocs and provides a rich academic atmosphere with a large number of faculty in the section of Computational Genetic Epidemiology. Ample computational support exists, including processors which support programs for genetic analysis, as well as standard programming and database management languages.\\nPubMed\\nMDACC Faculty\\nEducation & Training\\nPh.D. - University of Washington - 2006\\nPrograms\\nGenetics and Epigenetics\\nQuantitative Sciences\\nFaculty Development\\nMentoring Works\\nBack\\n\\nPotentially related faculty:\\nCharles Darkoh\\n\\n website: https://sph.uth.edu/faculty/?fac=0Oe7NOsP%2Bwqxzm8fNMAyFA==\\n\\n << Back\\nCharles Darkoh\\nProfessor and R. Palmer Beasley, M.D. & Lu-Yu Hwang, M.D. Chair\\nEpidemiology\\n713/500-9368\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nAbout\\nMy laboratory focuses on the epidemiology, pathogenesis, and molecular basis of enteric infectious diseases with the goal to identify and understand mechanisms of action of novel bacterial virulence factors, pathways, and unique microbial products that can be harnessed for diagnostics and therapeutics. My long-term research interests include investigating the role of small molecules and other metabolites produced by the gut microbiota in the pathogenesis of enteric infectious diseases, mechanisms of host-pathogen interactions, antimicrobial resistance, host genetics and susceptibility to bacterial infections, and global health. I have active lines of research on Clostridium (Clostridioides) difficile infections, drug discovery, diagnostics, antimicrobial resistance, and global health.\\nCenter Affiliation\\nCenter for Infectious Diseases\\nResearch Interests\\nEpidemiology\\nGenetics and -omics\\nGlobal Health\\nInfectious Disease\\n\\nPotentially related faculty:\\nJoseph McCormick\\n\\n website: https://sph.uth.edu/faculty/?fac=b0beWb7l7z1FViVZQPFKTm1SaQ3glg/R65TV2Px4lDs=\\n\\n << Back\\nJoseph McCormick\\nProfessor & James H. Steele, D.V.M. Professorship\\nEpidemiology\\n956/755-0605\\nRegional Academic Health Center\\nOne West University Blvd, SPH Building, S1.330, Brownsville, TX 78520\\nView CV\\nAbout\\nRaised on a farm in Indiana, I graduated from Florida Southern College in chemistry and mathematics and attended the Free University in Brussels in preparation for teaching sciences and mathematics in French in the Congo where I was also introduced to medicine. I obtained my MD at Duke in 1971 and an MS from Harvard (1970) under Dr. Weller (Nobel Laureate 1954). I trained at CHOP under Dr. Koop (later US Surgeon General). I joined the CDC EIS and worked in Brazil as a PAHO/CDC consultant for the meningitis outbreaks of 1974-6. In 1977 I founded the CDC Lassa fever project in Sierra Leone. I investigated the first Ebola epidemic in 1976 and led the one in 1979. In Sierra Leone I conducted definitive studies of the epidemiology and antiviral treatment of Lassa fever. As Chief, Special Pathogens Branch, Viral Diseases, CDC in 1982, I ran the Biosafety level 4 lab for 9 years. I organized and led the first AIDS investigation in Africa in 1983 and established the Project SIDA in Kinshasa, Congo. In 1983 I isolated the virus that causes Hemorrhagic Fever with Renal Syndrome (Hantavirus) at CDC.\\nIn 1993, I became Chairman, CHS at the Aga Khan University Medical School where I established a CDC EIS like program, an MS in Epidemiology, and a family Medicine Residency. I founded the UT Houston School of Public Health campus in Brownsville in 2001. The campus has published over300 peer reviewed articles characterizing the extraordinary level of health disparities in the region. I was instrumental in bringing in over $100 million in external funding.\\nI now research chronic and infectious diseases in the LRGV in a cohort of 5000 people with over 30 research collaborators. I am featured in several books for the lay reader (e.g.,The Coming Plague, The Hot Zone). My wife, Sue Fisher-Hoch and I wrote a popular account (Level 4, Virus Hunters of the CDC) of our professional adventures translated into 7 languages. I am an amateur pianist, and enjoy many outdoor activities.\\nCenter Affiliation\\nHispanic Health Research Center\\nResearch Interests\\nBehavioral/Mental Health\\nBorder Health\\nCancer\\nCardiovascular and Chronic Diseases\\nClinical Trials\\nEpidemiology\\nGlobal Health\\nInfectious Disease\\nPersonal Links\\nhttp://www.ncbi.nlm.nih.gov/myncbi/browse/collection/40492151/?sort=date&direction=ascending\\nhttps://en.wikipedia.org/wiki/Joseph_B._McCormick\\nhttps://scholar.google.com/citations?user=xgV24roAAAAJ\\nhttps://www.pbs.org/wgbh/pages/frontline/aids/interviews/mccormick.html\\n\\nPotentially related faculty:\\nMicaela Sandoval\\n\\n website: https://sph.uth.edu/faculty/?fac=7easTM9ILRE6auEurA/AUCTpx%2BnpUB%2BOCR2rrOuQ6tg=\\n\\n << Back\\nMicaela Sandoval\\nAssistant Professor Non-Tenure Research\\nEpidemiology\\n713/500-9000\\nReuel Stallones Building\\n1200 Pressler Street, Houston, TX 77030\\nView CV\\nCenter Affiliation\\nCenter for Infectious Diseases\\n\\n'}"
|
| 370 |
+
]
|
| 371 |
+
},
|
| 372 |
+
"execution_count": 17,
|
| 373 |
+
"metadata": {},
|
| 374 |
+
"output_type": "execute_result"
|
| 375 |
+
}
|
| 376 |
+
],
|
| 377 |
+
"source": [
|
| 378 |
+
"def messages_for(description, similars):\n",
|
| 379 |
+
" user_prompt = f\"Here is my description: {description}\\n\\n\"\n",
|
| 380 |
+
" user_prompt += make_context(similars)\n",
|
| 381 |
+
" return {\"role\": \"user\", \"content\": user_prompt}\n",
|
| 382 |
+
"messages_for(\"I am looking for a faculty member who is an expert in epidemiology.\", find_similars(\"I am looking for a faculty member who is an expert in epidemiology.\"))"
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"cell_type": "code",
|
| 387 |
+
"execution_count": 18,
|
| 388 |
+
"id": "0c9e6350",
|
| 389 |
+
"metadata": {},
|
| 390 |
+
"outputs": [],
|
| 391 |
+
"source": [
|
| 392 |
+
"# environment\n",
|
| 393 |
+
"\n",
|
| 394 |
+
"load_dotenv(override=True)\n",
|
| 395 |
+
"os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY', 'your-key-if-not-using-env')\n",
|
| 396 |
+
"os.environ['HF_TOKEN'] = os.getenv('HF_TOKEN', 'your-key-if-not-using-env')\n",
|
| 397 |
+
"\n",
|
| 398 |
+
"openai = OpenAI()"
|
| 399 |
+
]
|
| 400 |
+
},
|
| 401 |
+
{
|
| 402 |
+
"cell_type": "code",
|
| 403 |
+
"execution_count": 25,
|
| 404 |
+
"id": "cd319467",
|
| 405 |
+
"metadata": {},
|
| 406 |
+
"outputs": [
|
| 407 |
+
{
|
| 408 |
+
"name": "stdout",
|
| 409 |
+
"output_type": "stream",
|
| 410 |
+
"text": [
|
| 411 |
+
"<generator object gpt_4o_mini_rag at 0x1bdd28dc0>\n"
|
| 412 |
+
]
|
| 413 |
+
}
|
| 414 |
+
],
|
| 415 |
+
"source": [
|
| 416 |
+
"# print in markdown format\n",
|
| 417 |
+
"from IPython.display import Markdown, display\n",
|
| 418 |
+
"def gpt_4o_mini_rag(description, history):\n",
|
| 419 |
+
"\n",
|
| 420 |
+
" system_message = \"You are a academic advisor. You estimate the relevance of faculty members to a given description. Suggest relevant faculty members. Don't forget to include a link to the faculty member's profile. You should give explanation for your choice in markdown format.\"\n",
|
| 421 |
+
" system_message = {\"role\": \"system\", \"content\": system_message}\n",
|
| 422 |
+
" similars = find_similars(description=description)\n",
|
| 423 |
+
" messages = messages_for(description, similars)\n",
|
| 424 |
+
" messages = [system_message] + history + [messages]\n",
|
| 425 |
+
" \n",
|
| 426 |
+
" stream = openai.chat.completions.create(\n",
|
| 427 |
+
" model=\"gpt-4o-mini\", \n",
|
| 428 |
+
" messages=messages,\n",
|
| 429 |
+
" seed=42,\n",
|
| 430 |
+
" stream=True\n",
|
| 431 |
+
" )\n",
|
| 432 |
+
" \n",
|
| 433 |
+
" response = \"\"\n",
|
| 434 |
+
" for chunk in stream:\n",
|
| 435 |
+
" response += chunk.choices[0].delta.content or ''\n",
|
| 436 |
+
" yield response\n",
|
| 437 |
+
"\n",
|
| 438 |
+
"\n",
|
| 439 |
+
"\n",
|
| 440 |
+
"def display_markdown_response(description):\n",
|
| 441 |
+
" response = gpt_4o_mini_rag(description, [])\n",
|
| 442 |
+
" print(response)\n",
|
| 443 |
+
" # display(Markdown(response))\n",
|
| 444 |
+
"\n",
|
| 445 |
+
"display_markdown_response(\"I am keen on clinical trial. Can you give me faculty members who are experts in develop statistical methods for clinical trial?\")"
|
| 446 |
+
]
|
| 447 |
+
},
|
| 448 |
+
{
|
| 449 |
+
"cell_type": "code",
|
| 450 |
+
"execution_count": null,
|
| 451 |
+
"id": "05423e60",
|
| 452 |
+
"metadata": {},
|
| 453 |
+
"outputs": [
|
| 454 |
+
{
|
| 455 |
+
"name": "stderr",
|
| 456 |
+
"output_type": "stream",
|
| 457 |
+
"text": [
|
| 458 |
+
"/Users/guchunhui/Documents/sandbox/data_generator/.venv/lib/python3.11/site-packages/gradio/blocks.py:1153: UserWarning: Cannot load gradio/monochrome. Caught Exception: 401 Client Error: Unauthorized for url: https://huggingface.co/api/spaces/gradio/monochrome (Request ID: Root=1-68329c92-678e41f1740e159154584e10;6a619f00-c33e-4633-931d-eab62cf234bc)\n",
|
| 459 |
+
"\n",
|
| 460 |
+
"Invalid credentials in Authorization header\n",
|
| 461 |
+
" warnings.warn(f\"Cannot load {theme}. Caught Exception: {str(e)}\")\n"
|
| 462 |
+
]
|
| 463 |
+
},
|
| 464 |
+
{
|
| 465 |
+
"name": "stdout",
|
| 466 |
+
"output_type": "stream",
|
| 467 |
+
"text": [
|
| 468 |
+
"* Running on local URL: http://127.0.0.1:7864\n",
|
| 469 |
+
"* To create a public link, set `share=True` in `launch()`.\n"
|
| 470 |
+
]
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"data": {
|
| 474 |
+
"text/html": [
|
| 475 |
+
"<div><iframe src=\"http://127.0.0.1:7864/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 476 |
+
],
|
| 477 |
+
"text/plain": [
|
| 478 |
+
"<IPython.core.display.HTML object>"
|
| 479 |
+
]
|
| 480 |
+
},
|
| 481 |
+
"metadata": {},
|
| 482 |
+
"output_type": "display_data"
|
| 483 |
+
},
|
| 484 |
+
{
|
| 485 |
+
"data": {
|
| 486 |
+
"text/plain": []
|
| 487 |
+
},
|
| 488 |
+
"execution_count": 28,
|
| 489 |
+
"metadata": {},
|
| 490 |
+
"output_type": "execute_result"
|
| 491 |
+
}
|
| 492 |
+
],
|
| 493 |
+
"source": [
|
| 494 |
+
"import gradio as gr\n",
|
| 495 |
+
"MODEL = \"gpt-4o-mini\"\n",
|
| 496 |
+
"\n",
|
| 497 |
+
"\n",
|
| 498 |
+
"\n",
|
| 499 |
+
"gr.ChatInterface(fn=gpt_4o_mini_rag, \n",
|
| 500 |
+
" title=\"Faculty Advisor Chat\",\n",
|
| 501 |
+
" description=\"Ask about faculty members and their expertise\",\n",
|
| 502 |
+
" theme='earneleh/paris',\n",
|
| 503 |
+
" examples=[\n",
|
| 504 |
+
" \"I am looking for a faculty member who is an expert in epidemiology\",\n",
|
| 505 |
+
" \"Can you recommend someone who works on clinical trials?\",\n",
|
| 506 |
+
" \"Who specializes in machine learning?\"\n",
|
| 507 |
+
" ],\n",
|
| 508 |
+
" type=\"messages\").launch()"
|
| 509 |
+
]
|
| 510 |
+
}
|
| 511 |
+
],
|
| 512 |
+
"metadata": {
|
| 513 |
+
"kernelspec": {
|
| 514 |
+
"display_name": ".venv",
|
| 515 |
+
"language": "python",
|
| 516 |
+
"name": "python3"
|
| 517 |
+
},
|
| 518 |
+
"language_info": {
|
| 519 |
+
"codemirror_mode": {
|
| 520 |
+
"name": "ipython",
|
| 521 |
+
"version": 3
|
| 522 |
+
},
|
| 523 |
+
"file_extension": ".py",
|
| 524 |
+
"mimetype": "text/x-python",
|
| 525 |
+
"name": "python",
|
| 526 |
+
"nbconvert_exporter": "python",
|
| 527 |
+
"pygments_lexer": "ipython3",
|
| 528 |
+
"version": "3.11.12"
|
| 529 |
+
}
|
| 530 |
+
},
|
| 531 |
+
"nbformat": 4,
|
| 532 |
+
"nbformat_minor": 5
|
| 533 |
+
}
|
simple.ipynb
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
src/{GSBS_faculty_scraper.py → scraper/GSBS_faculty_scraper.py}
RENAMED
|
@@ -6,7 +6,7 @@ from typing_extensions import override
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
-
from faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class GSBSFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from GSBS websites."""
|
|
@@ -208,7 +208,6 @@ class GSBSFacultyScraper(FacultyScraper):
|
|
| 208 |
|
| 209 |
print(f"Completed scraping {page_num} page(s), total faculty: {len(faculty_list)}")
|
| 210 |
self.faculty_list = faculty_list
|
| 211 |
-
return faculty_list
|
| 212 |
|
| 213 |
|
| 214 |
def main():
|
|
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
+
from src.scraper.faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class GSBSFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from GSBS websites."""
|
|
|
|
| 208 |
|
| 209 |
print(f"Completed scraping {page_num} page(s), total faculty: {len(faculty_list)}")
|
| 210 |
self.faculty_list = faculty_list
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
def main():
|
src/{faculty_scraper.py → scraper/faculty_scraper.py}
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
from typing import List, Dict, Optional
|
| 4 |
from urllib.parse import urljoin
|
| 5 |
-
import profile_scraper
|
| 6 |
from summarize import summarize
|
| 7 |
import json
|
| 8 |
|
|
@@ -28,6 +30,10 @@ class FacultyScraper:
|
|
| 28 |
if not self.faculty_list:
|
| 29 |
print("No faculty data to save. Please scrape data first.")
|
| 30 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
with open(output_file, 'w', encoding='utf-8') as f:
|
| 33 |
for faculty_member in self.faculty_list:
|
|
@@ -80,7 +86,6 @@ class FacultyScraper:
|
|
| 80 |
print(f"Processed {i+1}/{len(faculty_divs)} faculty members")
|
| 81 |
|
| 82 |
self.faculty_list = faculty_list
|
| 83 |
-
return faculty_list
|
| 84 |
|
| 85 |
def _get_faculty_profile(self, profile_url: str) -> str:
|
| 86 |
"""
|
|
@@ -104,11 +109,6 @@ class FacultyScraper:
|
|
| 104 |
'''
|
| 105 |
pass
|
| 106 |
|
| 107 |
-
def scrape_faculty_list(self) -> List[Dict]:
|
| 108 |
-
'''
|
| 109 |
-
Scrape the faculty list from the faculty divs
|
| 110 |
-
'''
|
| 111 |
-
pass
|
| 112 |
|
| 113 |
def _extract_image_url(self, faculty_div) -> Optional[str]:
|
| 114 |
'''
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import time
|
| 3 |
import requests
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
from typing import List, Dict, Optional
|
| 6 |
from urllib.parse import urljoin
|
| 7 |
+
import src.scraper.profile_scraper as profile_scraper
|
| 8 |
from summarize import summarize
|
| 9 |
import json
|
| 10 |
|
|
|
|
| 30 |
if not self.faculty_list:
|
| 31 |
print("No faculty data to save. Please scrape data first.")
|
| 32 |
return
|
| 33 |
+
|
| 34 |
+
# remove the file if it exists
|
| 35 |
+
if os.path.exists(output_file):
|
| 36 |
+
os.remove(output_file)
|
| 37 |
|
| 38 |
with open(output_file, 'w', encoding='utf-8') as f:
|
| 39 |
for faculty_member in self.faculty_list:
|
|
|
|
| 86 |
print(f"Processed {i+1}/{len(faculty_divs)} faculty members")
|
| 87 |
|
| 88 |
self.faculty_list = faculty_list
|
|
|
|
| 89 |
|
| 90 |
def _get_faculty_profile(self, profile_url: str) -> str:
|
| 91 |
"""
|
|
|
|
| 109 |
'''
|
| 110 |
pass
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
def _extract_image_url(self, faculty_div) -> Optional[str]:
|
| 114 |
'''
|
src/{profile_scraper.py → scraper/profile_scraper.py}
RENAMED
|
File without changes
|
src/{sbmi_faculty_scraper.py → scraper/sbmi_faculty_scraper.py}
RENAMED
|
@@ -6,7 +6,7 @@ from typing_extensions import override
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
-
from faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class SBMIFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from SBMI websites."""
|
|
@@ -31,30 +31,8 @@ class SBMIFacultyScraper(FacultyScraper):
|
|
| 31 |
Returns:
|
| 32 |
List: List of faculty divs
|
| 33 |
"""
|
| 34 |
-
#
|
| 35 |
-
faculty_divs = (
|
| 36 |
-
# SBMI-specific selectors
|
| 37 |
-
self.soup.find_all('div', class_='faculty-listing-item') or
|
| 38 |
-
self.soup.find_all('div', class_='faculty-member-card') or
|
| 39 |
-
self.soup.find_all('article', class_='faculty-profile') or
|
| 40 |
-
|
| 41 |
-
# UTHealth common patterns
|
| 42 |
-
self.soup.find_all('div', class_='people-card') or
|
| 43 |
-
self.soup.find_all('div', class_='person-profile') or
|
| 44 |
-
|
| 45 |
-
# Generic patterns
|
| 46 |
-
self.soup.find_all('div', class_='faculty-card') or
|
| 47 |
-
self.soup.find_all('div', class_='faculty-member') or
|
| 48 |
-
self.soup.find_all('div', class_='person-card') or
|
| 49 |
-
self.soup.find_all('div', class_='cell') or
|
| 50 |
-
self.soup.find_all('article', class_='faculty') or
|
| 51 |
-
self.soup.find_all('div', class_='directory-entry') or
|
| 52 |
-
|
| 53 |
-
# Look for any div containing faculty-related links
|
| 54 |
-
self.soup.find_all('div', lambda value: value and any(
|
| 55 |
-
keyword in str(value).lower() for keyword in ['faculty', 'people', 'staff', 'profile']
|
| 56 |
-
))
|
| 57 |
-
)
|
| 58 |
|
| 59 |
# Filter out empty or invalid divs
|
| 60 |
return [div for div in faculty_divs if div and div.get_text().strip()]
|
|
@@ -70,30 +48,14 @@ class SBMIFacultyScraper(FacultyScraper):
|
|
| 70 |
Returns:
|
| 71 |
Optional[str]: Faculty name if found, None otherwise
|
| 72 |
"""
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
for selector in name_selectors:
|
| 82 |
-
name_element = faculty_div.select_one(selector)
|
| 83 |
-
if name_element:
|
| 84 |
-
name = name_element.get_text().strip()
|
| 85 |
-
# Clean up common title patterns and suffixes
|
| 86 |
-
name = self._clean_name(name)
|
| 87 |
-
if name and len(name) > 2 and ' ' in name: # Ensure it's a full name
|
| 88 |
-
return name
|
| 89 |
-
|
| 90 |
-
# If no name found in structured elements, look for links with names
|
| 91 |
-
links = faculty_div.find_all('a')
|
| 92 |
-
for link in links:
|
| 93 |
-
link_text = link.get_text().strip()
|
| 94 |
-
cleaned_name = self._clean_name(link_text)
|
| 95 |
-
if cleaned_name and len(cleaned_name) > 2 and ' ' in cleaned_name:
|
| 96 |
-
return cleaned_name
|
| 97 |
|
| 98 |
return None
|
| 99 |
|
|
@@ -120,118 +82,89 @@ class SBMIFacultyScraper(FacultyScraper):
|
|
| 120 |
|
| 121 |
return name.strip()
|
| 122 |
|
| 123 |
-
|
| 124 |
-
def _extract_profile_url(self, faculty_div) -> Optional[str]:
|
| 125 |
"""
|
| 126 |
-
Extract
|
| 127 |
|
| 128 |
Args:
|
| 129 |
faculty_div: BeautifulSoup element containing faculty info
|
| 130 |
|
| 131 |
Returns:
|
| 132 |
-
|
| 133 |
"""
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
for link in links:
|
| 149 |
-
href = link.get('href')
|
| 150 |
-
if href and not href.startswith(('mailto:', 'tel:', '#', 'javascript:')):
|
| 151 |
-
# Prefer links that look like faculty profiles
|
| 152 |
-
if any(keyword in href.lower() for keyword in ['faculty', 'profile', 'people']):
|
| 153 |
-
return self.get_absolute_url(self.base_url, href)
|
| 154 |
|
| 155 |
-
|
| 156 |
-
if
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
| 161 |
return None
|
| 162 |
|
| 163 |
@override
|
| 164 |
-
def
|
| 165 |
"""
|
| 166 |
-
Extract
|
| 167 |
|
| 168 |
Args:
|
| 169 |
faculty_div: BeautifulSoup element containing faculty info
|
| 170 |
|
| 171 |
Returns:
|
| 172 |
-
Optional[str]:
|
| 173 |
"""
|
| 174 |
-
#
|
| 175 |
-
|
| 176 |
-
if
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
for element in elements_with_style:
|
| 185 |
-
style = element.get('style', '')
|
| 186 |
-
if 'background-image' in style and 'url(' in style:
|
| 187 |
-
start = style.find('url(') + 4
|
| 188 |
-
end = style.find(')', start)
|
| 189 |
-
if start != -1 and end != -1:
|
| 190 |
-
img_url = style[start:end].strip('\'"')
|
| 191 |
-
if img_url and not img_url.startswith('data:'):
|
| 192 |
-
return self.get_absolute_url(self.base_url, img_url)
|
| 193 |
|
| 194 |
return None
|
| 195 |
|
| 196 |
-
|
|
|
|
| 197 |
"""
|
| 198 |
-
Extract faculty
|
| 199 |
|
| 200 |
Args:
|
| 201 |
faculty_div: BeautifulSoup element containing faculty info
|
| 202 |
|
| 203 |
Returns:
|
| 204 |
-
Optional[str]:
|
| 205 |
"""
|
| 206 |
-
#
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
]
|
| 214 |
-
|
| 215 |
-
for selector in position_selectors:
|
| 216 |
-
elements = faculty_div.select(selector)
|
| 217 |
-
for element in elements:
|
| 218 |
-
text = element.get_text().strip()
|
| 219 |
-
# Filter out obvious non-position text
|
| 220 |
-
if (text and len(text) > 3 and
|
| 221 |
-
not any(skip in text.lower() for skip in
|
| 222 |
-
['email', 'phone', 'office', 'room', '@', 'tel:', 'mailto:'])):
|
| 223 |
-
return text
|
| 224 |
-
|
| 225 |
-
# Look for text patterns that might be positions
|
| 226 |
-
text_content = faculty_div.get_text()
|
| 227 |
-
lines = [line.strip() for line in text_content.split('\n') if line.strip()]
|
| 228 |
|
| 229 |
-
for line in lines[1:4]: # Skip first line (likely name), check next few
|
| 230 |
-
if (len(line) > 5 and
|
| 231 |
-
any(keyword in line.lower() for keyword in
|
| 232 |
-
['professor', 'director', 'chair', 'faculty', 'researcher', 'scientist'])):
|
| 233 |
-
return line
|
| 234 |
-
|
| 235 |
return None
|
| 236 |
|
| 237 |
@override
|
|
@@ -284,6 +217,11 @@ class SBMIFacultyScraper(FacultyScraper):
|
|
| 284 |
if position:
|
| 285 |
faculty_info['position'] = position
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
# Extract profile URL and get profile summary
|
| 288 |
profile_url = self._extract_profile_url(faculty_div)
|
| 289 |
if profile_url:
|
|
@@ -312,11 +250,11 @@ def main():
|
|
| 312 |
base_url = 'https://sbmi.uth.edu/faculty-and-staff/'
|
| 313 |
|
| 314 |
# Create scraper instance and run
|
| 315 |
-
scraper = SBMIFacultyScraper(base_url, debug=
|
| 316 |
faculty_list = scraper.scrape_faculty_list()
|
| 317 |
-
|
| 318 |
# Save the faculty list as jsonl file
|
| 319 |
-
scraper.save_to_jsonl(
|
| 320 |
|
| 321 |
|
| 322 |
if __name__ == "__main__":
|
|
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
+
from src.scraper.faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class SBMIFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from SBMI websites."""
|
|
|
|
| 31 |
Returns:
|
| 32 |
List: List of faculty divs
|
| 33 |
"""
|
| 34 |
+
# Look for divs with onclick attributes that contain faculty URLs
|
| 35 |
+
faculty_divs = self.soup.find_all('div', attrs={'onclick': lambda x: x and 'window.location' in x and 'faculty-and-staff' in x})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Filter out empty or invalid divs
|
| 38 |
return [div for div in faculty_divs if div and div.get_text().strip()]
|
|
|
|
| 48 |
Returns:
|
| 49 |
Optional[str]: Faculty name if found, None otherwise
|
| 50 |
"""
|
| 51 |
+
# Look for the name in the fac-nam span
|
| 52 |
+
name_element = faculty_div.select_one('.fac-nam strong')
|
| 53 |
+
if name_element:
|
| 54 |
+
name = name_element.get_text().strip()
|
| 55 |
+
# Clean up common title patterns and suffixes
|
| 56 |
+
name = self._clean_name(name)
|
| 57 |
+
if name and len(name) > 2 and ' ' in name: # Ensure it's a full name
|
| 58 |
+
return name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
return None
|
| 61 |
|
|
|
|
| 82 |
|
| 83 |
return name.strip()
|
| 84 |
|
| 85 |
+
def _extract_areas_of_expertise(self, faculty_div) -> List[str]:
|
|
|
|
| 86 |
"""
|
| 87 |
+
Extract areas of expertise from the faculty div.
|
| 88 |
|
| 89 |
Args:
|
| 90 |
faculty_div: BeautifulSoup element containing faculty info
|
| 91 |
|
| 92 |
Returns:
|
| 93 |
+
List[str]: List of areas of expertise
|
| 94 |
"""
|
| 95 |
+
areas = []
|
| 96 |
+
# Look for text after "Areas of Expertise" and before "click for full bio"
|
| 97 |
+
text_content = faculty_div.get_text()
|
| 98 |
+
if "Areas of Expertise" in text_content:
|
| 99 |
+
expertise_section = text_content.split("Areas of Expertise")[1].split("click for full bio")[0]
|
| 100 |
+
# Split by "»" and clean up each area
|
| 101 |
+
for line in expertise_section.split("»"):
|
| 102 |
+
area = line.strip()
|
| 103 |
+
if area and not area.startswith("click for full bio"):
|
| 104 |
+
areas.append(area.strip())
|
| 105 |
+
return areas
|
| 106 |
+
|
| 107 |
+
@override
|
| 108 |
+
def _extract_position(self, faculty_div) -> Optional[str]:
|
| 109 |
+
"""
|
| 110 |
+
Extract faculty position/title.
|
| 111 |
|
| 112 |
+
Args:
|
| 113 |
+
faculty_div: BeautifulSoup element containing faculty info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
Returns:
|
| 116 |
+
Optional[str]: Position if found, None otherwise
|
| 117 |
+
"""
|
| 118 |
+
# Look for the position in the em tag after the name
|
| 119 |
+
position_element = faculty_div.select_one('.fac-nam + em')
|
| 120 |
+
if position_element:
|
| 121 |
+
return position_element.get_text().strip()
|
| 122 |
+
|
| 123 |
return None
|
| 124 |
|
| 125 |
@override
|
| 126 |
+
def _extract_profile_url(self, faculty_div) -> Optional[str]:
|
| 127 |
"""
|
| 128 |
+
Extract the profile URL from the faculty div.
|
| 129 |
|
| 130 |
Args:
|
| 131 |
faculty_div: BeautifulSoup element containing faculty info
|
| 132 |
|
| 133 |
Returns:
|
| 134 |
+
Optional[str]: Profile URL if found, None otherwise
|
| 135 |
"""
|
| 136 |
+
# Extract URL from onclick attribute
|
| 137 |
+
onclick = faculty_div.get('onclick', '')
|
| 138 |
+
if 'window.location' in onclick:
|
| 139 |
+
# Extract URL between quotes
|
| 140 |
+
start = onclick.find("'") + 1
|
| 141 |
+
end = onclick.find("'", start)
|
| 142 |
+
if start != -1 and end != -1:
|
| 143 |
+
url = onclick[start:end]
|
| 144 |
+
if url and not url.startswith(('mailto:', 'tel:', '#', 'javascript:')):
|
| 145 |
+
return url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
return None
|
| 148 |
|
| 149 |
+
@override
|
| 150 |
+
def _extract_image_url(self, faculty_div) -> Optional[str]:
|
| 151 |
"""
|
| 152 |
+
Extract faculty image URL.
|
| 153 |
|
| 154 |
Args:
|
| 155 |
faculty_div: BeautifulSoup element containing faculty info
|
| 156 |
|
| 157 |
Returns:
|
| 158 |
+
Optional[str]: Image URL if found, None otherwise
|
| 159 |
"""
|
| 160 |
+
# Look for img tag within the photo div
|
| 161 |
+
img_tag = faculty_div.select_one('.photo img')
|
| 162 |
+
if img_tag:
|
| 163 |
+
src = img_tag.get('src')
|
| 164 |
+
if src and not any(placeholder in src.lower() for placeholder in
|
| 165 |
+
['placeholder', 'default', 'no-image', 'blank', 'missing']):
|
| 166 |
+
return self.get_absolute_url(self.base_url, src)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
return None
|
| 169 |
|
| 170 |
@override
|
|
|
|
| 217 |
if position:
|
| 218 |
faculty_info['position'] = position
|
| 219 |
|
| 220 |
+
# Extract areas of expertise
|
| 221 |
+
areas = self._extract_areas_of_expertise(faculty_div)
|
| 222 |
+
if areas:
|
| 223 |
+
faculty_info['areas_of_expertise'] = areas
|
| 224 |
+
|
| 225 |
# Extract profile URL and get profile summary
|
| 226 |
profile_url = self._extract_profile_url(faculty_div)
|
| 227 |
if profile_url:
|
|
|
|
| 250 |
base_url = 'https://sbmi.uth.edu/faculty-and-staff/'
|
| 251 |
|
| 252 |
# Create scraper instance and run
|
| 253 |
+
scraper = SBMIFacultyScraper(base_url, debug=False)
|
| 254 |
faculty_list = scraper.scrape_faculty_list()
|
| 255 |
+
file_name = 'data/sbmi_faculty_list.jsonl'
|
| 256 |
# Save the faculty list as jsonl file
|
| 257 |
+
scraper.save_to_jsonl(file_name)
|
| 258 |
|
| 259 |
|
| 260 |
if __name__ == "__main__":
|
src/{sph_faculty_scraper.py → scraper/sph_faculty_scraper.py}
RENAMED
|
@@ -6,7 +6,7 @@ from typing_extensions import override
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
-
from faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class SPHFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from SPH websites."""
|
|
@@ -98,12 +98,9 @@ def main():
|
|
| 98 |
base_url = 'https://sph.uth.edu/faculty/'
|
| 99 |
|
| 100 |
# Create scraper instance and run
|
| 101 |
-
scraper = SPHFacultyScraper(base_url, debug=
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
with open('data/faculty_list.jsonl', 'w') as f:
|
| 105 |
-
for faculty in faculty_list:
|
| 106 |
-
f.write(json.dumps(faculty) + '\n')
|
| 107 |
|
| 108 |
|
| 109 |
if __name__ == "__main__":
|
|
|
|
| 6 |
import time
|
| 7 |
from urllib.parse import urljoin
|
| 8 |
from summarize import summarize
|
| 9 |
+
from src.scraper.faculty_scraper import FacultyScraper
|
| 10 |
|
| 11 |
class SPHFacultyScraper(FacultyScraper):
|
| 12 |
"""A class to scrape faculty information from SPH websites."""
|
|
|
|
| 98 |
base_url = 'https://sph.uth.edu/faculty/'
|
| 99 |
|
| 100 |
# Create scraper instance and run
|
| 101 |
+
scraper = SPHFacultyScraper(base_url, debug=False)
|
| 102 |
+
scraper.scrape_faculty_list()
|
| 103 |
+
scraper.save_to_jsonl('data/sph_faculty_list.jsonl')
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
src/summarize.py
CHANGED
|
@@ -6,7 +6,7 @@ from dotenv import load_dotenv
|
|
| 6 |
from bs4 import BeautifulSoup
|
| 7 |
from IPython.display import Markdown, display
|
| 8 |
from openai import OpenAI
|
| 9 |
-
import profile_scraper as profile_scraper
|
| 10 |
# Load environment variables in a file called .env
|
| 11 |
|
| 12 |
load_dotenv(override=True)
|
|
@@ -28,18 +28,15 @@ else:
|
|
| 28 |
|
| 29 |
# Define our system prompt - you can experiment with this later, changing the last sentence to 'Respond in markdown in Spanish."
|
| 30 |
|
| 31 |
-
system_prompt =
|
| 32 |
-
and provides a short summary, ignoring text that might be navigation related. \
|
| 33 |
-
Respond in markdown."
|
| 34 |
|
| 35 |
# A function that writes a User Prompt that asks for summaries of websites:
|
| 36 |
|
| 37 |
def user_prompt_for(website):
|
| 38 |
-
user_prompt = f"You are looking at a
|
| 39 |
user_prompt += "\nThe contents of this website is as follows; \
|
| 40 |
-
please provide a
|
| 41 |
-
|
| 42 |
-
user_prompt += website.text
|
| 43 |
return user_prompt
|
| 44 |
|
| 45 |
# See how this function creates exactly the format above
|
|
@@ -50,12 +47,20 @@ def messages_for(website):
|
|
| 50 |
{"role": "user", "content": user_prompt_for(website)}
|
| 51 |
]
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# And now: call the OpenAI API. You will get very familiar with this!
|
| 54 |
|
| 55 |
-
def summarize(
|
| 56 |
-
website = profile_scraper.FacultyProfileScraper(url)
|
| 57 |
response = openai.chat.completions.create(
|
| 58 |
model = "gpt-4o-mini",
|
| 59 |
messages = messages_for(website)
|
| 60 |
)
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from bs4 import BeautifulSoup
|
| 7 |
from IPython.display import Markdown, display
|
| 8 |
from openai import OpenAI
|
| 9 |
+
import src.scraper.profile_scraper as profile_scraper
|
| 10 |
# Load environment variables in a file called .env
|
| 11 |
|
| 12 |
load_dotenv(override=True)
|
|
|
|
| 28 |
|
| 29 |
# Define our system prompt - you can experiment with this later, changing the last sentence to 'Respond in markdown in Spanish."
|
| 30 |
|
| 31 |
+
system_prompt = '''You are an assistant helping to remove unrelated html elements and put everything in a single text file'''
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# A function that writes a User Prompt that asks for summaries of websites:
|
| 34 |
|
| 35 |
def user_prompt_for(website):
|
| 36 |
+
user_prompt = f"You are looking at a faculty member's website"
|
| 37 |
user_prompt += "\nThe contents of this website is as follows; \
|
| 38 |
+
please provide a processed text file\n"
|
| 39 |
+
user_prompt += website
|
|
|
|
| 40 |
return user_prompt
|
| 41 |
|
| 42 |
# See how this function creates exactly the format above
|
|
|
|
| 47 |
{"role": "user", "content": user_prompt_for(website)}
|
| 48 |
]
|
| 49 |
|
| 50 |
+
def remove_prefix_and_suffix(text):
|
| 51 |
+
# only keep text between ``` and ```
|
| 52 |
+
text = text.split("```")[1]
|
| 53 |
+
return text
|
| 54 |
+
|
| 55 |
# And now: call the OpenAI API. You will get very familiar with this!
|
| 56 |
|
| 57 |
+
def summarize(website):
|
|
|
|
| 58 |
response = openai.chat.completions.create(
|
| 59 |
model = "gpt-4o-mini",
|
| 60 |
messages = messages_for(website)
|
| 61 |
)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
return response.choices[0].message.content
|
| 65 |
+
|
| 66 |
+
|