#NEWLINE# def root_semrep( syntree , semkey = 'SEM' ) : #NEWLINE# #INDENT# '\n    Find the semantic representation at the root of a tree.\n\n    :param syntree: a parse ``Tree``\n    :param semkey: the feature label to use for the root semantics in the tree\n    :return: the semantic representation at the root of a ``Tree``\n    :rtype: sem.Expression\n    ' #NEWLINE# from nltk.grammar import FeatStructNonterminal #NEWLINE# node = syntree . label ( ) #NEWLINE# assert isinstance ( node , FeatStructNonterminal ) #NEWLINE# try : #NEWLINE# #INDENT# return node [ semkey ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# print ( node , end = ' ' ) #NEWLINE# print ( ( 'has no specification for the feature %s' % semkey ) ) #NEWLINE# #UNINDENT# raise