Package kpi.asoiu.model.test

Examples of kpi.asoiu.model.test.ArticleEntity


        System.out.println("\n Frequency : " + calculateSubjectFrequency());
    }

    private void saveArticle() {
        ArticleEntity article = new ArticleEntity();
        StringBuffer text = new StringBuffer();
        for (Sentence sentence : sentences) {
            text.append(sentence.getText());
        }
        article.setText(text.toString());
        SimpleDAO simpleDAO = DAOFactory.getDao();
        article.setId(simpleDAO.addObjects(article));
        Map<String, SubjectsEntity> subjectsEntityMap = new HashMap<String, SubjectsEntity>();
        Map<String, Double> subjectsMap = calculateSubjectFrequency();
        for (String word : subjectsMap.keySet()) {
            SubjectsEntity subjectsEntity = new SubjectsEntity();
            subjectsEntity.setFreq(subjectsMap.get(word).floatValue());
            subjectsEntity.setWord(word);
            subjectsEntity.setArticle(article);
            subjectsEntityMap.put(word, subjectsEntity);
            subjectsEntity.setId(simpleDAO.addObjects(subjectsEntity));
        }

        article.setSubjects(new ArrayList<SubjectsEntity>(subjectsEntityMap.values()));
        List<TripletEntity> tripletEntities = new ArrayList<TripletEntity>();
        for (Triplet triplet : tree.keySet()) {
            TripletEntity tripletEntity = createEntityFromTriplet(triplet, subjectsEntityMap);
            tripletEntities.add(tripletEntity);
            tripletEntities.addAll(treeToList(tripletEntity, tree.get(triplet), subjectsEntityMap));
        }
        for (TripletEntity tripletEntity : tripletEntities) {
            tripletEntity.setId(simpleDAO.addObjects(tripletEntity));
        }
        article.setTriplets(tripletEntities);
        simpleDAO.updateObject(article);
    }
View Full Code Here

TOP

Related Classes of kpi.asoiu.model.test.ArticleEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.