|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from .helper import check_evaluation, session |
| 3 | + |
| 4 | + |
| 5 | +def test_natlang(): |
| 6 | + |
| 7 | + session.evaluate( |
| 8 | + """ |
| 9 | + LoadModule["pymathics.natlang"] |
| 10 | + """ |
| 11 | + ) |
| 12 | + |
| 13 | + for str_expr, str_expected, message in ( |
| 14 | + ( |
| 15 | + 'WordCount["A long time ago"]', |
| 16 | + "4", |
| 17 | + "WordCount", |
| 18 | + ), |
| 19 | + ( |
| 20 | + "Length[WordList[]]>10000", |
| 21 | + "True", |
| 22 | + "WordList", |
| 23 | + ), |
| 24 | + ( |
| 25 | + 'TextWords["Hickory, dickory, dock! The mouse ran up the clock."]', |
| 26 | + '{"Hickory", "dickory", "dock", "The", "mouse", "ran", "up", "the", "clock"}', |
| 27 | + "TextWords", |
| 28 | + ), |
| 29 | + ( |
| 30 | + 'TextSentences["Night and day. Day and night."]', |
| 31 | + '{"Night and day.", "Day and night."}', |
| 32 | + "TextSentences", |
| 33 | + ), |
| 34 | + ( |
| 35 | + 'TextSentences["Mr. Jones met Mrs. Jones."]', |
| 36 | + '{"Mr. Jones met Mrs. Jones."}', |
| 37 | + "TextSentences with Abbreviations", |
| 38 | + ), |
| 39 | + # ( |
| 40 | + # 'DeleteStopwords[{"Somewhere", "over", "the", "rainbow"}]', |
| 41 | + # '{"rainbow"}', |
| 42 | + # "DeleteStopWords", |
| 43 | + # ), |
| 44 | + ( |
| 45 | + 'WordFrequency["Apple Tree", "apple", IgnoreCase -> True]', |
| 46 | + "0.5", |
| 47 | + "WordFrequency", |
| 48 | + ), |
| 49 | + ( |
| 50 | + 'TextCases["I was in London last year.", "Pronoun"]', |
| 51 | + '{"I"}', |
| 52 | + "TextCases", |
| 53 | + ), |
| 54 | + # ( |
| 55 | + # 'Pluralize["try"]', |
| 56 | + # '"I"', |
| 57 | + # "Pluralize", |
| 58 | + # ), |
| 59 | + ): |
| 60 | + check_evaluation(str_expr, str_expected, message) |
0 commit comments