Skip to content

Commit

Permalink
WIP: detect lang - #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltdev committed Feb 27, 2018
1 parent 427db92 commit ddd3a41
Show file tree
Hide file tree
Showing 5 changed files with 742 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
hashes*
hashes*
node_modules
34 changes: 34 additions & 0 deletions langdetect/detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

if [ ! $(command -v nodejs) ] && [ ! $(command -v node) ]
then
echo Nodejs is needed to run this script
exit 1
fi

if [ $(command -v yarn) ]
then
yarn
elif [ $(command -v npm) ]
then
npm i
else
echo Yarn or NPM is needed to install dependencies
exit 1
fi

if [ ! -f "queries.tmp" ]
then
cp ../src/queries ./queries.tmp
fi

while IFS= read -r line
do
lang=$(echo $line | ./node_modules/.bin/franc)
if [ ! -d ../src/lang/"$lang"/ ]
then
mkdir ../src/lang/"$lang"/
fi
echo $line >> ../src/lang/"$lang"/"$lang"
tail -n +2 ./queries.tmp > ./.queries.tmp && mv ./.queries.tmp ./queries.tmp
done < ./queries.tmp
Loading

0 comments on commit ddd3a41

Please sign in to comment.