Spaces:
Runtime error
Runtime error
jaifar530
commited on
fix bugs
Browse files
app.py
CHANGED
|
@@ -51,7 +51,7 @@ with open('RandomForestClassifier.pkl', 'rb') as file:
|
|
| 51 |
|
| 52 |
input_paragraph = st.text_area("Input your text here")
|
| 53 |
df = pd.DataFrame(columns=["paragraph"])
|
| 54 |
-
df = df.
|
| 55 |
|
| 56 |
num_words = 500
|
| 57 |
input_paragraph = ' '.join(word_tokenize(input_paragraph)[:num_words])
|
|
@@ -65,6 +65,7 @@ def extract_features(text):
|
|
| 65 |
stopword_count = len([word for word in words if word in stopwords.words('english')])
|
| 66 |
lemma_count = len(set(lemmatizer.lemmatize(word) for word in words))
|
| 67 |
named_entity_count = get_entities(text)
|
|
|
|
| 68 |
tagged_words = nltk.pos_tag(words)
|
| 69 |
pos_counts = nltk.FreqDist(tag for (word, tag) in tagged_words)
|
| 70 |
pos_features = {
|
|
@@ -101,7 +102,7 @@ if press_me_button:
|
|
| 101 |
input_features = df['paragraph'].apply(extract_features)
|
| 102 |
predicted_llm = clf_loaded.predict(input_features)
|
| 103 |
st.write(f"Predicted LLM: {predicted_llm[0]}")
|
| 104 |
-
|
| 105 |
predicted_proba = clf_loaded.predict_proba(input_features)
|
| 106 |
probabilities = predicted_proba[0]
|
| 107 |
labels = clf_loaded.classes_
|
|
@@ -116,4 +117,4 @@ if press_me_button:
|
|
| 116 |
prob_dict = dict(zip(new_labels, probabilities))
|
| 117 |
|
| 118 |
# Print the dictionary
|
| 119 |
-
|
|
|
|
| 51 |
|
| 52 |
input_paragraph = st.text_area("Input your text here")
|
| 53 |
df = pd.DataFrame(columns=["paragraph"])
|
| 54 |
+
df = df.concat({"paragraph": input_paragraph}, ignore_index=True)
|
| 55 |
|
| 56 |
num_words = 500
|
| 57 |
input_paragraph = ' '.join(word_tokenize(input_paragraph)[:num_words])
|
|
|
|
| 65 |
stopword_count = len([word for word in words if word in stopwords.words('english')])
|
| 66 |
lemma_count = len(set(lemmatizer.lemmatize(word) for word in words))
|
| 67 |
named_entity_count = get_entities(text)
|
| 68 |
+
st.write(named_entity_count)
|
| 69 |
tagged_words = nltk.pos_tag(words)
|
| 70 |
pos_counts = nltk.FreqDist(tag for (word, tag) in tagged_words)
|
| 71 |
pos_features = {
|
|
|
|
| 102 |
input_features = df['paragraph'].apply(extract_features)
|
| 103 |
predicted_llm = clf_loaded.predict(input_features)
|
| 104 |
st.write(f"Predicted LLM: {predicted_llm[0]}")
|
| 105 |
+
|
| 106 |
predicted_proba = clf_loaded.predict_proba(input_features)
|
| 107 |
probabilities = predicted_proba[0]
|
| 108 |
labels = clf_loaded.classes_
|
|
|
|
| 117 |
prob_dict = dict(zip(new_labels, probabilities))
|
| 118 |
|
| 119 |
# Print the dictionary
|
| 120 |
+
st.write(prob_dict)
|