private String getNodeTypeAndDatabaseIdString(FeatureTree tree, TreeNode node) { StringBuilder sb = new StringBuilder(); // type-attribute // level of the tree sb.append(tree.getBabyTreeType()); sb.append("/"); if (tree.getClass() == JointlyCodingFeatureTree.class) { sb.append(tree.getAlignmentType()); sb.append("/"); } // name of the feature sb.append(tree.getFeatureName()); sb.append("_"); // unique node number - database_id -attribute int nodeIdentity = node.getNodeIdentityNumber(); sb.append(nodeIdentity); sb.append(" "); return sb.toString(); }
private String getNodeString(FeatureTree tree, TreeNode parentNode) { StringBuilder sb = new StringBuilder(); // each node line begins with this sb.append("# _attributes "); String language = tree.getLanguage(); // the default name of the node; here the name of the feature sb.append(getNodeTypeAndDatabaseIdString(tree, parentNode)); if (parentNode.isRootNode()) { // add some extra attributes for root node sb.append(getAttributeString(NodeLabels.TOTAL_COST_OF_TREE, tree.getTotalTreeCost())); sb.append(getAttributeString(NodeLabels.MODEL_COST_OF_TREE, tree.getModelCost())); sb.append(getAttributeString(NodeLabels.DATA_COST_OF_TREE, tree.getDataCost())); sb.append(getAttributeString(NodeLabels.FEATURE_NAME, tree.getFeatureName())); sb.append( getAttributeString( NodeLabels.TREE_LEVEL, tree.getBabyTreeType().toString() + ":" + language)); sb.append(getAttributeString(NodeLabels.TREE_TYPE, tree.getTreeType())); sb.append(getAttributeString(NodeLabels.COLUMN_LABELS, tree.getColumnLabels())); if (tree.getClass() == JointlyCodingFeatureTree.class) { sb.append(getAttributeString(NodeLabels.ROW_LABELS, tree.getRowLabels())); sb.append(getAttributeString(NodeLabels.ALIGNMENT_TYPE, tree.getAlignmentType())); } if (tree.getBabyTreeType() != BabyTreeType.JOINT) { sb.append(getAttributeString(NodeLabels.POS, getRootNodePositionString(tree, parentNode))); } sb.append("queryset=root "); } else { // not root node sb.append( getAttributeString( NodeLabels.FILL, getColor(minEntropy, maxEntropy, computeEntropy(parentNode.getCountMatrix())))); } // default label, if not defined, the getNodeDatabaseIdString is shown in nodes instead sb.append(getAttributeString(NodeLabels.LABEL, getMatrixString(tree, parentNode))); // attributes that all nodes share sb.append(getAttributeString(NodeLabels.MATRIX_COST, parentNode.getCost())); sb.append(getAttributeString(NodeLabels.MATRIX, getMatrixString(tree, parentNode))); sb.append( getAttributeString( NodeLabels.FEATURE_VALUE_IN_PREVIOUS_SPLIT, parentNode.getValueOfCandidateFeature())); sb.append( getAttributeString(NodeLabels.NUMBER_OF_CANDIDATES, parentNode.getCandidates().size())); sb.append(getAttributeString(NodeLabels.ENTROPY, computeEntropy(parentNode.getCountMatrix()))); // inner nodes have been split if (parentNode.getAppliedCandidate() != null) { sb.append(getAttributeString(NodeLabels.BEST_CANDIDATE, parentNode.getAppliedCandidate())); sb.append( getAttributeString( NodeLabels.BEST_CANDIDATE_COST, parentNode.getAppliedCandidate().getCost())); } sb.append("\n"); return sb.toString(); }