Skip to content

Instantly share code, notes, and snippets.

@ramizdemiurge
Last active February 23, 2018 12:01
Show Gist options
  • Save ramizdemiurge/872ce9bc6069ad067a15db2cd516795a to your computer and use it in GitHub Desktop.
Save ramizdemiurge/872ce9bc6069ad067a15db2cd516795a to your computer and use it in GitHub Desktop.
Categorizer
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