Maulidaaa commited on
Commit
1e22ab1
·
verified ·
1 Parent(s): 73d3d96

Update app/routes.py

Browse files
Files changed (1) hide show
  1. app/routes.py +5 -2
app/routes.py CHANGED
@@ -15,9 +15,12 @@ logging.basicConfig(level=logging.INFO)
15
  # Load data and model once
16
  df_cosing, df_brand, product_embeddings = load_data()
17
 
18
- # Fungsi untuk membersihkan prefix seperti "Ingredients:", "Komposisi:", dll
19
  def clean_ingredient_name(name):
20
- return re.sub(r'(?i)\b(ingredients|komposisi|composition)\b\s*[:\-]?\s*', '', name).strip()
 
 
 
 
21
 
22
  @analyze_blueprint.route("/analyze", methods=["POST"])
23
  def analyze_ingredients():
 
15
  # Load data and model once
16
  df_cosing, df_brand, product_embeddings = load_data()
17
 
 
18
  def clean_ingredient_name(name):
19
+ # Hapus awalan seperti "Ingredients:", "Komposisi-", "Composition/", dll
20
+ name = re.sub(r'(?i)\b(ingredients|komposisi|composition|bahan)\b\s*[:/\-]?\s*', '', name)
21
+ # Hapus simbol-simbol aneh di awal (seperti '/', '-', ':', dll)
22
+ name = re.sub(r'^[^\w]+', '', name)
23
+ return name.strip()
24
 
25
  @analyze_blueprint.route("/analyze", methods=["POST"])
26
  def analyze_ingredients():