Skip to content

Commit beb5438

Browse files
authored
去除Rate of growth,补充提交之前修改 (#111)
1 parent 2123bee commit beb5438

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

data/caption/caption_2nd/params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232

3333
proloculus_shape_classes = {"spherical": [0, 0.33], "normal": [0.33, 0.67], "kidney-shaped": [0.67, 1]}
3434

35+
volution_coiled_classes = {
36+
"tightly coiled": [0, 0.150],
37+
"moderately coiled": [0.150, 0.2],
38+
"lossely expanded": [0.2, 999],
39+
}
40+
3541
tunnel_angle_classes = {"narrow": [0, 20], "moderate": [21, 30], "broad": [31, 99]}
3642

3743
chomata_size_classes = {"small": [0, 0.06], "moderate": [0.06, 0.1], "massive": [0.1, 9999]}

data/caption/caption_2nd/volution.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,58 @@ def genVolutionHeightAndGrowthRate(self):
6464
return ""
6565
txt += txt1
6666
self.chamber_heights = txt1
67-
txt += "Rates of growth of {start} to {end} volution are ".format(
68-
start=ordinal_numbers[1], end=ordinal_numbers[len(self.volutions_table) - 1]
69-
)
67+
self.growth_rate_raw = []
68+
# txt += "Rates of growth of {start} to {end} volution are ".format(
69+
# start=ordinal_numbers[1], end=ordinal_numbers[len(self.volutions_table) - 1]
70+
# )
7071
for i in range(len(heights) - 1):
7172
txt2 += str(round(heights[i + 1] / heights[i], 1))
73+
self.growth_rate_raw.append(heights[i + 1] - heights[i])
7274
if i != len(heights) - 2:
7375
txt2 += ", "
7476
else:
7577
txt2 += ". "
76-
txt += txt2
77-
self.growth_rate = txt2
78+
# txt += txt2
79+
# self.growth_rate = txt2
80+
self.growth_rate = None
81+
txt += f"Volutions {self.getCoiled()}. "
7882
return txt
7983

84+
def processTwo(self, inner, outer):
85+
if "moderate" in inner[0]:
86+
return f"{outer[0]} in outer volutions"
87+
elif "moderate" in outer[0]:
88+
return f"{inner[0]} in first {inner[1] + 2} volutions"
89+
else:
90+
return f"{inner[0]} in first {inner[1] + 2} volutions while {outer[0]} in outer volutions"
91+
92+
def getCoiled(self):
93+
coiled = [self.standardRangeFilter(volution_coiled_classes, g) for g in self.growth_rate_raw]
94+
inner, outer = ["", -1], ["", -1]
95+
current_modify = inner
96+
# print("new sample:")
97+
# print(self.chamber_heights)
98+
for i, word in enumerate(coiled):
99+
# print(f"{i}th loop:",inner,outer)
100+
if current_modify[0] == "":
101+
current_modify[0] = word
102+
current_modify[1] = i
103+
elif current_modify[0] != word:
104+
current_modify = outer
105+
current_modify[0] = word
106+
current_modify[1] = i
107+
else:
108+
current_modify[1] = i
109+
if inner[0] != "":
110+
if outer[0] == "":
111+
return inner[0]
112+
elif outer[0] == inner[0]:
113+
return inner[0]
114+
else:
115+
return self.processTwo(inner, outer)
116+
else:
117+
return "moderately coiled"
118+
80119
def genUserInput(self):
81120
txt = "The number of volutions is {num}. ".format(num=self.num)
82121
txt += self.genVolutionHeightAndGrowthRate()

0 commit comments

Comments
 (0)