Chinaunix

标题: 求助: 列表 文本处理 [打印本页]

作者: huanhuolang    时间: 2011-04-04 21:11
标题: 求助: 列表 文本处理

  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-05 13:59
自己顶下  ~~~~~~~~~~~




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2