示例#1
0
 args_t::args_t( int argc, const char * argv[] ) :
 output( stdout ),
 input1( stdin ),
 input2( NULL ),
 distance( DEFAULT_DISTANCE ),
 min_distance( DEFAULT_MIN_DISTANCE ),
 ambig( DEFAULT_AMBIG ),
 format ( DEFAULT_FORMAT ),
 overlap ( DEFAULT_OVERLAP ),
 do_bootstrap( false ),
 do_bootstrap_two_files ( false ),
 do_count( false ),
 quiet( false ),
 do_fst( false ),
 report_self ( false ),
 counts_in_name ( DEFAULT_COUNTS_IN_NAME ),
 include_prob( DEFAULT_INCLUDE_PROB ),
 ambigs_to_resolve(NULL),
 resolve_fraction(DEFAULT_FRACTION)
 {
     // skip arg[0], it's just the program name
   for (int i = 1; i < argc; ++i ) {
     const char * arg = argv[i];
     
     if ( arg[0] == '-' && arg[1] == '-' ) {
       if ( !strcmp( &arg[2], "help" ) ) help();
       else if ( !strcmp( &arg[2], "version" ) ) version();
       else
         ERROR( "unknown argument: %s", arg );
     }
     else if ( arg[0] == '-' ) {
       if ( !strcmp( &arg[1], "h" ) ) help();
       else if (  arg[1] == 'v' ) version();
       else if (  arg[1] == 'o' ) parse_output( next_arg (i, argc, argv) );
       else if (  arg[1] == 't' ) parse_distance ( next_arg (i, argc, argv) );
       else if (  arg[1] == 'w' ) parse_min_distance ( next_arg (i, argc, argv) );
       else if (  arg[1] == 'l')  parse_overlap( next_arg (i, argc, argv) );
       else if (  arg[1] == 'f')  parse_format( next_arg (i, argc, argv) );
       else if (  arg[1] == 'a')  parse_ambig( next_arg (i, argc, argv) );
       else if (  arg[1] == 's')  parse_second_in( next_arg (i, argc, argv) );
       else if (  arg[1] == 'd')  parse_counts_in_name( next_arg (i, argc, argv) );
       else if (  arg[1] == 'u')  parse_include_prob( next_arg (i, argc, argv) );
       else if (  arg[1] == 'b')  parse_bootstrap();
       else if (  arg[1] == 'r')  parse_bootstrap_two_files ();
       else if (  arg[1] == 'c')  parse_count();
       else if (  arg[1] == 'q')  parse_quiet();
       else if (  arg[1] == 'm')  parse_fst();
       else if (  arg[1] == '0')  parse_report_self();
       else if (  arg[1] == 'g')  parse_fraction( next_arg (i, argc, argv) );
       else
         ERROR( "unknown argument: %s", arg );
     }
     else
       if (i == argc-1) {
         parse_input (arg);
       } else {
         ERROR( "unknown argument: %s", arg );
       }
   }
 }
示例#2
0
static int xp_to_advance(const std::string& s) {
	std::pair<int,int> xp_frac = parse_fraction(s);

	//consider units without AMLA or advancement as having xp_max=1000000
	if(xp_frac.second == 0)
		xp_frac.second = 1000000;

	return xp_frac.second - xp_frac.first;
}
示例#3
0
 string fractionAddition(string expression) {
     int length = expression.length();
     int s = 0;
     pair<int, int> current = {0, 0};
     while(s < length)
     {
         int e = s + 1;
         while(e < length && expression[e] != '+' && expression[e] != '-')
             e++;
         pair<int, int> tmp = parse_fraction(expression, s, e);
         merge_fraction(current, tmp);
         s = e;
     }
     if(current.first == 0)
         current.second = 1;
     string ans = to_string(current.first) + "/" + to_string(current.second);
     return ans;
 }
示例#4
0
/**
 * Parses the byte stream according to the given document type
 * and creates a document model from it.
 *
 * @param p0 the destination (Hand over as reference!)
 * @param p1 the destination count
 * @param p2 the destination size
 * @param p3 the source
 * @param p4 the source count
 * @param p5 the type
 * @param p6 the type count
 */
void parse(void* p0, void* p1, void* p2, const void* p3, const void* p4,
           const void* p5, const void* p6) {

    // The comparison result.
    int r = 0;

    if (r != 1) {

        compare_arrays(p5, p6, (void*) CYBOL_ABSTRACTION, (void*) CYBOL_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_xml(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) OPERATION_ABSTRACTION, (void*) OPERATION_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_string(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) STRING_ABSTRACTION, (void*) STRING_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_string(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) BOOLEAN_ABSTRACTION, (void*) BOOLEAN_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_boolean(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) INTEGER_ABSTRACTION, (void*) INTEGER_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_integer(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) VECTOR_ABSTRACTION, (void*) VECTOR_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_vector(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) DOUBLE_ABSTRACTION, (void*) DOUBLE_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_double(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) FRACTION_ABSTRACTION, (void*) FRACTION_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_fraction(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) COMPLEX_ABSTRACTION, (void*) COMPLEX_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_complex(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) TIME_ABSTRACTION, (void*) TIME_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_time(p0, p1, p2, p3, p4);
        }
    }

    if (r != 1) {

        compare_arrays(p5, p6, (void*) CONFIGURATION_ABSTRACTION, (void*) CONFIGURATION_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

        if (r == 1) {

            parse_xml(p0, p1, p2, p3, p4);
        }
    }

    /*??
        //?? Later, distinguish file types according to abstraction,
        //?? for example xml, html, sxi, txt, rtf,
        //?? adl (from OpenEHR), KIF, ODL etc.!
        //?? For now, only the cybol file format is considered.

        if (r != 1) {

            compare_arrays(p5, p6, (void*) SXW_ABSTRACTION, (void*) SXW_ABSTRACTION_COUNT, (void*) &r, (void*) CHARACTER_ARRAY);

            if (r == 1) {

                //?? For other kinds of file (stream) formats,
                //?? for example from special applications like Open Office,
                //?? use a similar handling like for compound above!

                //?? Images possibly also have to be handled that way.
                //?? At first, the single image parameters have to be parsed
                //?? and written into a special parameter model in memory;
                //?? then that model has to be decoded into a knowledge model!
                //?? May be this idea is rubbish and will not work!
                //?? For the beginning, better handle images as primitve types.
            }
        }
    */
}