Skip to content

Commit

Permalink
verify profanities
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton committed Apr 28, 2024
1 parent f6f26af commit 86f3696
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Print the result
run: |
echo "Translations are: '${{ steps.google-translate.outputs.text }}'"
echo "${{ steps.google-translate.outputs.text }}" | sed 's/; /\n/g' > translated_texts.txt
echo "${{ steps.google-translate.outputs.text }}" | sed 's/ ; /\n/g' > translated_texts.txt
cat translated_texts.txt > ./scripts/checkProfanity.sh
shell: sh
- name: Upload Raw Translations
Expand Down
3 changes: 2 additions & 1 deletion scripts/checkProfanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

file = open("suspicious_texts.txt", "a")
for line in sys.stdin:
print("Checking: "+str(line.rstrip()))
prediction = predict_prob([line.rstrip()])
if prediction[0] > 0.5:
file.write(str(line.rstrip())+"\n")
print(str(line.rstrip()))
print("Offending line: "+str(line.rstrip()))

file.close()
5 changes: 3 additions & 2 deletions scripts/generateFilelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fi
DIFF=$(git diff -U0 HEAD~$1 ${@:2} | grep -E "^\+" | grep -v +++ | cut -c 2- | sed 's/^[ \t]*\(.*$\)/\1/')
echo "<xml>$DIFF</xml>" | xmlstarlet sel -t -m '//string' -v . -n > changed_texts.txt
TRANSLATIONS=$(cat changed_texts.txt)
TRANSLATIONS="${TRANSLATIONS//$'\n'/';'}"
TRANSLATIONS="${TRANSLATIONS//$'\r'/';'}"
TRANSLATIONS="${TRANSLATIONS//'%'/' ; '}"
TRANSLATIONS="${TRANSLATIONS//$'\n'/' ; '}"
TRANSLATIONS="${TRANSLATIONS//$'\r'/' ; '}"
echo $TRANSLATIONS

0 comments on commit 86f3696

Please sign in to comment.