Labels

Monday, March 29, 2021

Grammar check for .tex file

TeXtidote is a tool for spell and grammar check for Latex source file.

Installation:

download the deb file from https://github.com/sylvainhalle/textidote/releases.

$ sudo apt-get install ./textidote_X.Y.Z_all.deb

X.Y.Z. is the version number.

Java is needed and can be installed via,
$ sudo apt install default-jdk

useage:
textidote --check en  --output html paper.tex  >report.html

Tuesday, March 16, 2021

Open source grammar check tool

pyLanguagetool

pip install pylanguagetool

# pipe text to pylanguagetool
echo "This is a example" | pylanguagetool

# read text from a file
pylanguagetool textfile.txt

# read text from stdin
pylanguagetool < textfile.txt

# read text from the systems clipboard
pylanguagetool -c # get text from system clipboard

Reference:
https://github.com/Findus23/pyLanguagetool

Check the duplicate by Google search

#!/usr/bin/env python3
# stollen plagiarism checker
# by Seth Kenlon 
# GPLv3

# This program is free software: you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at
# your option) any later version.

# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

# You should have received a copy of the GNU General
# Public License along with this program.
# If not, see .

# useage:
# python3 -m pip install google --user
# $ chmod +x ./stollen.py
# $ ./stollen.py test.txt


import sys
import random
from pathlib import Path
from googlesearch import search

def Scrub(ARG):
    """
    Read lines of file.
    """

    f = open(ARG, 'r')
    LINES = f.readlines()
    Search(LINES)

def Search(LINES):
    """
    Search Internet for exact match of LINE.
    """

    COUNT=0
   
    for LINE in LINES:
        COUNT += 1        
        PAUSE = random.randrange(1,4)

        if VERBOSE:
            print("Searching...")
           
        for ITEM in search(LINE, tld="com", num=1, stop=1, pause=PAUSE):
            if VERBOSE:
                print("WARNING:" + LINE + " → " + ITEM)
            else:
                print("WARNING: line " + str(COUNT) + " → " + ITEM)

if __name__ == "__main__":
    random.seed()
    n=1
   
    if sys.argv[1] == "--verbose" or sys.argv[1] == "-v":
        VERBOSE = True
        # shift 1
        n += 1
    else:
        VERBOSE = False
       
    f = Path(sys.argv[n])

    if not f.is_file():
        print("Provide a text file to check.")
        exit()
    else:
        Scrub(sys.argv[n])
Reference: https://opensource.com/article/20/3/open-source-writing-tools