Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,7 +130,7 @@ STYLE = """
|
|
| 130 |
margin-top: -5px;
|
| 131 |
transform: rotate(315deg);
|
| 132 |
}
|
| 133 |
-
.
|
| 134 |
border: 1px solid var(--body-text-color);
|
| 135 |
padding: 5px;
|
| 136 |
border-radius: 5px;
|
|
@@ -142,17 +142,17 @@ STYLE = """
|
|
| 142 |
justify-content: space-between;
|
| 143 |
overflow: hidden;
|
| 144 |
}
|
| 145 |
-
.
|
| 146 |
padding: 5px;
|
| 147 |
font-size: 12px;
|
| 148 |
letter-spacing: 1px;
|
| 149 |
font-weight: 500;
|
| 150 |
}
|
| 151 |
/*Hover-Section*/
|
| 152 |
-
.
|
| 153 |
background: var(--primary-500);
|
| 154 |
}
|
| 155 |
-
.
|
| 156 |
border-color: var(--primary-500);
|
| 157 |
}
|
| 158 |
.chosen-token {
|
|
@@ -216,14 +216,14 @@ def generate_nodes(node, step):
|
|
| 216 |
selected_class = "selected-sequence"
|
| 217 |
else:
|
| 218 |
selected_class = "nonselected-sequence"
|
| 219 |
-
return f"<li> <
|
| 220 |
|
| 221 |
html_content = (
|
| 222 |
-
f"<li> <
|
| 223 |
)
|
| 224 |
if node.table is not None:
|
| 225 |
html_content += node.table
|
| 226 |
-
html_content += "</
|
| 227 |
|
| 228 |
if len(node.children.keys()) > 0:
|
| 229 |
html_content += "<ul> "
|
|
@@ -238,13 +238,12 @@ def generate_nodes(node, step):
|
|
| 238 |
def generate_html(start_sentence, original_tree):
|
| 239 |
html_output = f"""<div class="custom-container">
|
| 240 |
<div class="tree">
|
| 241 |
-
<
|
| 242 |
html_output += "<ul> "
|
| 243 |
for subnode in original_tree.children.values():
|
| 244 |
html_output += generate_nodes(subnode, step=1)
|
| 245 |
html_output += "</ul>"
|
| 246 |
html_output += """
|
| 247 |
-
</li> </ul>
|
| 248 |
</div>
|
| 249 |
</body>
|
| 250 |
"""
|
|
|
|
| 130 |
margin-top: -5px;
|
| 131 |
transform: rotate(315deg);
|
| 132 |
}
|
| 133 |
+
.box {
|
| 134 |
border: 1px solid var(--body-text-color);
|
| 135 |
padding: 5px;
|
| 136 |
border-radius: 5px;
|
|
|
|
| 142 |
justify-content: space-between;
|
| 143 |
overflow: hidden;
|
| 144 |
}
|
| 145 |
+
.box span {
|
| 146 |
padding: 5px;
|
| 147 |
font-size: 12px;
|
| 148 |
letter-spacing: 1px;
|
| 149 |
font-weight: 500;
|
| 150 |
}
|
| 151 |
/*Hover-Section*/
|
| 152 |
+
.box:hover, .box:hover+ul li .box {
|
| 153 |
background: var(--primary-500);
|
| 154 |
}
|
| 155 |
+
.box:hover+ul li::after, .box:hover+ul li::before, .box:hover+ul::before, .box:hover+ul ul::before, .box:hover+ul .box::before {
|
| 156 |
border-color: var(--primary-500);
|
| 157 |
}
|
| 158 |
.chosen-token {
|
|
|
|
| 216 |
selected_class = "selected-sequence"
|
| 217 |
else:
|
| 218 |
selected_class = "nonselected-sequence"
|
| 219 |
+
return f"<li> <div class='box end-of-text child {selected_class}'> <span> <b>{clean(token)}</b> <br>Total score: {node.total_score:.2f}</span> </div> </li>"
|
| 220 |
|
| 221 |
html_content = (
|
| 222 |
+
f"<li> <div class='box nonfinal child'> <span> <b>{clean(token)}</b> </span>"
|
| 223 |
)
|
| 224 |
if node.table is not None:
|
| 225 |
html_content += node.table
|
| 226 |
+
html_content += "</div>"
|
| 227 |
|
| 228 |
if len(node.children.keys()) > 0:
|
| 229 |
html_content += "<ul> "
|
|
|
|
| 238 |
def generate_html(start_sentence, original_tree):
|
| 239 |
html_output = f"""<div class="custom-container">
|
| 240 |
<div class="tree">
|
| 241 |
+
<div class="box" href='#' id='root'> <span> <b>{start_sentence}</b> </span> {original_tree.table} </div>"""
|
| 242 |
html_output += "<ul> "
|
| 243 |
for subnode in original_tree.children.values():
|
| 244 |
html_output += generate_nodes(subnode, step=1)
|
| 245 |
html_output += "</ul>"
|
| 246 |
html_output += """
|
|
|
|
| 247 |
</div>
|
| 248 |
</body>
|
| 249 |
"""
|