Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env node
- 'use-strict'
- const process = require('process');
- const fs = require('fs');
- try {
- const dict = fs.readFileSync(process.argv[2], 'utf8');
- const expr = fs.readFileSync(process.argv[3], 'utf8');
- const dic = [];
- let j = 0;
- let i;
- let cur = '';
- for (i = 0; i < dict.length; i++) {
- if (cur.length !== 0 && (dict[i] === ',' || dict[i] === '.' || dict[i] === ' ' || dict[i] === '\n')) {
- dic[j] = cur;
- j++;
- cur = '';
- }
- else {
- if (dict[i] !== ',' && dict[i] !== '.' && dict[i] !== ' ' && dict[i] !== '\n') cur += dict[i];
- }
- }
- cur = '';
- let x = 1;
- let y = 1;
- let is = 0;
- for (i = 0; i < expr.length; i++) {
- if (cur.length !== 0 && (expr[i] === ',' || expr[i] === '.' || expr[i] === ' ' || expr[i] === '\n')) {
- for (j = 0; j < dic.length; j++) {
- if (0 === cur.localeCompare(dic[j])) {
- is = 1;
- break;
- }
- }
- if (is === 0) {
- console.log(x + ',' + ' ' + (y - cur.length) + ' ' + cur);
- }
- if (expr[i] === ',' || expr[i] === '.' || expr[i] === ' ') y++;
- if (expr[i] === '\n') {
- x++;
- y = 1;
- }
- cur = '';
- is = 0;
- }
- else {
- if (expr[i] !== ',' && expr[i] !== '.' && expr[i] !== ' ' && expr[i] !== '\n') {
- cur += expr[i];
- y++;
- }
- if (expr[i] === ',' || expr[i] === '.' || expr[i] === ' ') y++;
- if (expr[i] === '\n') {
- x++;
- y = 1;
- }
- }
- }
- } catch (e) {
- console.error(e.message);
- }
Add Comment
Please, Sign In to add comment