vector<DisambiguatedData> PredictedMorphologyTreeRecoverer::GetMorphology(
    const SyntaxTree& realTree)
{
    size_t size = static_cast<size_t>(realTree.GetSize());
    vector<Token> tokens(size);
    for (size_t nodeIndex = 0; nodeIndex < size; ++nodeIndex)
    {
        tokens[nodeIndex] = static_cast<Token>(realTree.GetNodes()[nodeIndex]);
    }
    return disambiguator->Disambiguate(tokens);
}
EDGE_FEATURE_CALCULATOR_TEMPLATE
void EDGE_FEATURE_CALCULATOR_TEMPLATE1::CalculateFeatures(
    const SyntaxTree& tree
    , vector<vector<StringBatch> >* features)
{
    int size = tree.GetSize();
    const vector<SyntaxNode>& nodes = tree.GetNodes();
    // Calculate features for nodes
    vector<vector<wstring> > nodeFeatures
        = nodeFeatureCalculator.Calculate(tree);
    // Calculate features
    features->resize(size);
    for (int leftIndex = 0; leftIndex < size; ++leftIndex)
    {
        (*features)[leftIndex].resize(size);
        for (int rightIndex = 0; rightIndex < size; ++rightIndex)
        {
            if (leftIndex == rightIndex)
            {
                continue;
            }
            StringBatch& currentFeatures = (*features)[leftIndex][rightIndex];

            wstring distanceAbbr = Ceil(
                nodes[rightIndex].index - nodes[leftIndex].index);

            wstring posLeftMin2 = (leftIndex > 1 ? nodes[leftIndex - 2].label : L"none");
            wstring posLeftMin1 = (leftIndex > 0 ? nodes[leftIndex].label : L"none");
            wstring posLeft = L"!" + nodes[leftIndex].label;
            wstring posLeftPlus1 = (leftIndex + 1 < size ? nodes[leftIndex + 1].label : L"none");
            wstring posLeftPlus2 = (leftIndex + 2 < size ? nodes[leftIndex + 2].label : L"none");


            wstring posRightMin2 = (rightIndex > 1 ? nodes[rightIndex - 2].label : L"none");
            wstring posRightMin1 = (rightIndex > 0 ? nodes[rightIndex].label : L"none");
            wstring posRight = L"!" + nodes[rightIndex].label;
            wstring posRightPlus1 = (rightIndex + 1 < size ? nodes[rightIndex + 1].label : L"none");
            wstring posRightPlus2 = (rightIndex + 2 < size ? nodes[rightIndex + 2].label : L"none");


            currentFeatures.Add(posLeft + L"->");
            currentFeatures.Add(L"->" + posRight);

            currentFeatures.Add(posLeftMin2 + posLeftMin1 + posLeft + posLeftPlus1 + L"->" + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeftMin2 + posLeftMin1 + posLeft + L"->" + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeftMin1 + posLeft + L"->" + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeft + posLeftPlus1 + L"->" + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeft + L"->" + posRight + L"_" + distanceAbbr);

            currentFeatures.Add(posLeft + L"->" + posRightMin2 + posRightMin1 + posRight + posRightPlus1 + L"_" + distanceAbbr);
            currentFeatures.Add(posLeft + L"->" + posRightMin2 + posRightMin1 + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeft + L"->" + posRightMin1 + posRight + L"_" + distanceAbbr);
            currentFeatures.Add(posLeft + L"->" + posRight + posRightPlus1 + L"_" + distanceAbbr);


            // Add features
            wstring prefix = nodes[leftIndex].label + L"_" + nodes[rightIndex].label;
            currentFeatures.Add(L"L" + nodes[leftIndex].label);
            currentFeatures.Add(L"R" + nodes[rightIndex].label);
            // Add left node features
            const vector<wstring>& leftFeatures = nodeFeatures[leftIndex];
            for (size_t it = 0; it < leftFeatures.size(); ++it)
            {
                currentFeatures.Add(
                    prefix + L"L" + leftFeatures[it]);
            }
            // Add right node features
            const vector<wstring>& rightFeatures = nodeFeatures[rightIndex];
            for (size_t it = 0; it < rightFeatures.size(); ++it)
            {
                currentFeatures.Add(prefix + L"R" + rightFeatures[it]);
            }

            currentFeatures.Add(nodes[leftIndex].lemma + L"->" + nodes[rightIndex].label + L"_" + distanceAbbr);
            currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].lemma + L"_" + distanceAbbr);
            currentFeatures.Add(nodes[leftIndex].content + L"->" + nodes[rightIndex].label + L"_" + distanceAbbr);
            currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].content + L"_" + distanceAbbr);

            currentFeatures.Add(nodes[leftIndex].lemma + L"->" + nodes[rightIndex].label);
            currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].lemma);
            currentFeatures.Add(nodes[leftIndex].content + L"->" + nodes[rightIndex].label);
            currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].content);
        }
    }
}