Skip to content

Merge remote-tracking branch 'origin/develop' #6

Merge remote-tracking branch 'origin/develop'

Merge remote-tracking branch 'origin/develop' #6

Workflow file for this run

---
name: grammer check
on:
workflow_dispatch:
inputs:
grammar_check_disabled:
description: 'Disable grammar check'
default: 'false'
required: false
push:
branches:
- "**"
pull_request:
paths:
- 'docs/*.md'
types: [opened, edited, updated]
env:
GRAMMAR_CHECK_DISABLED: ${{ github.event.inputs.grammar_check_disabled || 'false' }}
jobs:
check-grammar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
# Install the dependencies for grammer check
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install --user --upgrade language_tool_python
# To check the grammatical mistakes of the given files and folders.
- name: Run grammar check
if: ${{ env.GRAMMAR_CHECK_DISABLED == 'false' }}
run: |
python - <<EOF
import language_tool_python
# Initialize LanguageTool
tool = language_tool_python.LanguageTool('en-US') # You can specify the language you want to check.
# Specify the directory path
directory_path = 'docs'
# Read the text from your file
file_path = 'docs/*.md' # Update the path accordingly
with open(file_path, 'r', encoding='utf-8') as file:
text = file.read()
# Check for grammar errors
matches = tool.check(text)
# Print relevant grammar errors with line numbers
relevant_errors = []
if matches:
for match in matches:
if match.ruleId == 'MORFOLOGIK_RULE_EN_US':
line_number = text.count('\n', 0, match.offset) + 1
relevant_errors.append((line_number, match.message))
if relevant_errors:
for error in relevant_errors:
line_number, message = error
print(f"Grammar error at line {line_number}: {message}")
exit(1)
else:
print("No grammar errors found.")
exit(0)
EOF