|
Termiz davlat universiteti Intellectual texnologiyalar fakulteti
|
Sana | 14.05.2024 | Hajmi | 106,13 Kb. | | #232201 |
Bog'liq 15-mustaqil ta\'lim
Termiz davlat universiteti
Intellectual texnologiyalar fakulteti
KI-123 guruh talabasi
Ahmadbek Nazarovning
MT ishi
MT.Tashqi kutubxonalar ustida amallar
Matnni rus tiliga tarjima qilish.
pip install googletrans
from googletrans import Translator
matn_uz="Python - dunyodagi eng mashxur dasturlash tili"
tarjima_ru = tarjimon.translate(matn_uz, dest='ru')
print(tarjima_ru.text)
2.ingliz tilidagi matnni o’zbek tiliga tarjima qilish.
pip install googletrans
from googletrans import Translator
matn_en = "Tashkent is the capital of Uzbekistan"
tarjima_uz = tarjimon.translate(matn_en, dest='uz')
print(tarjima_uz.text)
3.matn tilini alohida ko’rsatib tarjima qilish.
tarjima_uz = tarjimon.translate(matn_en, src='uz', dest='uz')
print(tarjima_uz.text)
4.requests yordamida kun.uz sahifasini to'liqligicha tortibb olish
import requests
from pprint import pprint
manzil= "https://kun.uz/news/main"
r = requests.get(manzil)
pprint(r.text)
restcountries.eu sahifasida API so’rov yuborish.
country = "Uzbekistan"
url = f"https://restcountries.eu/rest/v2/name/{country}"
r = requests.get(url)
r_json = r.json()[0]
print(r_json['capital'])
6.bs4 yordamida html sahifadan oxirgi yangiliklarning mavzusini ajratib olish..
import requests
from bs4 import BeautifulSoup
sahifa = "https://kun.uz/news/main"
r = requests.get(sahifa)
soup = BeautifulSoup(r.text, 'html.parser')
news = soup.find_all(class_="news-title") # yangiliklarning mavzusini ajratib olish
print(news[0].text) # eng birinchi yangilikni konsolga chiqarish
kun.uz sahifasidan olingan yangiliklar uchun so'zlar bulutini yaratish
import requests
from bs4 import BeautifulSoup
from wordcloud import WordCloud
import matplotlib.pyplot as plt
sahifa = "https://kun.uz/news/main"
r = requests.get(sahifa)
soup = BeautifulSoup(r.text, 'html.parser')
news = soup.find_all(class_="news-title")
matn=""
for n in news:
matn += n.text
# kerakmas so'zlar
stopwords=["учун","бўйича","лекин","билан","ва","бор","ҳам","хил",# bulutni yaratish
wordcloud = WordCloud(width = 1000, height = 1000,
background_color ='white',
stopwords = stopwords,
min_font_size = 20).generate(matn)
# plot the WordCloud image
plt.figure(figsize = (8, 8), facecolor = None)
plt.imshow(wordcloud)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
sozlarni bir-biri bilan solishtirish.
from fuzzywuzzy import fuzz
print(fuzz.ratio("salom",'assalom'))
print(fuzz.ratio("salom","salim"))
so'zlar orasidan o'xshash so'zlarni topish.
from fuzzywuzzy import process
from uzwords import words
text = "салом"
matches = process.extract(text, words, limit=3)
print(matches)
yagona so'zni tanlab olish.
from fuzzywuzzy import process
from uzwords import words
text = "telba"
match = process.extractOne(text,words)
print(match)
10.Matnni rus tiliga tarjima qilish.
pip install googletrans
from googletrans import Translator
matn_uz="Python - dunyodagi eng mashxur dasturlash tili"
tarjima_ru = tarjimon.translate(matn_uz, dest='ru')
print(tarjima_ru.text)
11.ingliz tilidan o’zbek tiliga tarjima qilish.
from googletrans import Translator
matn_en = "Tashkent is the capital of Uzbekistan"
tarjima_uz = tarjimon.translate(matn_en, dest='uz')
print(tarjima_uz.text)
ingliz tilidan rus tiliga tarjima qilish.
matn_en = "Tashkent is the capital of Uzbekistan"
tarjima_ru = tarjimon.translate(matn_en, dest='ru')
print(tarjima_ru.text)
tarjimon dastur yaratish .
import wx
from googletrans import Translator
tarjimon = Translator()
class MyFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='Oʻzbek-Ingliz Lugʻat')
panel = wx.Panel(self)
my_sizer = wx.BoxSizer(wx.VERTICAL)
self.text_ctrl = wx.TextCtrl(panel)
my_sizer.Add(self.text_ctrl, 0, wx.ALL | wx.EXPAND, 5)
my_btn=wx.Button(panel,label='TARJIMA') my_btn.Bind(wx.EVT_BUTTON,self.on_press) my_sizer.Add(my_btn, 0, wx.ALL | wx.CENTER, 5)
self.text_out=wx.TextCtrl(panel,style=wx.TE_READONY) my_sizer.Add(self.text_out,0,wx.ALL|wx.EXPAND,5) panel.SetSizer(my_sizer)
self.Show()
def on_press(self, event):
value = self.text_ctrl.GetValue()
if not value:
self.text_out.SetValue("Soʻz kiritmadingiz")
else:
tarjima = tarjimon.translate(value,src='uz',dest='en') self.text_out.SetValue(tarjima.text.capitalize())
if __name__ == '__main__':
app = wx.App() frame = MyFrame() app.MainLoop()
daryo sayti yangiliklarini yuklab olish.
import requests
from pprint import pprint
manzil= "https://kun.uz/news/main"
r = requests.get(manzil)
pprint(r.text)
rus tilidan ingliz tiliga matnni tarjima qilish.
matn_ru = "Ташкент-столица Узбекистана"
tarjima_en = tarjimon.translate(matn_ru, dest='en')
print(tarjima_en.text)
|
| |