ICTuniverse commited on
Commit
33860c8
·
verified ·
1 Parent(s): 28bc083

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -5,12 +5,19 @@ import os
5
 
6
  app = Flask(__name__)
7
 
8
- # Initialize vncorenlp (point to the JAR file in your folder)
9
- current_dir = 'reranking/vncorenlp'
10
- word_segmenter = py_vncorenlp.VnCoreNLP(save_dir=current_dir, annotators=["wseg"])
11
 
12
- # Load your cross-encoder model (replace with your model name or path)
13
- model_name = "truong1301/reranker_pho_BLAI" # Example model, replace with yours
 
 
 
 
 
 
 
14
  cross_encoder = CrossEncoder(model_name, max_length=256, num_labels=1)
15
 
16
  # Function to preprocess text with Vietnamese word segmentation
 
5
 
6
  app = Flask(__name__)
7
 
8
+ # Set the path to the VnCoreNLP JAR file
9
+ current_dir = os.path.dirname(os.path.abspath(__file__)) # Get the directory of app.py
10
+ vncorenlp_path = os.path.join(current_dir, "vncorenlp", "VnCoreNLP-1.2.jar")
11
 
12
+ # Check if the JAR file exists (for debugging)
13
+ if not os.path.exists(vncorenlp_path):
14
+ raise FileNotFoundError(f"VnCoreNLP JAR file not found at {vncorenlp_path}. Please ensure 'vncorenlp/VnCoreNLP-1.2.jar' is in the root directory.")
15
+
16
+ # Initialize vncorenlp with the JAR file path
17
+ word_segmenter = py_vncorenlp.VnCoreNLP(vncorenlp_path, annotators=["wseg"])
18
+
19
+ # Load your cross-encoder model
20
+ model_name = "truong1301/reranker_pho_BLAI" # Replace with your actual model if different
21
  cross_encoder = CrossEncoder(model_name, max_length=256, num_labels=1)
22
 
23
  # Function to preprocess text with Vietnamese word segmentation