기본적으로 파싱 된 트리를 작업하고 비어있는 카테고리 (빈 노드 주석)를 지배하는 트리 노드에 주석을 추가하려고합니다.AttributeError : 'ParentedTree'객체에 'label'속성이 없습니다.
다음과 같이 recurvsive 함수를 정의했지만 "AttributeError : 'ParentedTree'객체에 'label'속성이 없습니다."라는 오류가 발생합니다.
def annotateTraceNodes(node):
numChildren = len(node);
numNone=0;
for child in node:
if isinstance(child,Tree):
annotateTraceNodes(child);
if(numChildren==0 or child.label().endswith("-NONE-")):
numNone+=1;
if(numChildren==numNone):
print "setting the label";
node.set_label(node.label()+"-NONE-");
이 코드에는 'ParentedTree'라는 객체가 없습니다 –
혼란과 오자를 쓴 죄송합니다. 오타를 바로 잡았습니다. 어떻게하면 작동합니까? – Linguist
줄 끝에 세미콜론이 필요하지 않습니다. 이것은 C/C++가 아닙니다. – IanAuld