Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def update_array(array_a, array_b): | |
| # Create a dictionary to store the mappings from the first value to the second value | |
| mapping = {} | |
| # Populate the dictionary using the tuples from array A | |
| for a, b in array_a: | |
| mapping[a] = b | |
| # Iterate through the tuples in array B | |
| for i, (a, b) in enumerate(array_b): | |
| if b is None and a in mapping: | |
| # Replace the tuple in array B with the value from array A | |
| array_b[i] = (a, mapping[a]) | |
| def amb_texts(text): | |
| tokens = re.split(r'(\s+)', text) | |
| # tokens = [token for token in tokens if token.strip() != ''] | |
| ambs=a.sentence_ambiguity(text) | |
| res=list() | |
| for i in tokens: | |
| res.append((i,None)) | |
| update_array(ambs,res) | |
| # print(tokens,text) | |
| return res | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| iface.launch() | |