2.3.Masalani qo`yilishi
Hozirgi kunda foydalanuvchilarga Lugat dasturlardan ko’p foydalanishadi. Shu sababli bu dastur foydalanuvchi uchun sodda va tushinarli bo’lishi kerak. Bundan tashqari foydalanuvchiga tez qidirishi uchun filt tizimi yani indexlar buyicha qidirish yaratish lozim.Shu maqsada hozirgi kurs ishimda yaratilgan RU-Uz ilovasini orqali lugatdan foydalanishi va unda lugatni qidirishi mumkin
Asosiy Qism
Malumotlar bazasini yaratish
Dasturni yaratishda avvalo ma’lumotlar bazasini, undagi jadvallarni, jadvaldagi ustunlarni to’g’ri kiritish lozim. Jadval, ustun nomlarini yozishda probel, apostriv(‘) belgilaridan foydalanmaslik zarur.
Birinchi navbatda UZ-RU ilovasini ishlab chiqishdan oldin malumotlar bazasini yaratib olish lozim.Android Studioda malumotlar bazasi Sqlite,Room va MySql kabi dasturlarda yaratiladi.
Android ilovasini Room Database yordamida malumotlar bazasini yaratib olamiz,Bu uchun bazi bir kutubxonalarni yuklab olishimiz kerak va build.grade tashlashimiz kerak.
implementation "androidx.room:room-runtime: 2.2.5" kapt "androidx.room:room-compiler:2.2.5"
annotationProcessor "androidx.room:room-compiler: 2.2.5" implementation "androidx.room:room-ktx:2.2.5”
Language degan Class orqali table yaratib olamiz
C
import androidx.room.ColumnInfo
|
|
|
import androidx.room.Entity
|
|
import androidx.room.PrimaryKey
|
|
|
|
@Entity(tableName = "WORDS")
|
|
data class Word(
|
|
@PrimaryKey
|
|
val id: Int,
|
|
val word: String?,
|
|
val meaning: String?,
|
|
@ColumnInfo(defaultValue = "0")
|
|
var isfav: Int?
|
|
|
|
) {
|
|
constructor() : this(0, "", "", 0)
|
|
}
|
LanguageDaoni interfecani yaratib olamiz.Bu yerda biz malumotlarni
kiritishimiz,o`chirishimiz va qidirishimiz mumkin. Qidirishda bizda Sql lite surovlar
tilidan foydalanamiz
@Dao
|
|
|
interface Dao {
|
|
|
|
@Update
|
|
fun updateWord(word: Word) : Completable
|
|
|
|
@Query("select id, word, meaning, isfav from WORDS order by lower(word)")
|
|
fun getAllWords(): Observable>
|
|
|
|
@Query("select * from WORDS where isfav = 1 order by lower(word)")
|
|
fun getFavorautes(): Observable>
|
|
|
|
// @Query("select id, word, meaning, isfav from WORDS where word like :s or word is null")
|
|
// fun search(s : String?)
|
|
|
|
}
|
@Database(entities = [Word::class], version = 1)
|
|
|
abstract class RuDB : RoomDatabase()
|
|
{
|
|
abstract fun dao() : Dao
|
|
|
|
companion object {
|
|
|
|
|
|
private var instance: RuDB? = null
|
|
|
|
fun initDatabase(context: Context) {
|
|
synchronized(this) {
|
|
if (instance == null) {
|
|
instance = Room
|
|
.databaseBuilder(context.applicationContext, RuDB::class.java, "ru.db")
|
|
.fallbackToDestructiveMigration()
|
|
.createFromAsset("ru.db")
|
|
.build()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun getDatabase() = instance!!
|
|
|
|
}
|
|
|
|
|
|
|
|
}
@Database(entities = [Word::class], version = 1)
|
|
|
abstract class UzDB : RoomDatabase()
|
|
{
|
|
abstract fun dao() : Dao
|
|
|
|
companion object {
|
|
|
|
private var instance: UzDB? = null
|
|
|
|
fun initDatabase(context: Context) {
|
|
synchronized(this) {
|
|
if (instance == null) {
|
|
instance = Room
|
|
.databaseBuilder(context.applicationContext, UzDB::class.java, "uz.db")
|
|
.fallbackToDestructiveMigration()
|
|
.createFromAsset("uz.db")
|
|
.build()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun getDatabase() = instance!!
|
|
|
|
}
|
|
}
|
|
Qidiruv timini avtomlashtirishda “ruuz.db” nomli malumotlar omborini tashkil qildim.Malumotlar omborida(4-rasm) “ru” nomli jadvallar mavjud.Internet
tarqmoqida ulangandan keyin belgilangan malumotlarni malumotlar omboriga saqlab
olishimiz va saqlangan malumotlarni nomi orqali qidirishimiz mumkin
Dastur loyihasini yaratishda
Malumotlar bazasi va Internetdan malumotlarni olish uchun ApiServerce va ApiClientni yaratib bo`lganimizdan so`ng dastur yaratishni boshlaymiz.Dastur yaratishda Android Studiodan foydalandim. Dasturni ishga tushirishda Android Studio Create New Projectmi tanlab olamiz(5-rasm)
rasm Android Yangi Loyiha hosil qilish
rasm
Create New Project ni bosganimizdan Keyin Empty Activityni tanlaymiz(6-rasm) va
proektni quydagicha dizaynda hosil qildim(6-7-8 -rasm)
6-rasm Lugat search 7-rasm Details Page
Xulosa
Hammamizga ma’lumki, XXI asr “Axborot texnologiyalari asri” hisoblanadi. Bu asrda dasturlash sohasida misli ko‘rilmagan o‘zgarishlar bo‘ldi. Bunda avtomatlashtirish dasturning asosini tashkil qiladi. Yuqorida yaratilgan dastur ham foydalanuvchiga turli qulayliklar yaratib, qidirish sifatini oshiradi. Men dastur tuzish davomida Android Studi va Kotlin dasturlash tillaridan keng imkoniyatlar yaratilganligini tushundim. Ayniqsa MySQL, RestApi va Room Database kabi dasturlar bilan hamkorlikda ishlashi menda katta qiziqish uyg‘otdi. Men bu kurs ishini qilish davomida Android Studio dasturi yordamida ma’lumotlar bazasini boshqarishni,Rest Api va Retrofit va dasturda turli interfeyslarda yaratishni, formalar ustida amallar bajarishni o‘rgandim.
Men ushbu kurs ishini bajarish davomida Kotlin tili da dasturlash hamda qidiruv tizimini avtomatlashtirish to’g’risidagi bilimlarimni mustaxkamlab oldim. Dastur tuzish davomida Android Studio da ishladim. Android Studio ko’plab komponentalarni ishlatdim. Kurs ishini bajarish davomida dasturdagi ko’plab komponentalar palitrasidan foydalanishni, dastur tuzishdan oldin uning algoritmini to’liq tuzib chiqish lozimligini o’rgandim. Chunki dasturchi dasturni tuzishdan oldin uning algoritmini ishlab chiqib dasturni qanday natija qaytarishini bilgan holdagina dastur bexato, samarali ishlar ekan komponentalardan foydalanishni o’rgandim. Men ushbu kurs ishini bajarish davomida juda ko’p narsalarni o’rgandim.
Foydalanilgan adabiyotlar Internet
Best of the Web 1994 -- Naviga-
tors http://botw.org/1994/awards/navigators.html
Bill Clinton Joke of the Day: April 14,
1997. http://www.io.com/~cjburke/clinton/970414.html.
Bzip2 Homepage http://www.muraroa.demon.co.uk/
Google Search Engine http://google.stanford.edu/
Harvest http://harvest.transarc.com/
Mauldin, Michael L. Lycos Design Choices in an Internet Search Service, IEEE Expert Inter-
view http://www.computer.org/pubs/expert/1997/trends/x1008/mauldin.htm
The Effect of Cellular Phone Use Upon Driver Atten- tion http://www.webfirst.com/aaa/text/cell/cell0toc.htm
Search Engine Watch http://www.searchenginewatch.com/
RFC 1950 (zlib) ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc- index.html
Robots Exclusion Proto-
col: http://info.webcrawler.com/mak/projects/robots/exclusion.htm
Web Growth Summary: http://www.mit.edu/people/mkgray/net/web- growth-summary.html
Yahoo! http://www.yahoo.com/
Github https://github.com/UchqunShodmonov/NewsApp Tezislar
[Abiteboul 97] Serge Abiteboul and Victor Vianu, Queries and Computation on the Web. Proceedings of the International Conference on Database Theory. Delphi, Greece 1997.
[Bagdikian 97] Ben H. Bagdikian. The Media Monopoly. 5th Edition. Pub- lisher: Beacon, ISBN: 0807061557
[Chakrabarti 98] S.Chakrabarti, B.Dom, D.Gibson, J.Kleinberg, P. Ragha- van and S. Rajagopalan. Automatic Resource Compilation by Analyzing Hyperlink Structure and Associated Text. Seventh International Web Confe- rence (WWW 98). Brisbane, Australia, April 14-18, 1998.
[Cho 98] Junghoo Cho, Hector Garcia-Molina, Lawrence Page. Efficient Crawling Through URL Ordering. Seventh International Web Conference (WWW 98). Brisbane, Australia, April 14-18, 1998.
[Gravano 94] Luis Gravano, Hector Garcia-Molina, and A. Tomasic. The Ef- fectiveness of GlOSS for the Text-Database Discovery Problem. Proc. of the 1994 ACM SIGMOD International Conference On Management Of Data, 1994.
[Kleinberg 98] Jon Kleinberg, Authoritative Sources in a Hyperlinked Envi- ronment, Proc. ACM-SIAM Symposium on Discrete Algorithms, 1998.
[Marchiori 97] Massimo Marchiori. The Quest for Correct Information on the Web: Hyper Search Engines. The Sixth International WWW Conference (WWW 97). Santa Clara, USA, April 7-11, 1997.
[McBryan 94] Oliver A. McBryan. GENVL and WWWW: Tools for Taming the Web. First International Conference on the World Wide Web. CERN, Geneva (Switzerland), May 25-26-27
1994. http://www.cs.colorado.edu/home/mcbryan/mypapers/www94.ps
[Page 98] Lawrence Page, Sergey Brin, Rajeev Motwani, Terry Wino- grad. The PageRank Citation Ranking: Bringing Order to the
Web. Manuscript in
progress. http://google.stanford.edu/~backrub/pageranksub.ps
[Pinkerton 94] Brian Pinkerton, Finding What People Want: Experiences with the WebCrawler. The Second International WWW Conference Chica- go, USA, October 17-20,
1994. http://info.webcrawler.com/bp/WWW94.html
[Spertus 97] Ellen Spertus. ParaSite: Mining Structural Information on the Web. The Sixth International WWW Conference (WWW 97). Santa Clara, USA, April 7-11, 1997.
[TREC 96] Proceedings of the fifth Text REtrieval Conference (TREC-
5). Gaithersburg, Maryland, November 20-22, 1996. Publisher: Department of Commerce, National Institute of Standards and Technology. Editors: D.
K. Harman and E. M. Voorhees. Full text at: http://trec.nist.gov/
[Witten 94] Ian H Witten, Alistair Moffat, and Timothy C. Bell. Managing Gigabytes: Compressing and Indexing Documents and Images. New York: Van Nostrand Reinhold, 1994.
[Weiss 96] Ron Weiss, Bienvenido Velez, Mark A. Sheldon, Chanathip Manprempre, Peter Szilagyi, Andrzej Duda, and David K. Gif-
ford. HyPursuit: A Hierarchical Network Search Engine that Exploits Con- tent-Link Hypertext Clustering. Proceedings of the 7th ACM Conference on Hypertext. New York, 1996.
Ilova
@Database(entities = [Word::class], version = 1)
|
|
|
abstract class UzDB : RoomDatabase()
|
|
{
|
|
abstract fun dao() : Dao
|
|
|
|
companion object {
|
|
|
|
private var instance: UzDB? = null
|
|
|
|
fun initDatabase(context: Context) {
|
|
synchronized(this) {
|
|
if (instance == null) {
|
|
instance = Room
|
|
.databaseBuilder(context.applicationContext, UzDB::class.java, "uz.db")
|
|
.fallbackToDestructiveMigration()
|
|
.createFromAsset("uz.db")
|
|
.build()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun getDatabase() = instance!!
|
|
|
|
}
|
|
}
|
|
|
@Database(entities = [Word::class], version = 1)
|
|
|
abstract class RuDB : RoomDatabase()
|
|
{
|
|
abstract fun dao() : Dao
|
|
|
|
companion object {
|
|
|
|
|
|
private var instance: RuDB? = null
|
|
|
|
fun initDatabase(context: Context) {
|
|
synchronized(this) {
|
|
if (instance == null) {
|
|
instance = Room
|
|
.databaseBuilder(context.applicationContext, RuDB::class.java, "ru.db")
|
|
.fallbackToDestructiveMigration()
|
|
.createFromAsset("ru.db")
|
|
.build()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun getDatabase() = instance!!
|
|
|
|
}
|
|
|
@Dao
|
|
|
|
interface Dao {
|
|
|
|
@Update
|
|
fun updateWord(word: Word) : Completable
|
|
|
|
@Query("select id, word, meaning, isfav from WORDS order by lower(word)")
|
|
fun getAllWords(): Observable>
|
|
|
|
@Query("select * from WORDS where isfav = 1 order by lower(word)")
|
|
fun getFavorautes(): Observable>
|
|
|
|
// @Query("select id, word, meaning, isfav from WORDS where word like :s or word is null")
|
|
// fun search(s : String?)
|
|
|
|
}
|
|
@Entity(tableName = "WORDS")
|
|
|
|
data class Word(
|
|
|
@PrimaryKey
|
|
|
val id: Int,
|
|
|
val word: String?,
|
|
|
val meaning: String?,
|
|
|
@ColumnInfo(defaultValue = "0")
|
|
|
var isfav: Int?
|
|
|
|
|
|
) {
|
|
|
constructor() : this(0, "", "", 0)
|
|
|
}
|
class Repository private constructor(context: Context) {
|
|
|
private lateinit var ruDB: RuDB
|
|
private lateinit var uzDB: UzDB
|
|
|
|
init {
|
|
UzDB.initDatabase(context)
|
|
RuDB.initDatabase(context)
|
|
uzDB = UzDB.getDatabase()
|
|
ruDB = RuDB.getDatabase()
|
|
}
|
|
|
|
companion object {
|
|
private var instens: Repository? = null
|
|
fun getInstens(context: Context): Repository {
|
|
if (instens == null)
|
|
instens = Repository(context)
|
|
return instens!!
|
|
}
|
|
}
|
|
|
|
fun getRuWORDS() = ruDB.dao().getAllWords()
|
|
fun getUzWORDS() = uzDB.dao().getAllWords()
|
|
fun getRuFavWORDS() = ruDB.dao().getFavorautes()
|
|
fun getUzFavWORDS() = uzDB.dao().getFavorautes()
|
|
fun updateRuWord(word: Word) = ruDB.dao().updateWord(word)
|
|
fun updateUzWord(word: Word) = uzDB.dao().updateWord(word)
|
|
// fun searchRuWord(s: String) = ruDB.dao().search(s)
|
|
// fun searchUzWord(s: String) = uzDB.dao().search(s)
|
|
}
|
Do'stlaringiz bilan baham: |