Update app.py
Browse files
app.py
CHANGED
@@ -154,58 +154,51 @@ with col2:
|
|
154 |
value=selected_pair["code2"] if selected_pair else "",
|
155 |
help="Enter the second Java code snippet"
|
156 |
)
|
157 |
-
|
158 |
-
# Threshold slider
|
159 |
threshold = st.slider(
|
160 |
"Clone Detection Threshold",
|
161 |
-
min_value=0.
|
162 |
-
max_value=1.
|
163 |
-
value=0.
|
164 |
step=0.01,
|
165 |
-
help="
|
166 |
)
|
167 |
|
168 |
-
#
|
169 |
-
if
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
with tab1:
|
204 |
-
st.code(normalize_code(code1))
|
205 |
-
|
206 |
-
with tab2:
|
207 |
-
st.code(normalize_code(code2))
|
208 |
-
|
209 |
# Footer
|
210 |
st.markdown("---")
|
211 |
st.markdown("""
|
|
|
154 |
value=selected_pair["code2"] if selected_pair else "",
|
155 |
help="Enter the second Java code snippet"
|
156 |
)
|
157 |
+
# Threshold slider with proper value handling
|
|
|
158 |
threshold = st.slider(
|
159 |
"Clone Detection Threshold",
|
160 |
+
min_value=0.50,
|
161 |
+
max_value=1.00,
|
162 |
+
value=0.75, # Default middle value
|
163 |
step=0.01,
|
164 |
+
help="Similarity score needed to consider code as cloned (0.5-1.0)"
|
165 |
)
|
166 |
|
167 |
+
# In your comparison logic:
|
168 |
+
if similarity is not None:
|
169 |
+
# Display results with threshold comparison
|
170 |
+
is_clone = similarity >= threshold
|
171 |
+
|
172 |
+
st.subheader("Results")
|
173 |
+
col1, col2, col3 = st.columns(3)
|
174 |
+
|
175 |
+
with col1:
|
176 |
+
st.metric("Similarity Score", f"{similarity:.3f}")
|
177 |
+
|
178 |
+
with col2:
|
179 |
+
# Show the current threshold being used
|
180 |
+
st.metric("Current Threshold", f"{threshold:.3f}")
|
181 |
+
|
182 |
+
with col3:
|
183 |
+
# Visual clone decision
|
184 |
+
st.metric(
|
185 |
+
"Verdict",
|
186 |
+
"✅ CLONE" if is_clone else "❌ NOT CLONE",
|
187 |
+
delta=f"{similarity-threshold:+.3f}",
|
188 |
+
help=f"Score {'≥' if is_clone else '<'} threshold"
|
189 |
+
)
|
190 |
+
|
191 |
+
# Visual indicator
|
192 |
+
st.progress(similarity)
|
193 |
+
|
194 |
+
# Interpretation guide
|
195 |
+
with st.expander("Interpretation Guide"):
|
196 |
+
st.markdown("""
|
197 |
+
- **> 0.95**: Nearly identical (Type-1 clone)
|
198 |
+
- **0.85-0.95**: Very similar (Type-2 clone)
|
199 |
+
- **0.70-0.85**: Similar structure (Type-3 clone)
|
200 |
+
- **< 0.70**: Different code
|
201 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
# Footer
|
203 |
st.markdown("---")
|
204 |
st.markdown("""
|