KrishanRao commited on
Commit
90bfb01
·
verified ·
1 Parent(s): acf3891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -12,7 +12,6 @@ def extract_text(url):
12
  return text
13
 
14
  # Load Hugging Face model (for extracting named entities or QA)
15
- # Here we use a named entity recognition model, but you can use a question answering model if needed
16
  ner_model = pipeline("ner", model="dbmdz/bert-large-cased-finetuned-conll03-english")
17
 
18
  # Function to extract information using Hugging Face model
@@ -20,7 +19,7 @@ def extract_info_with_model(text):
20
  # Apply named entity recognition (NER) to extract entities from the text
21
  ner_results = ner_model(text)
22
 
23
- # You can refine this based on the type of entity or information you want to extract
24
  keytags = []
25
  seller_name = ""
26
  location_details = ""
@@ -37,9 +36,8 @@ def extract_info_with_model(text):
37
  location_details = entity['word'] # Geopolitical entity as location
38
 
39
  # For amenities and facilities, you can modify the logic or use additional models (e.g., question-answering models)
40
- # For now, we'll just return a placeholder for these
41
- amenities = "No amenities found"
42
- facilities = "No facilities found"
43
 
44
  return {
45
  "Keytags": ", ".join(keytags) if keytags else "No keytags found",
@@ -53,7 +51,18 @@ def extract_info_with_model(text):
53
  def get_info(url):
54
  text = extract_text(url)
55
  extracted_info = extract_info_with_model(text)
56
- return extracted_info
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  # Gradio Interface to allow user input and display output
59
  demo = gr.Interface(
 
12
  return text
13
 
14
  # Load Hugging Face model (for extracting named entities or QA)
 
15
  ner_model = pipeline("ner", model="dbmdz/bert-large-cased-finetuned-conll03-english")
16
 
17
  # Function to extract information using Hugging Face model
 
19
  # Apply named entity recognition (NER) to extract entities from the text
20
  ner_results = ner_model(text)
21
 
22
+ # Initialize variables
23
  keytags = []
24
  seller_name = ""
25
  location_details = ""
 
36
  location_details = entity['word'] # Geopolitical entity as location
37
 
38
  # For amenities and facilities, you can modify the logic or use additional models (e.g., question-answering models)
39
+ amenities = "No amenities found" # Placeholder for the amenities
40
+ facilities = "No facilities found" # Placeholder for the facilities
 
41
 
42
  return {
43
  "Keytags": ", ".join(keytags) if keytags else "No keytags found",
 
51
  def get_info(url):
52
  text = extract_text(url)
53
  extracted_info = extract_info_with_model(text)
54
+
55
+ # Print debug to understand what's being returned
56
+ print(extracted_info)
57
+
58
+ # Ensure the information is returned in the expected format
59
+ return (
60
+ extracted_info["Keytags"],
61
+ extracted_info["Amenities"],
62
+ extracted_info["Facilities"],
63
+ extracted_info["Seller Name"],
64
+ extracted_info["Location Details"]
65
+ )
66
 
67
  # Gradio Interface to allow user input and display output
68
  demo = gr.Interface(