-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreading.py
More file actions
190 lines (149 loc) · 8.25 KB
/
Copy pathreading.py
File metadata and controls
190 lines (149 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python
# coding: utf-8
# In[1]:
class reading:
def __init__(self, api_key):
self.api_key = api_key
self.text = """**Passage:**
The widening gap between the wealthiest and poorest segments of society is a persistent and complex issue with far-reaching consequences. While economic growth often lifts the overall standard of living, its benefits are not always distributed equitably. This disparity, frequently referred to as income inequality, is fueled by a confluence of factors, including technological advancements that displace workers, globalization leading to competition for jobs and resources, and regressive tax policies that disproportionately benefit the wealthy. Furthermore, the concentration of wealth in the hands of a few often translates into disproportionate political influence, creating a feedback loop that reinforces existing inequalities. This influence can manifest in lobbying efforts that shape legislation in favor of the wealthy, hindering policies aimed at addressing income inequality, such as progressive taxation or increased social safety nets. The consequences of this widening gap are not merely economic; they extend to social cohesion, impacting health outcomes, educational attainment, and even crime rates. Studies consistently show a correlation between high levels of income inequality and reduced social mobility, trapping individuals and families in cycles of poverty. Addressing this requires multifaceted approaches, encompassing policy reforms, educational initiatives, and investment in social infrastructure. However, the political will to implement significant change often faces considerable resistance from vested interests.
**Questions:**
1. The passage primarily focuses on:
a) The benefits of economic growth.
b) Technological advancements and their impact on employment.
c) The widening gap between the wealthy and the poor.
d) Regressive tax policies and their effects.
2. According to the passage, what is a significant consequence of concentrated wealth?
a) Increased social mobility.
b) Disproportionate political influence.
c) Improved health outcomes.
d) Reduced crime rates.
3. The term "regressive tax policies" in the passage refers to policies that:
a) Tax the wealthy at a higher rate.
b) Tax the poor at a higher rate.
c) Tax everyone at the same rate.
d) Are designed to reduce income inequality.
4. The passage suggests that the widening income gap is:
a) A solely economic problem.
b) Easily solved through policy reforms alone.
c) A complex problem with multifaceted causes and consequences.
d) Primarily caused by technological advancements.
5. What is a "feedback loop" in the context of the passage?
a) A cyclical process of economic growth.
b) A system where concentrated wealth reinforces existing inequalities.
c) A method for measuring income inequality.
d) A type of progressive tax policy.
6. The passage implies that addressing income inequality requires:
a) Focusing solely on economic growth.
b) A singular policy reform.
c) Multifaceted approaches involving various strategies.
d) Ignoring the influence of vested interests.
7. The word "cohesion" in the passage most nearly means:
a) Separation
b) Unity
c) Conflict
d) Division
8. According to the passage, what is the relationship between income inequality and social mobility?
a) High income inequality leads to increased social mobility.
b) There is no relationship between income inequality and social mobility.
c) High income inequality is unrelated to poverty cycles.
d) High income inequality is correlated with reduced social mobility.
9. The author's tone in the passage can best be described as:
a) Optimistic
b) Biased
c) Informative and analytical
d) Emotional and subjective
10. Which of the following is NOT explicitly mentioned as a factor contributing to income inequality?
a) Technological advancements
b) Globalization
c) Climate change
d) Regressive tax policies
**Answer Key:**
1. b)
2. c)
3. c)
4. c)
5. b)
6. b)
7. b)
8. b)
9. b)
10. d)
"""
# 分數(-1)
def generateQustion(self, passScore):
import google.generativeai as genai
import pandas as pd
import re
import time
question = {
"Article":[],
"Question":[],
"A":[],
"B":[],
"C":[],
"D":[],
"Ans":[]
}
articleCnt = 0
while(1):
if articleCnt == 3:
break
genai.configure(api_key = self.api_key)
model = genai.GenerativeModel('gemini-pro')
chat = model.start_chat()
response = chat.send_message('請完全按照' + '\n' + self.text + '\n' + "生成'1篇文章10題選擇題的英文閱讀測驗'")
# get passage
# 定位文章的起點和結尾
start_keyword = "**Passage:**"
mid_keyword = "**Questions:**"
end_keyword = "**Answer Key:**"
# print(response.text)
# 找到關鍵字的位置
start_index = response.text.find(start_keyword)
mid_index = response.text.find(mid_keyword)
end_index = response.text.find(end_keyword)
# 提取題目、選項及文章
passage = response.text[start_index + len(start_keyword):mid_index].strip()
questions_text = response.text[mid_index + len(mid_keyword):end_index].strip()
answer_text = response.text[end_index + len(end_keyword):].strip()
# get question
# 按照題號切割
questions = re.split(r"\d+\.", questions_text)
Cnt = 0
for q in questions:
# 忽略空白行
if q.strip():
# 新增文章至question
if Cnt == 1:
question["Article"].append(passage)
else:
question["Article"].append(None)
q = q.strip().strip("\n").strip().strip("\n").strip().strip("\n")
q_text, *choices = q.split("\n")
q_text.strip()
# 取選項
choices[0] = choices[0].strip().strip('a').strip(')').strip('(').strip().strip('a').strip(')').strip('(')
choices[1] = choices[1].strip().strip('b').strip(')').strip('(').strip().strip('b').strip(')').strip('(')
choices[2] = choices[2].strip().strip('c').strip(')').strip('(').strip().strip('c').strip(')').strip('(')
choices[3] = choices[3].strip().strip('d').strip(')').strip('(').strip().strip('d').strip(')').strip('(')
# 加入 questions
question["Question"].append(q_text)
question["A"].append(choices[0])
question["B"].append(choices[1])
question["C"].append(choices[2])
question["D"].append(choices[3])
Cnt += 1
# get answer
answers = re.split(r"\d+\.", answer_text)
tempAnswerList = []
for a in answers:
if a.strip():
a = a.strip().strip("\n").strip().strip("\n").strip().strip("\n").strip(")").strip("(").split("\n")
question["Ans"] = question["Ans"] + a
articleCnt += 1
time.sleep(5)
# turn into dataframe
df = pd.DataFrame(question)
df['number'] = range(1, 31)
return df
# In[ ]: