latest editions
This commit is contained in:
parent
420979be7d
commit
05e0a22874
51
data/classes51new.txt
Normal file
51
data/classes51new.txt
Normal file
|
@ -0,0 +1,51 @@
|
|||
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 - ورزش
|
|
@ -3,37 +3,22 @@
|
|||
"""
|
||||
import json
|
||||
|
||||
with open('./data/classes51.txt', 'r') as file:
|
||||
classes = file.readlines()
|
||||
with open('./data/classes51new.txt', 'r') as file:
|
||||
classes = file.read()
|
||||
|
||||
classes_list = classes.splitlines()
|
||||
|
||||
with open('./data/classification_ds.json', 'r') as file:
|
||||
sections = json.load(file)
|
||||
|
||||
# send content of some sections and classes to llama chat
|
||||
# and ask about the best class
|
||||
# and ask for the best class
|
||||
|
||||
|
||||
from html import escape
|
||||
from lxml import etree
|
||||
from datetime import datetime
|
||||
from elasticsearch import Elasticsearch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline, TextIteratorStreamer
|
||||
from threading import Thread
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
import torch
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import concurrent
|
||||
import threading
|
||||
import json
|
||||
import os.path
|
||||
import os
|
||||
import normalizer
|
||||
from funcs import write_to_json, read_from_json
|
||||
#lock = threading.Lock()
|
||||
#lock1 = threading.Lock()
|
||||
#from cleantext import clean
|
||||
#import re
|
||||
|
||||
import json
|
||||
from funcs import write_to_json
|
||||
|
||||
if torch.cuda.is_available():
|
||||
model_id = "PartAI/Dorna-Llama3-8B-Instruct"
|
||||
|
@ -46,22 +31,22 @@ remained = 0
|
|||
id = ''
|
||||
keywords_count = 15
|
||||
|
||||
|
||||
def command(text):
|
||||
global remained
|
||||
try:
|
||||
|
||||
messages = [{"role": "system", "content": "تو یک وکیل حقوق دان هستی و باید بتوانی متن های قانونی و حقوقی را به خوبی تفسیر کنی. " },
|
||||
messages = [{"role": "system", "content": "تو یک حقوق دان هستی و باید بتوانی متن های قانونی و حقوقی را به صورت حرفه ای تفسیر کنی. " },
|
||||
|
||||
{"role": "user", "content":
|
||||
'''با توجه به 51 کلاسی که در ادامه می آید، بهترین کلاس که از نظر محتوایی با متن زیر مطابقت دارد را از میان کلاس های ارائه شده انتخاب کن. تاکید می کنم که فقط اجازه داری یک کلاس را انتخاب کنی.
|
||||
نام کلاس باید دقیقا مطابق با عنوان های کلاس های 51 گانه باشد.
|
||||
هیچ توضیح اضافه ای پیش یا پس از عنوان کلاس ننویس.
|
||||
'''51 دسته در متن پرامپت می آید. در بین این دسته ها، شماره دسته ای که از نظر معنایی می تواند نزدیک ترین عنوان دسته برای متن باشد را انتخاب کن
|
||||
تاکید می کنم که فقط اجازه داری یک دسته را انتخاب کنی.
|
||||
فقط شماره دسته را به صورت یک عدد در خروجی بیاور.
|
||||
به هیچ عنوان، هیچ توضیح اضافه ای پیش یا پس از شماره دسته در خروجی ننویس.
|
||||
"متن": {}
|
||||
'''.format(text)
|
||||
},
|
||||
{"role": "user", "content":
|
||||
'''کلاس های 51 گانه عبارت اند از: {}
|
||||
'''دسته های 51 گانه عبارت اند از: {}
|
||||
'''.format(classes)
|
||||
},
|
||||
]
|
||||
|
@ -110,26 +95,31 @@ if __name__ == "__main__":
|
|||
prev_class = sections[counter]['domain_name']
|
||||
content = sections[counter]['content']
|
||||
|
||||
new_class = command(content)
|
||||
new_class = command(content)
|
||||
try:
|
||||
new_class_title = (classes_list[(int(new_class))-1].split('-')[1]).strip()
|
||||
except:
|
||||
new_class_title = '-'
|
||||
|
||||
print("section " + str(count) + "/" + str(len(sections)) + " class extracting ... ")
|
||||
classes_dict.append({
|
||||
'id': count,
|
||||
'content':content,
|
||||
'prev-class': prev_class,
|
||||
'new-class': new_class
|
||||
'new-class-title': new_class_title,
|
||||
'new-class': new_class,
|
||||
})
|
||||
count+= 1
|
||||
counter+= 500
|
||||
|
||||
if counter > 49387:
|
||||
break
|
||||
write_to_json(classes_dict, "./data/result.json")
|
||||
write_to_json(classes_dict, "./data/result4.json")
|
||||
|
||||
except Exception as inst:
|
||||
print(type(inst)) # the exception type
|
||||
print(inst.args) # arguments stored in .args
|
||||
|
||||
|
||||
|
||||
end_time = time.time()
|
||||
print(end_time)
|
||||
operation_time = (int(end_time-start_time)/60)/60
|
||||
|
|
Loading…
Reference in New Issue
Block a user