https://github.com/linuxscout/awk-arabic
Arabic Texts task by AWK
https://github.com/linuxscout/awk-arabic
Last synced: 26 days ago
JSON representation
Arabic Texts task by AWK
- Host: GitHub
- URL: https://github.com/linuxscout/awk-arabic
- Owner: linuxscout
- License: cc0-1.0
- Created: 2023-07-15T23:14:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-15T23:21:46.000Z (almost 2 years ago)
- Last Synced: 2023-07-16T00:22:25.229Z (almost 2 years ago)
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# awk-arabic
Arabic Texts task by AWKهذه الصفحة لكتابة بعض الملاحظات والإرشادات عن استعمال لغة برمجة AWK في مهام اللغة العربية
## أفكار لاستعمالات أوك* حذف الحركات
* تغيير الفاصل في ملف csv
* تقسيم النص إلى كلمات
* حساب تكرار الكلمات
* حذف الكلمات المستبعدة### حذف الحركات
أوك لا يدعم اليونيكود لذا علينا تحويل الحركات إلى utf8سكريبت حذف الحركات بواسطة أوك:
```awk
echo "أُحِبُّ وَطَنِي" | awk '{ gsub(/\xd9\x8b|\xd9\x8c|\xd9\x8d|\xd9\x8e|\xd9\x8f|\xd9\x90|\xd9\x91|\xd9\x92|\xd9\xb0/, ""); print }'
```
للحصول على سلسلة الحركات بشكل بايتات استعنّا بسكريبت بيثون
```python
repru = []
for c in u"\u064b\u064c\u064d\u064e\u064f\u0650\u0651\u0652\u0670":
code_point = ord(c) # Unicode code point
utf8_bytes = chr(code_point).encode('utf-8')
utf8_representation = ''.join([f'\\x{byte:02x}' for byte in utf8_bytes])
repru.append(utf8_representation)
print('|'.join(repru))
```
الناتج يكون:
```
\xd9\x8b|\xd9\x8c|\xd9\x8d|\xd9\x8e|\xd9\x8f|\xd9\x90|\xd9\x91|\xd9\x92|\xd9\xb0
```### حذف التطويل
رمز التطويل في يونيكود هو u0640
```awk
echo "1 **:-أحـــب:.*,5;" | awk '{ gsub(/\xd9\x80/, ""); print }'
```### convert multiline record to csv
FS = field separator
RS = record separator
OFS = output field separator
```awk
BEGIN { FS="\n"; RS=""; OFS="\t"}{print $1,$2,$9}
END {}
```## مراجع
30 Examples for Awk Command in Text Processing
https://likegeeks.com/awk-command/