예제 #1
0
bool generate_json (parse_tree const& in,
                    std::basic_ostream<Char>& out)
{
    json_printer<std::basic_ostream<Char> > print(out, in.annotations());
    print(in.ast());
    return true; 
}
예제 #2
0
bool generate_mss_dot( parse_tree const& in,
                   std::basic_ostream<Char>& out)
{
    mss_dot_printer<std::basic_ostream<Char> > printer(out, in.annotations());
    printer.print(in.ast());
    
    return true; 
}
예제 #3
0
bool generate_json (parse_tree const& in,
                    std::basic_string<Char>& out)
{
    std::basic_stringstream<Char> oss;
    json_printer<std::basic_stringstream<Char> > print(oss, in.annotations());
    print(in.ast());
    out = oss.str();
    return true; 
}
예제 #4
0
void evalb::add_tree(parse_tree proposed, parse_tree gold)
{

    static multi_transformer<annotation_remover, collinizer, empty_remover>
    trnsfm;

    proposed.transform(trnsfm);
    gold.transform(trnsfm);

    auto prop_const = get_constituents(proposed);
    auto gold_const = get_constituents(gold);

    uint64_t crossings = 0;
    for (const auto& guess : prop_const)
    {
        for (const auto& gold : gold_const)
        {
            if (crosses(guess, gold))
            {
                ++crossings;
                break;
            }
        }
    }
    if (crossings == 0)
        ++zero_crossing_;
    crossed_ += crossings;
    ++total_trees_;

    proposed_total_ += prop_const.size();
    uint64_t gold_total = gold_const.size();
    uint64_t matched = 0;
    for (const auto& guess : prop_const)
    {
        auto it = gold_const.find(guess);
        if (it != gold_const.end())
        {
            ++matched;
            gold_const.erase(it);
        }
    }

    if (matched == gold_total && matched == prop_const.size())
        ++perfect_;

    gold_total_ += gold_total;
    proposed_correct_ += matched;
}
예제 #5
0
파일: xml.hpp 프로젝트: brycelelbach/prana
 static type call (utree const& ut, parse_tree<Tag> const& pt) {
   using fusion::at_c;
   switch (ut.which()) {
     case utree_type::reference_type:
       return call(ut.deref());
     case utree_type::range_type:
     case utree_type::list_type:
       return at_c<1>(pt.annotations()[ut.tag()]);
     default:
       return -1; 
   }
 }
예제 #6
0
 source_location get_location(utree const& ut)
 {    
     return tree.annotations()[ut.tag()].first;
 }
예제 #7
0
 int get_node_type(utree const& ut)
 {   
     return( tree.annotations(ut.tag()).second );
 }