2016-04-26 4 views
1

これが私のコードです:サポートされていないオペランドのタイプ(複数可)について>>:「builtin_function_or_method」と「_io.TextIOWrapper」の

def _parse(self, text): 
    """ 
    This is the core interaction with the parser. 

    It returns a Python data-structure, while the parse() 
    function returns a JSON object 
    """ 

    # CoreNLP interactive shell cannot recognize newline 
    if '\n' in text or '\r' in text: 
     to_send = re.sub("[\r\n]", " ", text).strip() 
    else: 
     to_send = text 


    self.corenlp.sendline(to_send) 
    max_expected_time = max(300.0, len(to_send)/3.0) 

    # repeated_input = self.corenlp.except("\n") # confirm it 
    t = self.corenlp.expect(["\nNLP> ", pexpect.TIMEOUT, pexpect.EOF, 
           "\nWARNING: Parsing of sentence failed, possibly because of out of memory."], 
           timeout=max_expected_time) 
    incoming = self.corenlp.before 
    lag = incoming.split(b"\r\n") 
    incoming = b"\r\n".join(lag).decode('latin-1').encode('utf-8') 
    if t == 1: 
     # TIMEOUT, clean up anything left in buffer 
     print >>sys.stderr, {'error': "timed out after %f seconds" % max_expected_time, 
           'input': to_send, 
           'output': incoming} 
     raise TimeoutError("Timed out after %d seconds" % max_expected_time) 
    elif t == 2: 
       # EOF, probably crash CoreNLP process 
     print >>sys.stderr, {'error': "CoreNLP terminates abnormally while parsing", 
           'input': to_send, 
           'output': incoming} 
     raise ProcessError("CoreNLP process terminates abnormally while parsing") 
    elif t == 3: 
       # out of memory 
     print >>sys.stderr, {'error': "WARNING: Parsing of sentence failed, possibly because of out of memory.", 
           'input': to_send, 
           'output': incoming} 
     raise OutOfMemoryError 

    if VERBOSE: 
     print("%s\n%s" % ('=' * 40, incoming)) 
    try: 
     results = parse_parser_results(incoming) 
    except ixception as e: 
     if VERBOSE: 
      print(traceback.format_exc()) 
     raise e 

    self.pre_loaded_analisys_dict[to_send] = results 

    with open(self.pre_analysis,"w", encoding = 'utf-8') as f: 
     json.dump(self.pre_loaded_analisys_dict,f) 

    return results 

そして、私はこのエラーを持っている(私は用語の多くを解析していますそれは)私はそのエラーを持っている最初の時間です:>>用

サポートされていないオペランドのタイプ(S): 'builtin_function_or_method' と '_io.TextIOWrapper'

任意のアイデア?

EDIT:

b'Q \ rを\ n注記パイプラインタイミング情報:\ rを\ nTokenizerAnnotator:。 0.0秒\ rをする\のnWordsToSentencesAnnotator:0.0秒\ printintの着信変数iはこれを持っています。 r \ nPOSTaggerAnnotator:0.0秒。\ r \nMARαAnnotator:0.1秒。\ r \ nNERCombinerAnnotator:0.4秒。\ r \ nTOTAL:0.6秒。 。0.0秒 StanfordCoreNLPパイプラインのための\ rを\ n総時間::606.1 トークン/秒で337個のトークン\ rを\ nPipelineセットアップのために。138.7秒は\ rをする\ n」を

私はこのような何かを取得する必要があります:膝の

b'Contusion \ R \ nSentence#1(3つのトークン):\ R 膝の\ r \ n [文字のnContusion \ =挫傷CharacterOffsetBegin = 0 CharacterOffsetEnd = 9 PartOfSpeech = NN補題=偽装NamedEntityTag = O] [テキスト= のCharacterOffsetBegin = 10 CharacterOffsetEnd = 12 PartOfSpeech = IN補題=の NamedEntityTag = O] [テキスト=膝CharacterOffsetBegin = 13 CharacterOffsetEnd = 17 PartOfSpeech = NN補題=膝NamedEntityTag = O] \ r」が

+0

エラーが発生するのはどの回線ですか? –

+0

私はこれを持っています: 'Annotation pipeline timing information ...' – AEU

答えて

0

人々は、この特定のエラーメッセージを直撃している質問を探して遅ればせながら答え:それはあなたがしようとしていることを示していますPython 3でPython 2スタイルのストリームリダイレクトを使用するか、from __future__ import print_functionがPython 2.xで有効になっている間に使用します。

print >> sys.stderr, expressionの代わりにprint(expression, file=sys.stderr)と書く必要があります。

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?この変更の詳細については、こちらをご覧ください。

関連する問題