Search in sources :

Example 41 with Individual

use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.

the class AnimationConstructionServiceImpl method dealCompanys.

public boolean dealCompanys(Individual animationIndividual, BaikePage baikePage) {
    List<String> companys = new ArrayList<String>();
    int index = 0;
    for (String parameterName : baikePage.getParameterNames()) {
        if (parameterName.equals("动画制作")) {
            companys = Arrays.asList(baikePage.getParameterValues().get(index).split("、"));
            if (companys.size() == 1) {
                companys = Arrays.asList(baikePage.getParameterValues().get(index).split(","));
            }
            for (String company : companys) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (company.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual companyIndividual = this.queryIndividual(company, polysemantExplain, url, true, OntologyClassEnum.COMPANY);
                    constructionDAO.addObjectProperty(companyIndividual, "制作", animationIndividual);
                }
            }
        }
        if (parameterName.equals("制片")) {
            companys = Arrays.asList(baikePage.getParameterValues().get(index).split("、"));
            if (companys.size() == 1) {
                companys = Arrays.asList(baikePage.getParameterValues().get(index).split(","));
            }
            for (String company : companys) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (company.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual companyIndividual = this.queryIndividual(company, polysemantExplain, url, true, OntologyClassEnum.COMPANY);
                    constructionDAO.addObjectProperty(companyIndividual, "制片", animationIndividual);
                    constructionDAO.addObjectProperty(companyIndividual, "制作", animationIndividual);
                }
            }
        }
        ++index;
    }
    return true;
}
Also used : Individual(org.apache.jena.ontology.Individual) ArrayList(java.util.ArrayList)

Example 42 with Individual

use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.

the class AnimationConstructionServiceImpl method dealCharacters.

public boolean dealCharacters(Individual animationIndividual, BaikePage baikePage) {
    List<String> characters = new ArrayList<String>();
    int index = 0;
    for (String parameterName : baikePage.getParameterNames()) {
        if (parameterName.equals("原作")) {
            characters = Arrays.asList(baikePage.getParameterValues().get(index).split("、"));
            if (characters.size() == 1) {
                characters = Arrays.asList(baikePage.getParameterValues().get(index).split(","));
            }
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "创作", animationIndividual);
                    constructionDAO.addObjectProperty(animationIndividual, "原作", characterIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "有动画", animationIndividual);
                }
            }
        }
        if (parameterName.equals("导演")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "导演", animationIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "执导", animationIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "拍", animationIndividual);
                }
            }
        }
        if (parameterName.equals("剧本")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "写剧本", animationIndividual);
                }
            }
        }
        if (parameterName.equals("角色设计")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "设计角色", animationIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "设计", animationIndividual);
                }
            }
        }
        if (parameterName.equals("作画监督")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "监督作画", animationIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "监督", animationIndividual);
                }
            }
        }
        if (parameterName.equals("音乐")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "创作音乐", animationIndividual);
                    constructionDAO.addObjectProperty(characterIndividual, "创作", animationIndividual);
                }
            }
        }
        if (parameterName.equals("主要配音")) {
            characters = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String character : characters) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (character.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual characterIndividual = this.queryIndividual(character, polysemantExplain, url, true, OntologyClassEnum.CHARACTER);
                    constructionDAO.addObjectProperty(characterIndividual, "配音", animationIndividual);
                }
            }
        }
        ++index;
    }
    return true;
}
Also used : Individual(org.apache.jena.ontology.Individual) ArrayList(java.util.ArrayList)

Example 43 with Individual

use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.

the class AnimationConstructionServiceImpl method dealAreas.

public boolean dealAreas(Individual animationIndividual, BaikePage baikePage) {
    List<String> areas = new ArrayList<String>();
    int index = 0;
    for (String parameterName : baikePage.getParameterNames()) {
        if (parameterName.equals("地区")) {
            areas = Arrays.asList(baikePage.getParameterValues().get(index).split("、"));
            if (areas.size() == 1) {
                areas = Arrays.asList(baikePage.getParameterValues().get(index).split(","));
            }
            for (String area : areas) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (area.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual areaIndividual = this.queryIndividual(area, polysemantExplain, url, true, OntologyClassEnum.AREA);
                    constructionDAO.addObjectProperty(animationIndividual, "属于", areaIndividual);
                }
                // 创建二级类
                OntClass areaClass = constructionDAO.getOntClass(area);
                // 如果本体中此时没有该二级类
                if (areaClass == null) {
                    areaClass = constructionDAO.createOntClass(area);
                }
                // 获取一级类 动画类
                OntClass animationClass = constructionDAO.getOntClass(OntologyClassEnum.ANIMATION.getName());
                // 创建子类(二级类)
                constructionDAO.addSubClass(animationClass, areaClass);
                constructionDAO.addSubClass(animationIndividual, areaClass);
            }
        }
        ++index;
    }
    return false;
}
Also used : Individual(org.apache.jena.ontology.Individual) ArrayList(java.util.ArrayList) OntClass(org.apache.jena.ontology.OntClass)

Example 44 with Individual

use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.

the class AnimationConstructionServiceImpl method construction.

@Override
public boolean construction(BaikePage baikePage) throws Exception {
    // 词条标题(实体名)
    String individualName = baikePage.getLemmaTitle();
    String polysemantExplain = baikePage.getPolysemantExplain();
    String url = baikePage.getUrl();
    Individual animationIndividual = null;
    // 查询词典中是否有该实体 有则查询返回 没有则创建返回  true表示这是本名
    animationIndividual = this.queryIndividual(individualName, polysemantExplain, url, true, OntologyClassEnum.ANIMATION);
    constructionDAO.addObjectProperty(animationIndividual, "是", animationIndividual);
    // 添加数据属性(描述和歧义说明)
    String lemmaSummary = baikePage.getLemmaSummary();
    String picSrc = baikePage.getPicSrc();
    if (picSrc != null) {
        // 取得当前时间
        long times = System.currentTimeMillis();
        // 生成0-1000的随机数
        int random = (int) (Math.random() * 1000);
        // 扩展名称
        String newPicName = times + "" + random + ".jpg";
        PictureDownloader.picDownload(picSrc, newPicName, Config.picSavePath + File.separator + OntologyClassEnum.ANIMATION.getName());
        constructionDAO.addDataProperty(animationIndividual, "picSrc", newPicName);
    }
    constructionDAO.addDataProperty(animationIndividual, "URL信息来源", url);
    constructionDAO.addDataProperty(animationIndividual, "描述", lemmaSummary);
    constructionDAO.addDataProperty(animationIndividual, "歧义说明", polysemantExplain);
    // 添加基本信息
    List<String> parameterNamesFilter = baikePage.getParameterNames();
    List<String> parameterValuesFilter = baikePage.getParameterValues();
    constructionDAO.addDataProperties(animationIndividual, parameterNamesFilter, parameterValuesFilter);
    // 处理动画-公司对象(动画制作公司)
    this.dealCompanys(animationIndividual, baikePage);
    // 处理动画-公司对象(制片公司)
    // this.dealCompanys(animationIndividual, baikePage);
    // 处理动画-地区对象(地区)
    this.dealAreas(animationIndividual, baikePage);
    // 处理动画-人物对象(主演)
    this.dealCharacters(animationIndividual, baikePage);
    return false;
}
Also used : Individual(org.apache.jena.ontology.Individual)

Example 45 with Individual

use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.

the class CaricatureConstructionServiceImpl method dealCompanys.

public boolean dealCompanys(Individual caricatureIndividual, BaikePage baikePage) {
    List<String> companys = new ArrayList<String>();
    int index = 0;
    for (String parameterName : baikePage.getParameterNames()) {
        if (parameterName.equals("连载杂志")) {
            companys = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String company : companys) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (company.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual companyIndividual = this.queryIndividual(company, polysemantExplain, url, true, OntologyClassEnum.COMPANY);
                    constructionDAO.addObjectProperty(caricatureIndividual, "连载在", companyIndividual);
                    constructionDAO.addObjectProperty(companyIndividual, "连载", caricatureIndividual);
                    constructionDAO.addObjectProperty(companyIndividual, "创办", caricatureIndividual);
                }
            }
        }
        if (parameterName.equals("出版社")) {
            companys = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
            for (String company : companys) {
                String url = null;
                int i = 0;
                for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
                    if (company.equals(parameterHasUrlValue)) {
                        url = baikePage.getParameterHasUrl().get(i);
                    }
                    ++i;
                }
                if (url != null) {
                    String polysemantExplain = "待更新";
                    Individual companyIndividual = this.queryIndividual(company, polysemantExplain, url, true, OntologyClassEnum.COMPANY);
                    constructionDAO.addObjectProperty(caricatureIndividual, "出版在", companyIndividual);
                    constructionDAO.addObjectProperty(companyIndividual, "出版", caricatureIndividual);
                }
            }
        }
        ++index;
    }
    return true;
}
Also used : Individual(org.apache.jena.ontology.Individual) ArrayList(java.util.ArrayList)

Aggregations

Individual (org.apache.jena.ontology.Individual)53 ArrayList (java.util.ArrayList)17 OntClass (org.apache.jena.ontology.OntClass)16 Literal (org.apache.jena.rdf.model.Literal)6 OntModel (org.apache.jena.ontology.OntModel)4 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 MediaType (javax.ws.rs.core.MediaType)2 ObjectProperty (org.apache.jena.ontology.ObjectProperty)2 OntResource (org.apache.jena.ontology.OntResource)2 Test (org.junit.Test)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Model (org.apache.jena.rdf.model.Model)1 Resource (org.apache.jena.rdf.model.Resource)1 Address (org.orcid.jaxb.model.message.Address)1 Email (org.orcid.jaxb.model.message.Email)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1