File size: 2,257 Bytes
e4c29e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#/usr/bin/sh
# Build arabic misspelling corpus
DATA=abdnormal.txt
default: all
# Clean build files
clean:
	
backup: 
	
#create all files 
all: 

build:DATA=abdnormal
build:
	python scripts/analyze_doc.py -f output/${DATA}.unq -o output/${DATA}.csv

# Publish to github
publish:
	git push origin master 
spellcheck:
	# generate suggestion for unkown words
#~ 	hunspell -d ar_DZ -a samples/${DATA}  > output/${DATA}.1.tmp
suggest:
	# select mispelled words with suggestion only
	grep "^& " output/${DATA}.1.tmp > output/${DATA}.tmp
	sed "s/: /\t/g" -i output/${DATA}.tmp
	# extract word input in colums to separate it
	cut -f1 output/${DATA}.tmp > output/${DATA}.input.tmp 
	sed "s/&//g" -i output/${DATA}.input.tmp  
	sed "s/ /\t/g" -i output/${DATA}.input.tmp  

	# extract word suggestion in colums to separate it
	cut -f2 output/${DATA}.tmp  > output/${DATA}.suggest.tmp 
	sed "s/, /;/g" -i output/${DATA}.suggest.tmp 
	# join files
	echo "word\tn1\tn2\tsuggest"| cat >output/${DATA}.csv
	paste output/${DATA}.input.tmp output/${DATA}.suggest.tmp >> output/${DATA}.csv
	rm output/*.tmp
	
join:
	python scripts/join.py -c join -f samples/${DATA}  -f2 output/${DATA}.csv -o output/${DATA}.corpus.csv 
	
suggest2:
	#tokenize
#~ 	scripts/tokenize.sh  tests/samples/abdnormal.txt  >  tests/output/abdnormal.tok 

	# generate suggestion for unkown words
#~ 	cd tests; hunspell -d ar_DZ -a output/abdnormal.tok  > output/abd.1.tmp
	# select mispelled words with suggestion only
#~ 	cd tests; grep "^& " output/abd.1.tmp > output/abd.tmp
	cp tests/output/abd.1.tmp tests/output/abd.tmp 
#~ 	sed "s/\*/\*\t/g" -i tests/output/abd.tmp
	# remove first line
	sed 1d -i tests/output/abd.tmp 
	# remove empty lines
	sed -e '/^$$/d' -i tests/output/abd.tmp 
	sed "s/: /\t/g" -i tests/output/abd.tmp 
	# extract word input in colums to separate it
	cut -f1 tests/output/abd.tmp >tests/output/input.tmp 
#~ 	sed "s/&//g" -i tests/output/input.tmp 
	sed "s/ /\t/g" -i tests/output/input.tmp 

	# extract word suggestion in colums to separate it
	cut -f2 tests/output/abd.tmp >tests/output/suggest.tmp 
	sed "s/, /;/g" -i tests/output/suggest.tmp 
	# join files
	#paste tests/output/abdnormal.tok tests/output/input.tmp tests/output/suggest.tmp > tests/output/abdo.csv