/*
 * SDK Pullenti Lingvo, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software.
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.ner.vacance;

/**
 * Анализатор вакансий (специфический анализатор)
 */
public class VacanceAnalyzer extends com.pullenti.ner.Analyzer {

    /**
     * Имя анализатора ("VACANCE")
     */
    public static final String ANALYZER_NAME = "VACANCE";

    @Override
    public String getName() {
        return ANALYZER_NAME;
    }


    @Override
    public String getCaption() {
        return "Вакансия";
    }


    @Override
    public String getDescription() {
        return "Текст содержит одну вакансию";
    }


    @Override
    public com.pullenti.ner.Analyzer clone() {
        return new VacanceAnalyzer();
    }

    @Override
    public boolean isSpecific() {
        return true;
    }


    @Override
    public java.util.Collection<com.pullenti.ner.metadata.ReferentClass> getTypeSystem() {
        return java.util.Arrays.asList(new com.pullenti.ner.metadata.ReferentClass[] {MetaVacance.GLOBALMETA});
    }


    @Override
    public java.util.HashMap<String, byte[]> getImages() {
        java.util.HashMap<String, byte[]> res = new java.util.HashMap<String, byte[]>();
        res.put(MetaVacance.IMAGEID.toString(), com.pullenti.ner.core.internal.ResourceHelper3.getBytes("vacance.png"));
        return res;
    }


    @Override
    public com.pullenti.ner.Referent createReferent(String type) {
        if (com.pullenti.unisharp.Utils.stringsEq(type, VacanceItemReferent.OBJ_TYPENAME)) 
            return new VacanceItemReferent();
        return null;
    }

    @Override
    public int getProgressWeight() {
        return 1;
    }


    @Override
    public void process(com.pullenti.ner.core.AnalysisKit kit) {
        com.pullenti.ner.core.AnalyzerData ad = kit.getAnalyzerData(this);
        java.util.ArrayList<com.pullenti.ner.vacance.internal.VacanceToken> li = com.pullenti.ner.vacance.internal.VacanceToken.tryParseList(kit.firstToken);
        if (li == null || (li.size() < 1)) 
            return;
        boolean isExpired = false;
        for (com.pullenti.ner.vacance.internal.VacanceToken v : li) {
            if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.EXPIRED) 
                isExpired = true;
        }
        boolean hasDate = false;
        boolean hasSkills = false;
        for (com.pullenti.ner.vacance.internal.VacanceToken v : li) {
            if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.UNDEFINED || v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.DUMMY) 
                continue;
            if (com.pullenti.unisharp.Utils.isNullOrEmpty(v.value) && v.refs.size() == 0) 
                continue;
            VacanceItemReferent it = new VacanceItemReferent();
            if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.DATE) {
                it.setTyp(VacanceItemType.DATE);
                hasDate = true;
            }
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.EXPIERENCE) 
                it.setTyp(VacanceItemType.EXPERIENCE);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.MONEY) 
                it.setTyp(VacanceItemType.MONEY);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.NAME) {
                it.setTyp(VacanceItemType.NAME);
                if (isExpired) 
                    it.setExpired(true);
            }
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.EDUCATION) 
                it.setTyp(VacanceItemType.EDUCATION);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.LANGUAGE) 
                it.setTyp(VacanceItemType.LANGUAGE);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.DRIVING) 
                it.setTyp(VacanceItemType.DRIVINGLICENSE);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.LICENSE) 
                it.setTyp(VacanceItemType.LICENSE);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.MORAL) 
                it.setTyp(VacanceItemType.MORAL);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.PLUS) 
                it.setTyp(VacanceItemType.PLUS);
            else if (v.typ == com.pullenti.ner.vacance.internal.VacanceTokenType.SKILL) {
                it.setTyp(VacanceItemType.SKILL);
                hasSkills = true;
            }
            else 
                continue;
            if (v.value != null) 
                it.setValue(v.value);
            for (com.pullenti.ner.Referent r : v.refs) {
                it.addSlot(VacanceItemReferent.ATTR_REF, r, false, 0);
            }
            com.pullenti.ner.ReferentToken rt = new com.pullenti.ner.ReferentToken(ad.registerReferent(it), v.getBeginToken(), v.getEndToken(), null);
            kit.embedToken(rt);
        }
    }

    private static boolean m_Initialized = false;

    private static Object m_Lock;

    public static void initialize() {
        synchronized (m_Lock) {
            if (m_Initialized) 
                return;
            m_Initialized = true;
            MetaVacance.initialize();
            com.pullenti.ner.vacance.internal.VacanceToken.initialize();
            com.pullenti.ner.ProcessorService.registerAnalyzer(new VacanceAnalyzer());
        }
    }

    public VacanceAnalyzer() {
        super();
    }
    
    static {
        m_Lock = new Object();
    }
}
