Last active
February 23, 2018 12:01
-
-
Save ramizdemiurge/872ce9bc6069ad067a15db2cd516795a to your computer and use it in GitHub Desktop.
Categorizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
/** | |
* @author ramiz.demiurge | |
* @date 23.02.2018 | |
*/ | |
public class CategorizerClass { | |
private final static LinkedList<CategoryClass> categoryClassLinkedList = new LinkedList<>(); | |
static { | |
categoryClassLinkedList.add(new CategoryClass(1, "informasiya texnologiyaları", "informasiya", "информац", "программирование", "proqramlaşdırma")); | |
categoryClassLinkedList.add(new CategoryClass(3, "maliyyə", "maliyye")); | |
categoryClassLinkedList.add(new CategoryClass(4, "dizayn", "дизайн", "memar")); | |
categoryClassLinkedList.add(new CategoryClass(5, "marketinq", "маркетинг")); | |
categoryClassLinkedList.add(new CategoryClass(6, "satış", "satıs", "satısh")); | |
categoryClassLinkedList.add(new CategoryClass(7, "hüquqşünas", "huquqşunas", "huquqsunas", "hüquq")); | |
categoryClassLinkedList.add(new CategoryClass(8, "təhsil", "elm")); | |
categoryClassLinkedList.add(new CategoryClass(9, "xidmət", "xidmet")); | |
categoryClassLinkedList.add(new CategoryClass(11, "tibb", "əczaçılıq")); | |
categoryClassLinkedList.add(new CategoryClass(12, "sənaye", "senaye")); | |
categoryClassLinkedList.add(new CategoryClass(13, "inzibat")); | |
} | |
public static int getCategory(String categoryString) { | |
for (CategoryClass categoryClass : categoryClassLinkedList) { | |
for (String name : categoryClass.getNames()) { | |
if (categoryString.toLowerCase().contains(name)) return categoryClass.getCategoryId(); | |
} | |
} | |
return 0; | |
} | |
protected static class CategoryClass { | |
private int categoryId; | |
private String[] names; | |
CategoryClass(int categoryId, String... names) { | |
this.categoryId = categoryId; | |
this.names = names; | |
} | |
int getCategoryId() { | |
return categoryId; | |
} | |
String[] getNames() { | |
return names; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment