ArvixApiAccess is Kotlin written open-source library to make search requests to API of Arvix.org
In order to start using you should add that dependency to your project.
<repository>
<id>myMavenRepoRead</id>
<url>https://mymavenrepo.com/repo/m3NxrnIEacYdXdF77zDL/</url>
</repository>
...
<dependency>
<groupId>olegthelilfix</groupId>
<artifactId>ArxivApiAccess</artifactId>
<version>${ArxivApiAccess.version}</version>
</dependency>
In order to start using you should add that dependency to your project.
repositories {
...
maven {
url "https://mymavenrepo.com/repo/m3NxrnIEacYdXdF77zDL/"
}
...
}
...
dependencies {
...
compile group: 'olegthelilfix', name: 'ArxivApiAccess', version: '0.2-RELEASE'
...
}
// Request to find the last 20 articles about Java or Kotlin
val request: SearchRequest = SearchRequest.SearchRequestBuilder
.create("Java", SearchField.ALL)
.or("Kotlin", SearchField.ALL)
.sortBy(SortBy.LAST_UPTATED_DATE)
.sortOrder(SortOrder.DESCENDING)
.maxResults(20)
.build()
val response: Feed = SearchRequestExecutor().executeAndMap(request)
val responseAsString: String = SearchRequestExecutor().execute(request)
println(response)
println(responseAsString)
val subjectCategory = "JAVA"
val fileToSave = "../arxiv_data_sets/${subjectCategory}.csv"
// All article about java
val request = SearchRequest.SearchRequestBuilder
.create(subjectCategory, SearchField.ALL)
.build()
loadAllByRequest(request, {feed ->
// save to file
val writer = FileWriter(fileToSave, true)
writer.use {
feed.entry?.forEach {
val authorString = it.author.joinToString(", ") { author -> author.name }
val resultString = "${it.updated}|${subjectCategory}|${it.title}|${authorString}".replace("\n", "")
writer.write("${resultString}\n")
}
writer.close()
}
println("parsed ${feed.startIndex+feed.itemsPerPage}/${feed.totalResults}")
// return false to stop a process of the parsing
true
})
// the request to find all articles about Java or Kotlin for last 30 days
val request: SearchRequest = SearchRequest.SearchRequestBuilder
.create("Java", SearchField.ALL)
.or("Kotlin", SearchField.ALL)
.build()
var list = searchAllByPeriod(request, Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS)))
println(list)
feed.entry?.forEach {
it.category.forEach { category ->
try {
val categoryFullName = convertTermCode(category.term)
println("Mapped ${category.term} to ${categoryFullName}")
}
catch (e: TermNotFoundException) {
println(e.message)
}
}
}
#linked projects @articleflowbot or ArticleFlow github is the telegram bot to make search request to arxiv.org
Feel free to email me at olegthelilfix@pm.me