research14 commited on
Commit
2d7bc30
1 Parent(s): 4281734

testing add custom ling ent

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -31,13 +31,11 @@ def linguistic_features_fn(message):
31
  # Use LFTK to dynamically extract handcrafted linguistic features
32
  extracted_features = LFTK.extract(features = ["a_word_ps", "a_kup_pw", "n_noun"])
33
 
34
- # Extract values only and convert them to a list
35
- values_list = list(extracted_features.values())
36
 
37
- # Print the values without braces and quotes
38
- print(*values_list)
39
 
40
- return values_list
41
 
42
  def update_api_key(new_key):
43
  print("update_api_key ran")
@@ -244,7 +242,9 @@ def interface():
244
  # Will activate after getting API key
245
  have_key2 = gr.Dropdown(["Yes", "No"], label="Do you own an API Key?", scale=0.5)
246
  ling_ents_apikey_input = gr.Textbox(label="Open AI Key", placeholder="Enter your Openai key here", type="password")
247
- linguistic_entities = gr.Dropdown(["Noun", "Determiner", "Noun phrase", "Verb phrase", "Dependent clause", "T-units"], label="Linguistic Entity")
 
 
248
  ling_ents_btn = gr.Button(value="Submit")
249
 
250
  # Outputs
@@ -262,9 +262,17 @@ def interface():
262
  # Event Handler for API Key
263
  ling_ents_btn.click(update_api_key, inputs=ling_ents_apikey_input)
264
 
 
 
 
 
 
 
 
 
265
  def update_textbox(prompt):
266
  return prompt
267
-
268
  ling_ents_btn.click(fn=update_textbox, inputs=ling_ents_prompt, outputs=user_prompt_1, api_name="ling_ents_btn")
269
 
270
  # Show features from LFTK
 
31
  # Use LFTK to dynamically extract handcrafted linguistic features
32
  extracted_features = LFTK.extract(features = ["a_word_ps", "a_kup_pw", "n_noun"])
33
 
34
+ formatted_output = json.dumps(extracted_features, indent=2)
 
35
 
36
+ print(formatted_output)
 
37
 
38
+ return formatted_output
39
 
40
  def update_api_key(new_key):
41
  print("update_api_key ran")
 
242
  # Will activate after getting API key
243
  have_key2 = gr.Dropdown(["Yes", "No"], label="Do you own an API Key?", scale=0.5)
244
  ling_ents_apikey_input = gr.Textbox(label="Open AI Key", placeholder="Enter your Openai key here", type="password")
245
+ linguistic_entities = gr.Dropdown(["Noun", "Determiner", "Noun phrase", "Verb phrase", "Dependent clause", "T-units", "Other"], label="Linguistic Entity")
246
+ with gr.Accordion("If other, enter your own Linguistic Entity here:"):
247
+ linguistic_entities_other = gr.Textbox(show_label=False, placeholder="Enter your own Linguistic Entity")
248
  ling_ents_btn = gr.Button(value="Submit")
249
 
250
  # Outputs
 
262
  # Event Handler for API Key
263
  ling_ents_btn.click(update_api_key, inputs=ling_ents_apikey_input)
264
 
265
+ def update_dropdown(dropdown_prompt, other_prompt):
266
+ if (dropdown_prompt == "Other"):
267
+ return other_prompt
268
+ else:
269
+ return dropdown_prompt
270
+
271
+ ling_ents_btn.click(update_dropdown, inputs=[linguistic_entities, linguistic_entities_other], outputs=[linguistic_entities])
272
+
273
  def update_textbox(prompt):
274
  return prompt
275
+
276
  ling_ents_btn.click(fn=update_textbox, inputs=ling_ents_prompt, outputs=user_prompt_1, api_name="ling_ents_btn")
277
 
278
  # Show features from LFTK