File size: 923 Bytes
98eb826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()