+ -
当前位置:首页 → 问答吧 → 求助: 列表 文本处理

求助: 列表 文本处理

时间:2011-04-04

来源:互联网

  1. #s为句法树
  2. s = '''(ROOT
  3.   (S
  4.     (PP (IN In)
  5.       (NP (DT this) (NN study)))
  6.     (, ,)
  7.     (NP (PRP we))
  8.     (VP (VBD examined)
  9.       (NP
  10.         (NP (DT the) (NN expression))
  11.         (PP (IN of)
  12.           (NP (JJ let-7) (NNS miRNAs))))
  13.       (PP (IN in)
  14.         (NP
  15.           (NP (JJ human) (NN colon) (NN cancer) (NNS tumors))
  16.           (CC and)
  17.           (NP (NN cell) (NNS lines))))
  18.       (, ,)
  19.       (PP (IN with)
  20.         (NP
  21.           (NP (DT the) (NN result))
  22.           (SBAR (IN that)
  23.             (S
  24.               (NP
  25.                 (NP (CD 2))
  26.                 (PP (IN of)
  27.                   (NP
  28.                     (NP (CD 6) (NNS cases))
  29.                     (CC and)
  30.                     (NP (CD 1))))
  31.                 (PP (IN of)
  32.                   (NP (CD 3) (NN cell) (NNS lines))))
  33.               (VP (VBD showed)
  34.                 (NP
  35.                   (NP (VBN reduced) (NN expression))
  36.                   (PP (IN of)
  37.                     (NP (NN let-7))))))))))
  38.     (. .)))
  39. '''
  40. str1="reduced"
  41. str2="let-7"
  42. temp=[]
  43. link=[]
  44. s=s.replace('(', ' ( ')
  45. s=s.replace(')', ' ) ')
  46. list=s.split()
  47. print list
  48. for word in list:
  49.     #print word,
  50.     while True:
  51.         string=list.pop(0)
  52.         temp.append(string)
  53.         #print string,
  54.         if string==')':
  55.             break
  56.     print temp
复制代码
请问:这个为什么读不到底 ?先谢谢了

作者: huanhuolang   发布时间: 2011-04-04

自己顶下  ~~~~~~~~~~~

作者: huanhuolang   发布时间: 2011-04-05