in reply to Re^2: bracket processing
in thread bracket processing

Excellent, thanks much Ken. That helps! Sorry I missed samples, attaching a few here.

I am starting to learn text analysis (e.g. sentiment analysis on reviews/opinion). Here is the link to the full dataset: http://www.cs.jhu.edu/~mdredze/datasets/sentiment/ . Many are also available on google.

Few samples are shown below. Seems text processing is far more complex than I realized. Lots of variations/edge cases. Just came across cases where brackets can't be removed as it makes the text pretty ackward, something like: 'Company is good because of: (1) quick service, (2) product range..'.

#samples The largest of these (4 quart{16 cups}) will hold all but a little bit + of a bag of flour. I like the look of the stainless steel and the fa +ct of the seal around the lid. I {mistakenly} did not recieve my order (it was a different order i wa +s expecting), and they rushed me another collar. The rougher the machine the more wear on the fabric and more pilling, +lint, etc.... I would highly recommend these sheets for the price an +d the great quality for the price. [I would rate them 5 stars if the +y were heavier and soft as cashmere, but for the money definitely a g +ood buy.]

Replies are listed 'Best First'.
Re^4: bracket processing
by AnomalousMonk (Archbishop) on Apr 02, 2020 at 04:09 UTC

    Please let me suggest once again a reading of How to ask better questions using Test::More and sample data. What I and some other monks would like to see is something like:

    my @Tests = ( [ 'The largest (4 quart{16 cups}) will hold most of a bag of flour +.', # input string 'The largest will hold most of a bag of flour.', + # expected output ], [ 'I {mistakenly} did not recieve my order (it was a different ord +er), and they rushed me another.', 'I did not recieve my order, and they rushed me another.', ], [ 'Company is good because of: (1) quick service, (2) product rang +e.', 'Company is good because of: (1) quick service, (2) product rang +e.', 'parenthesized ordinals untouched', # optional comment ], [ '...', '...', ], # another test case ... # more test cases );
    This can integrate easily into a Test::More testing framework. Individual test cases should be as short as possible and should always be paired with exact expected output. Degenerate and trivial cases, e.g.,
        ''  ' '  '()'  ' ()'  '() '  'x'  'foo'  etc, etc...
    should also be given. (Update: If exceptions may be thrown, a test case or cases should ultimately be written for each exception; see Test::Exception.) Note that this is work you will have to do anyway because you must always build a testing framework for any serious project you undertake!

    What I, for one, do not like to see is an invitation to do a lot of work to generate test case input for which I must also guess the correct output; that's your job.


    Give a man a fish:  <%-{-{-{-<

      Thanks AnomalousMonk, appreciate your advice. Have never used Test::More, so will learn now. Will also post some interesting test cases that I might come across.