mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
consolidate duplicated code to spammyCategory
This commit is contained in:
parent
d92225a3a2
commit
ee1d4c8edf
1 changed files with 5 additions and 5 deletions
|
|
@ -41,13 +41,14 @@ class CategoriesModel @Inject constructor(
|
||||||
Timber.d("Previous year: %s", prevYearInString)
|
Timber.d("Previous year: %s", prevYearInString)
|
||||||
|
|
||||||
val mentionsDecade = item.matches(".*0s.*".toRegex())
|
val mentionsDecade = item.matches(".*0s.*".toRegex())
|
||||||
|
val spammyCategory = item.matches("(.*)needing(.*)".toRegex())
|
||||||
|
|| item.matches("(.*)taken on(.*)".toRegex())
|
||||||
|
|
||||||
if (mentionsDecade) {
|
if (mentionsDecade) {
|
||||||
//Check if the year in the form of XX(X)0s is relevant, i.e. in the 2000s or 2010s (or 2020s) as stated in Issue #1029
|
//Check if the year in the form of XX(X)0s is recent/relevant, i.e. in the 2000s or 2010s/2020s as stated in Issue #1029
|
||||||
// If not, check if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750)
|
// If not, check if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750)
|
||||||
return !item.matches(".*20[0-2]0s.*".toRegex())
|
return !item.matches(".*20[0-2]0s.*".toRegex())
|
||||||
|| item.matches("(.*)needing(.*)".toRegex())
|
|| spammyCategory
|
||||||
|| item.matches("(.*)taken on(.*)".toRegex())
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If it is not an year in 20xxs form, then check if item contains a 4-digit word
|
// If it is not an year in 20xxs form, then check if item contains a 4-digit word
|
||||||
|
|
@ -57,8 +58,7 @@ class CategoriesModel @Inject constructor(
|
||||||
return item.matches(".*(19|20)\\d{2}.*".toRegex())
|
return item.matches(".*(19|20)\\d{2}.*".toRegex())
|
||||||
&& !item.contains(yearInString)
|
&& !item.contains(yearInString)
|
||||||
&& !item.contains(prevYearInString)
|
&& !item.contains(prevYearInString)
|
||||||
|| item.matches("(.*)needing(.*)".toRegex())
|
|| spammyCategory
|
||||||
|| item.matches("(.*)taken on(.*)".toRegex())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue