import re
a1="(''imperfective'') {{qualifier|impersonal}} (with {{l|nv|bíká}}) he/she/it [[write]]s (as this, that, there), (something unspecified on something unspecified), makes a [[tattoo]], makes a [[mark]]"
b2="starting (a fire), making (a fire), burning (a fire)" 
b2="it is [[whitish]], [[off-white]], [[cream#Adjective|cream-colored]], light [[beige]], [[tan]]"
b2="he is sailing it away, floating away in it, rowing it away (a boat)"
b2="they (3+ actors) go out horizontally (as through a door), exit, leave."
b2="it sticks, pierces, penetrates, stabs (a sharp pointed object as a thorn)"
def rework(s) :
  ret=s
  ret=ret.replace("something unspecified", "sth") 
  ret=ret.replace("something","sth")

  ret=ret.replace("he/she/it","he")
  ret=ret.replace("he/she","he")
  ret=ret.replace("him/her/it","him")
  ret=ret.replace("him/her","him")
  ret=ret.replace("his/her/its","his")
  ret=ret.replace("his/her","his")

  ret=ret.replace("such as","as")
  ret=ret.replace("object","obj")

  # remove italics between parentheses
  m=re.compile("\(\'\'.*\'\)") 
  ret=m.sub('',ret)
    
  # remove qualifiers 
  m=re.compile("\{\{\qualifier\|[^\}]+\}\}") 
  ret=m.sub('',ret)

  # remove first parentheses  
  m=re.compile("^\([^\)]*\)") 
  ret=m.sub('a',ret.strip())
  
  # reduce examples
  m=re.compile("\(([^\)]*) or [^\)]*\)") 
  ret=m.sub(r'(\1)',ret.strip())
    
  m=re.compile("\(([^,\)]*),[^\)]*\)") 
  ret=m.sub(r'(\1)',ret.strip())
    
  # strip markup
  m=re.compile("\[\[([^\|\]]*\|)?([^\]]*)\]\]") 
  ret=m.sub(r'\2',ret.strip())
    
  #ret = ret.strip()
  return ret

def cut50(s):
  if len(s) <= 50:
      return s
    
  # retrieve last paren clause 
  paren=""
  ret=s
  m=re.compile("(\([^\)]*\))$")
  p=m.search(s)
  if p:
       paren=" "+p.group(1) 
       ret=s[0:p.span()[0]]
  print  (len(paren)) 
  cut=50
  if len(paren)>25:
    cut=25
  m=re.compile("(.*),(.*)")
  p=m.search(ret[0:cut] )
  if p:
       return p.group(1).strip()+paren 
  else:
       return ret.split(',')[0].strip()+paren

b2=rework(b2)
print(b2,len(b2)," \n")
print(cut50(b2), len(cut50(b2))) 
#cut50(b2)
it sticks, pierces, penetrates, stabs (a sharp pointed obj as a thorn) 70  

33
33
it sticks, pierces (a sharp pointed obj as a thorn) 51