Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,12 +4,9 @@ import py_vncorenlp
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
-
save_dir_vncore =
|
| 8 |
-
py_vncorenlp.download_model(save_dir=save_dir_vncore)
|
| 9 |
rdrsegmenter = py_vncorenlp.VnCoreNLP(annotators=["wseg"], save_dir=save_dir_vncore)
|
| 10 |
|
| 11 |
-
# Initialize vncorenlp with the JAR file path
|
| 12 |
-
word_segmenter = py_vncorenlp.VnCoreNLP(vncorenlp_path, annotators=["wseg"])
|
| 13 |
|
| 14 |
# Load your cross-encoder model
|
| 15 |
model_name = "truong1301/reranker_pho_BLAI" # Replace with your actual model if different
|
|
@@ -19,7 +16,7 @@ cross_encoder = CrossEncoder(model_name, max_length=256, num_labels=1)
|
|
| 19 |
def preprocess_text(text):
|
| 20 |
if not text:
|
| 21 |
return text
|
| 22 |
-
segmented_text =
|
| 23 |
# Join tokenized sentences into a single string
|
| 24 |
return " ".join([" ".join(sentence) for sentence in segmented_text])
|
| 25 |
|
|
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
+
save_dir_vncore = "/home/user/app/reranking/vncorenlp"
|
|
|
|
| 8 |
rdrsegmenter = py_vncorenlp.VnCoreNLP(annotators=["wseg"], save_dir=save_dir_vncore)
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Load your cross-encoder model
|
| 12 |
model_name = "truong1301/reranker_pho_BLAI" # Replace with your actual model if different
|
|
|
|
| 16 |
def preprocess_text(text):
|
| 17 |
if not text:
|
| 18 |
return text
|
| 19 |
+
segmented_text = rdrsegmenter.word_segment(text)
|
| 20 |
# Join tokenized sentences into a single string
|
| 21 |
return " ".join([" ".join(sentence) for sentence in segmented_text])
|
| 22 |
|