Example #1
0
def test_analyze():
    result = analyze("あああ令和2年十月十七日あああ平成一九年(2007年)10月18日あああ")
    for i, r in enumerate(result):
        if i in (1, 3):
            assert type(r) == dict
        else:
            assert type(r) == str
Example #2
0
def _analyze(format_json: bool, string: str) -> None:
    result = analyze(string)
    if format_json:
        click.echo(json.dumps(result, indent=2, ensure_ascii=False))
    else:
        click.echo(result)
Example #3
0
def test_get_analysis_should_return_the_same_result_as_function_parse(
    webapp: app.TestApp, ):
    assert get_analysis(webapp,
                        _GET_PARSE_STRING).json == analyze(_GET_PARSE_STRING)
Example #4
0
def get_analysis():
    string = request.args.get("string", None)
    if string is None:
        raise BadRequest("Parameter `string` is required.")
    # TODO: allow base time to be specified.
    return jsonify(analyze(string))
Example #5
0
def test_example():
    result = analyze("それは令和2年十月十七日の出来事でした。")
    print(result)