Skip to content

Commit a22be47

Browse files
committed
add example
1 parent 8d76c4b commit a22be47

File tree

3 files changed

+73
-18
lines changed

3 files changed

+73
-18
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
Module for showing how PDFScraper works
3+
"""
4+
from scrapegraphai.graphs import PDFScraperGraph
5+
6+
graph_config = {
7+
"llm": {
8+
"model": "ollama/llama3",
9+
"temperature": 0,
10+
"format": "json", # Ollama needs the format to be specified explicitly
11+
"model_tokens": 4000,
12+
},
13+
"embeddings": {
14+
"model": "ollama/nomic-embed-text",
15+
"temperature": 0,
16+
},
17+
"verbose": True,
18+
"headless": False,
19+
}
20+
21+
# Covert to list
22+
sources = [
23+
"This paper provides evidence from a natural experiment on the relationship between positive affect and productivity. We link highly detailed administrative data on the behaviors and performance of all telesales workers at a large telecommunications company with survey reports of employee happiness that we collected on a weekly basis. We use variation in worker mood arising from visual exposure to weather—the interaction between call center architecture and outdoor weather conditions—in order to provide a quasi-experimental test of the effect of happiness on productivity. We find evidence of a positive impact on sales performance, which is driven by changes in labor productivity – largely through workers converting more calls into sales, and to a lesser extent by making more calls per hour and adhering more closely to their schedule. We find no evidence in our setting of effects on measures of high-frequency labor supply such as attendance and break-taking.",
24+
"The diffusion of social media coincided with a worsening of mental health conditions among adolescents and young adults in the United States, giving rise to speculation that social media might be detrimental to mental health. In this paper, we provide quasi-experimental estimates of the impact of social media on mental health by leveraging a unique natural experiment: the staggered introduction of Facebook across U.S. colleges. Our analysis couples data on student mental health around the years of Facebook's expansion with a generalized difference-in-differences empirical strategy. We find that the roll-out of Facebook at a college increased symptoms of poor mental health, especially depression. We also find that, among students predicted to be most susceptible to mental illness, the introduction of Facebook led to increased utilization of mental healthcare services. Lastly, we find that, after the introduction of Facebook, students were more likely to report experiencing impairments to academic performance resulting from poor mental health. Additional evidence on mechanisms suggests that the results are due to Facebook fostering unfavorable social comparisons.",
25+
"Hollywood films are generally released first in the United States and then later abroad, with some variation in lags across films and countries. With the growth in movie piracy since the appearance of BitTorrent in 2003, films have become available through illegal piracy immediately after release in the US, while they are not available for legal viewing abroad until their foreign premieres in each country. We make use of this variation in international release lags to ask whether longer lags – which facilitate more local pre-release piracy – depress theatrical box office receipts, particularly after the widespread adoption of BitTorrent. We find that longer release windows are associated with decreased box office returns, even after controlling for film and country fixed effects. This relationship is much stronger in contexts where piracy is more prevalent: after BitTorrent’s adoption and in heavily-pirated genres. Our findings indicate that, as a lower bound, international box office returns in our sample were at least 7% lower than they would have been in the absence of pre-release piracy. By contrast, we do not see evidence of elevated sales displacement in US box office revenue following the adoption of BitTorrent, and we suggest that delayed legal availability of the content abroad may drive the losses to piracy."
26+
# Add more sources here
27+
]
28+
29+
prompt = """
30+
You are an expert in reviewing academic manuscripts. Please analyze the abstracts provided from an academic journal article to extract and clearly identify the following elements:
31+
32+
Independent Variable (IV): The variable that is manipulated or considered as the primary cause affecting other variables.
33+
Dependent Variable (DV): The variable that is measured or observed, which is expected to change as a result of variations in the Independent Variable.
34+
Exogenous Shock: Identify any external or unexpected events used in the study that serve as a natural experiment or provide a unique setting for observing the effects on the IV and DV.
35+
Response Format: For each abstract, present your response in the following structured format:
36+
37+
Independent Variable (IV):
38+
Dependent Variable (DV):
39+
Exogenous Shock:
40+
41+
Example Queries and Responses:
42+
43+
Query: This paper provides evidence from a natural experiment on the relationship between positive affect and productivity. We link highly detailed administrative data on the behaviors and performance of all telesales workers at a large telecommunications company with survey reports of employee happiness that we collected on a weekly basis. We use variation in worker mood arising from visual exposure to weather the interaction between call center architecture and outdoor weather conditions in order to provide a quasi-experimental test of the effect of happiness on productivity. We find evidence of a positive impact on sales performance, which is driven by changes in labor productivity largely through workers converting more calls into sales, and to a lesser extent by making more calls per hour and adhering more closely to their schedule. We find no evidence in our setting of effects on measures of high-frequency labor supply such as attendance and break-taking.
44+
45+
Response:
46+
47+
Independent Variable (IV): Employee happiness.
48+
Dependent Variable (DV): Overall firm productivity.
49+
Exogenous Shock: Sudden company-wide increase in bonus payments.
50+
51+
Query: The diffusion of social media coincided with a worsening of mental health conditions among adolescents and young adults in the United States, giving rise to speculation that social media might be detrimental to mental health. In this paper, we provide quasi-experimental estimates of the impact of social media on mental health by leveraging a unique natural experiment: the staggered introduction of Facebook across U.S. colleges. Our analysis couples data on student mental health around the years of Facebook's expansion with a generalized difference-in-differences empirical strategy. We find that the roll-out of Facebook at a college increased symptoms of poor mental health, especially depression. We also find that, among students predicted to be most susceptible to mental illness, the introduction of Facebook led to increased utilization of mental healthcare services. Lastly, we find that, after the introduction of Facebook, students were more likely to report experiencing impairments to academic performance resulting from poor mental health. Additional evidence on mechanisms suggests that the results are due to Facebook fostering unfavorable social comparisons.
52+
53+
Response:
54+
55+
Independent Variable (IV): Exposure to social media.
56+
Dependent Variable (DV): Mental health outcomes.
57+
Exogenous Shock: staggered introduction of Facebook across U.S. colleges.
58+
"""
59+
results = []
60+
for source in sources:
61+
pdf_scraper_graph = PDFScraperGraph(
62+
prompt=prompt,
63+
source=source,
64+
config=graph_config
65+
)
66+
result = pdf_scraper_graph.run()
67+
results.append(result)
68+
69+
print(results)

requirements-dev.lock

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ botocore==1.34.113
4848
# via boto3
4949
# via s3transfer
5050
burr==0.19.1
51-
# via burr
5251
# via scrapegraphai
5352
cachetools==5.3.3
5453
# via google-auth
@@ -64,13 +63,6 @@ click==8.1.7
6463
# via streamlit
6564
# via typer
6665
# via uvicorn
67-
colorama==0.4.6
68-
# via click
69-
# via loguru
70-
# via pytest
71-
# via sphinx
72-
# via tqdm
73-
# via uvicorn
7466
contourpy==1.2.1
7567
# via matplotlib
7668
cycler==0.12.1
@@ -144,7 +136,6 @@ graphviz==0.20.3
144136
# via scrapegraphai
145137
greenlet==3.0.3
146138
# via playwright
147-
# via sqlalchemy
148139
groq==0.8.0
149140
# via langchain-groq
150141
grpcio==1.64.0
@@ -475,19 +466,17 @@ undetected-playwright==0.3.0
475466
# via scrapegraphai
476467
uritemplate==4.1.1
477468
# via google-api-python-client
478-
urllib3==2.2.1
469+
urllib3==1.26.18
479470
# via botocore
480471
# via requests
481472
uvicorn==0.29.0
482473
# via burr
483474
# via fastapi
484-
watchdog==4.0.1
485-
# via streamlit
475+
uvloop==0.19.0
476+
# via uvicorn
486477
watchfiles==0.21.0
487478
# via uvicorn
488479
websockets==12.0
489480
# via uvicorn
490-
win32-setctime==1.1.0
491-
# via loguru
492481
yarl==1.9.4
493482
# via aiohttp

requirements.lock

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ certifi==2024.2.2
4040
# via requests
4141
charset-normalizer==3.3.2
4242
# via requests
43-
colorama==0.4.6
44-
# via tqdm
4543
dataclasses-json==0.6.6
4644
# via langchain
4745
# via langchain-community
@@ -89,7 +87,6 @@ graphviz==0.20.3
8987
# via scrapegraphai
9088
greenlet==3.0.3
9189
# via playwright
92-
# via sqlalchemy
9390
groq==0.8.0
9491
# via langchain-groq
9592
grpcio==1.64.0
@@ -287,7 +284,7 @@ undetected-playwright==0.3.0
287284
# via scrapegraphai
288285
uritemplate==4.1.1
289286
# via google-api-python-client
290-
urllib3==2.2.1
287+
urllib3==1.26.18
291288
# via botocore
292289
# via requests
293290
yarl==1.9.4

0 commit comments

Comments
 (0)