ye-nlp commited on
Commit
aa61fae
·
verified ·
1 Parent(s): ff6f281

Update detect_with_embedding.sh

Browse files
Files changed (1) hide show
  1. detect_with_embedding.sh +6 -6
detect_with_embedding.sh CHANGED
@@ -1,8 +1,8 @@
1
  #!/bin/bash
2
 
3
  # Define base directory, Python script, and input directory
4
- BASE_DIR="$HOME/exp/sylbreak4all/lang_detection/embedding"
5
- PYTHON_SCRIPT="$BASE_DIR/embed_lang_detect.py" # Replace with the name of your Python script
6
  INPUT_DIR="$BASE_DIR/data/eg_input"
7
  WORD2VEC_DIR="$BASE_DIR/word2vec"
8
  FASTTEXT_DIR="$BASE_DIR/fasttext"
@@ -14,14 +14,14 @@ run_detection() {
14
  echo "Running language detection using $model_type models..."
15
  for file in "$INPUT_DIR"/*; do
16
  filename=$(basename -- "$file")
17
- detected_language=$(python3 "$PYTHON_SCRIPT" --mode detect --input "$file" --model_folder "$model_dir")
18
  echo "File: $filename - Detected Language with $model_type: $detected_language"
19
 
20
  # Run detection on random sentences from the file, 10 times
21
  for i in {1..10}; do
22
  random_sentence=$(shuf -n 1 "$file")
23
  echo "Attempt $i - Random sentence from $filename: $random_sentence"
24
- detected_language_sentence=$(python3 "$PYTHON_SCRIPT" --mode detect --input "$random_sentence" --model_folder "$model_dir")
25
  echo "Detected Language with $model_type: $detected_language_sentence"
26
  done
27
  echo ""
@@ -29,10 +29,10 @@ run_detection() {
29
  }
30
 
31
  # Run detection using Word2Vec models
32
- run_detection "Word2Vec" "$WORD2VEC_DIR"
33
 
34
  # Run detection using FastText models
35
- run_detection "FastText" "$FASTTEXT_DIR"
36
 
37
  echo "Language detection completed for all files."
38
 
 
1
  #!/bin/bash
2
 
3
  # Define base directory, Python script, and input directory
4
+ BASE_DIR="$HOME/exp/myNLP/lang_detect"
5
+ PYTHON_SCRIPT="$BASE_DIR/demo_usage.py" # Replace with the name of your Python script
6
  INPUT_DIR="$BASE_DIR/data/eg_input"
7
  WORD2VEC_DIR="$BASE_DIR/word2vec"
8
  FASTTEXT_DIR="$BASE_DIR/fasttext"
 
14
  echo "Running language detection using $model_type models..."
15
  for file in "$INPUT_DIR"/*; do
16
  filename=$(basename -- "$file")
17
+ detected_language=$(python3 "$PYTHON_SCRIPT" --mode detect --approach $model_type --input "$file" --profiles "$model_dir")
18
  echo "File: $filename - Detected Language with $model_type: $detected_language"
19
 
20
  # Run detection on random sentences from the file, 10 times
21
  for i in {1..10}; do
22
  random_sentence=$(shuf -n 1 "$file")
23
  echo "Attempt $i - Random sentence from $filename: $random_sentence"
24
+ detected_language_sentence=$(python3 "$PYTHON_SCRIPT" --mode detect --approach $model_type --input "$random_sentence" --profiles "$model_dir")
25
  echo "Detected Language with $model_type: $detected_language_sentence"
26
  done
27
  echo ""
 
29
  }
30
 
31
  # Run detection using Word2Vec models
32
+ run_detection "word2vec" "$WORD2VEC_DIR"
33
 
34
  # Run detection using FastText models
35
+ run_detection "fasttext" "$FASTTEXT_DIR"
36
 
37
  echo "Language detection completed for all files."
38