示例#1
0
  private MajorModel getMajorModel(String major) {
    for (MajorModel model : majors.get("one")) {
      if (major.equals(model.getValue())) {
        return model;
      }
    }

    for (MajorModel model : majors.get("two")) {
      if (major.equals(model.getValue())) {
        return model;
      }
    }
    return null;
  }
示例#2
0
  // step1
  // 计算各个分类的Jd数
  public void handler() {
    ClassLoader classLoader = (new Chi()).getClass().getClassLoader();
    InputStream stream = classLoader.getResourceAsStream(SRC_JD);
    Scanner scanner = new Scanner(stream);

    String line = null;
    String jdLine = null;
    String[] arr = null;
    Set<String> words = null;
    Set<String> jdWords = null;
    Set<String> jds = null;
    String jd = null;
    boolean next = false;
    MajorModel model = null;
    Splitter splitter = Splitter.on(" ").omitEmptyStrings().trimResults();
    while (scanner.hasNextLine()) {
      line = scanner.nextLine();
      if (line == null || line.trim().equals("")) {
        continue;
      }

      if (line.startsWith("jobid:")) {
        jdLine = line;

      } else if (line.startsWith("majorcalssify:")) {
        arr = line.split(":")[1].split(",");
        jd = jdLine.split(" ")[1];
        jdWords = new HashSet<String>();
        jd_words.put(jd, jdWords);

        for (String m : arr) {
          model = getMajorModel(m);
          if (model != null) { // 对专业进行验证,确保专业存在
            next = true;
            if (major_words.containsKey(model.getId())) {
              words = major_words.get(model.getId());
            } else {
              words = new HashSet<String>();
              if (model.isMain()) {
                major_words.put(model.getId(), words);
              } else {
                major_words.put(model.getParent().getId(), words);
              }
            }

            if (major_jds.containsKey(model.getId())) {
              jds = major_jds.get(model.getId());
            } else {
              jds = new HashSet<String>();
              if (model.isMain()) {
                major_jds.put(model.getId(), jds);
              } else {
                major_jds.put(model.getParent().getId(), jds);
              }
            }
            jds.add(jd); // get job id

          } else {
            next = false;
          }
        }
      } else if (line.startsWith("corp:")) {
        // ignore
        // } else if (line.startsWith("title:")) {
        // ignore
      } else {
        if (next) {
          for (String word : splitter.split(line)) {
            words.add(word);
            jdWords.add(word);
          }
          jdWords.remove("intro:");
          jdWords.remove("title:");
          words.remove("intro:");
          words.remove("title:");
        }
      }
    }
  }