| Marc Kupietz | b43a518 | 2024-02-03 18:09:10 +0100 | [diff] [blame] | 1 | const { execSync } = require('child_process'); |
| 2 | const exp = require('constants'); |
| 3 | |
| 4 | describe('conllu2cmc', () => { |
| 5 | test('Test sparse mode', (done) => { |
| 6 | // Modify the command based on your script's location and options |
| 7 | const command = 'node src/index.js -s < test/data/ndy.conllu'; |
| 8 | const stdout = execSync(command).toString(); |
| 9 | expect(stdout).toContain('😂\t_\tEMOIMG\tEMOIMG'); |
| 10 | var emoimg_count = (stdout.match(/EMOIMG/g) || []).length; |
| 11 | expect(emoimg_count).toBe(382); |
| 12 | var ascimg_count = (stdout.match(/EMOASC/g) || []).length; |
| 13 | expect(ascimg_count).toBe(60); |
| 14 | var ascimg_count = (stdout.match(/URL/g) || []).length; |
| 15 | expect(ascimg_count).toBe(8); |
| 16 | var adr_count = (stdout.match(/ADR/g) || []).length; |
| 17 | expect(adr_count).toBe(2); |
| Marc Kupietz | fd92b1d | 2024-03-13 10:51:29 +0100 | [diff] [blame] | 18 | var eot_count = (stdout.match(/\n# eot/g) || []).length; |
| 19 | expect(eot_count).toBe(1); |
| 20 | var eof_count = (stdout.match(/\n# eof/g) || []).length; |
| 21 | expect(eof_count).toBe(1); |
| Marc Kupietz | b43a518 | 2024-02-03 18:09:10 +0100 | [diff] [blame] | 22 | var lines_count = (stdout.split("\n")).length; |
| Marc Kupietz | fd92b1d | 2024-03-13 10:51:29 +0100 | [diff] [blame] | 23 | expect(lines_count).toBe(746); |
| Marc Kupietz | b43a518 | 2024-02-03 18:09:10 +0100 | [diff] [blame] | 24 | done(); |
| 25 | }); |
| 26 | |
| 27 | test('Test full mode', (done) => { |
| 28 | const command = 'node src/index.js < test/data/ndy.conllu'; |
| 29 | const stdout = execSync(command).toString(); |
| 30 | expect(stdout).toContain('😂\t_\tEMOIMG\tEMOIMG'); |
| 31 | var emoimg_count = (stdout.match(/EMOIMG/g) || []).length; |
| 32 | expect(emoimg_count).toBe(382); |
| 33 | var ascimg_count = (stdout.match(/EMOASC/g) || []).length; |
| 34 | expect(ascimg_count).toBe(60); |
| 35 | var ascimg_count = (stdout.match(/URL/g) || []).length; |
| 36 | expect(ascimg_count).toBe(8); |
| 37 | var adr_count = (stdout.match(/ADR/g) || []).length; |
| 38 | expect(adr_count).toBe(2); |
| 39 | var lines_count = (stdout.split("\n")).length; |
| Marc Kupietz | fd92b1d | 2024-03-13 10:51:29 +0100 | [diff] [blame] | 40 | expect(lines_count).toBe(6202); |
| Marc Kupietz | b43a518 | 2024-02-03 18:09:10 +0100 | [diff] [blame] | 41 | done(); |
| 42 | }); |
| Marc Kupietz | b5d80b3 | 2025-12-11 15:48:09 +0100 | [diff] [blame^] | 43 | |
| 44 | test('Regression test for issue #113: emoji modifiers and ZWJ', (done) => { |
| 45 | // Test that compound emojis with modifiers and ZWJ are recognized as single EMOIMG tokens |
| 46 | const testInput = `# foundry = base |
| 47 | # text_id = test-113 |
| 48 | # text = ✊🏿 and 👨👨👦 |
| 49 | 1 ✊🏿 _ _ _ _ _ _ _ _ |
| 50 | 2 and _ CCONJ _ _ _ _ _ _ |
| 51 | 3 👨👨👦 _ _ _ _ _ _ _ _ |
| 52 | |
| 53 | `; |
| 54 | const { execSync } = require('child_process'); |
| 55 | const stdout = execSync('node src/index.js', { input: testInput }).toString(); |
| 56 | |
| 57 | // Check that compound emojis are tagged as EMOIMG |
| 58 | expect(stdout).toContain('✊🏿\t_\tEMOIMG\tEMOIMG'); |
| 59 | expect(stdout).toContain('👨👨👦\t_\tEMOIMG\tEMOIMG'); |
| 60 | |
| 61 | // Count EMOIMG occurrences (should be 2 for each emoji - columns 3 and 4) |
| 62 | var emoimg_count = (stdout.match(/EMOIMG/g) || []).length; |
| 63 | expect(emoimg_count).toBe(4); // 2 emojis × 2 columns = 4 |
| 64 | done(); |
| 65 | }); |
| 66 | |
| Marc Kupietz | 7497fc4 | 2025-12-11 15:47:34 +0100 | [diff] [blame] | 67 | test('Regression test for issue #114: Wikipedia emoji templates', (done) => { |
| 68 | // Test that Wikipedia emoji templates are recognized as EMOWIKI tokens |
| 69 | const testInput = `# foundry = base |
| 70 | # text_id = test-114 |
| 71 | # text = [_EMOJI:{{S|;)}}_] and [_EMOJI:{{cool}}_] |
| 72 | 1 [_EMOJI:{{S|;)}}_] _ _ _ _ _ _ _ _ |
| 73 | 2 and _ CCONJ _ _ _ _ _ _ |
| 74 | 3 [_EMOJI:{{cool}}_] _ _ _ _ _ _ _ _ |
| 75 | |
| 76 | `; |
| 77 | const { execSync } = require('child_process'); |
| 78 | const stdout = execSync('node src/index.js', { input: testInput }).toString(); |
| 79 | |
| 80 | // Check that Wikipedia emoji templates are tagged as EMOWIKI |
| 81 | expect(stdout).toContain('[_EMOJI:{{S|;)}}_]\t_\tEMOWIKI\tEMOWIKI'); |
| 82 | expect(stdout).toContain('[_EMOJI:{{cool}}_]\t_\tEMOWIKI\tEMOWIKI'); |
| 83 | |
| 84 | // Count EMOWIKI occurrences (should be 2 for each template - columns 3 and 4) |
| 85 | var emowiki_count = (stdout.match(/EMOWIKI/g) || []).length; |
| 86 | expect(emowiki_count).toBe(4); // 2 templates × 2 columns = 4 |
| 87 | done(); |
| 88 | }); |
| Marc Kupietz | b43a518 | 2024-02-03 18:09:10 +0100 | [diff] [blame] | 89 | }); |