【问题标题】:Is there a way matching two profiles based on the profile data有没有办法根据配置文件数据匹配两个配置文件
【发布时间】:2014-10-30 06:27:12
【问题描述】:

我需要测量两个配置文件之间的相似性,我们将在其中对它们进行文字描述。现在使用配置文件数据,我需要找到它们之间的相似性。你能给我一个方法吗。?

【问题讨论】:

    标签: nlp artificial-intelligence opennlp


    【解决方案1】:

    您可以对此问题进行文献综述,将问题分解为子问题,或根据您对问题的看法应用现有解决方案。例如,如果您将此问题视为文本聚类的应用,则可以应用现有的句子相似性度量。

    关键字匹配似乎是最简单的解决方案。此基线只需要您识别命名实体并计算匹配项。您可以在此过程中进行一些术语加权。

    解决方案的复杂性取决于文本的结构(个人资料更像 LinkedIn 个人资料还是简历?)和误报的可能性(姓名和出生日期是否始终存在,是否足以确定相似性? )。您没有提供示例供我们查看。

    【讨论】:

      【解决方案2】:

      OpenNLP 中并没有真正的实用程序。我建议你先采取一种简单的方法,然后从那里开始工作。我推荐的简单方法是对每个配置文件描述进行矢量化,然后使用标准相似度度量来比较它们。这是使用余弦相似度的示例。您可能会遇到的下一个问题是尝试将它们相互比较……然后您将进入需要进行聚类的领域。您还应该考虑去除噪音和停用词,并可能会产生更好的标记。这个例子只是一个例子,你要做的最重要的决定是添加什么到你的向量中。

      import java.util.HashSet;
      import java.util.Set;
      import java.util.SortedMap;
      import java.util.TreeMap;
      
      /**
       *
       * Crudely compares two strings
       */
      public class SimpleProfileComparer {
      
        public static void main(String[] args) {
          String[] profileA = "bob likes to ride bikes and hiking".split(" ");
          String[] profileB = "jim likes bikes and also enjoys hiking".split(" ");;
          SortedMap<String, Double> a = new TreeMap<>();
          for (String string : profileA) {
            a.put(string, 1d);
          }
          SortedMap<String, Double> b = new TreeMap<>();
          for (String string : profileB) {
            b.put(string, 1d);
          }
          Set<String>keys = new HashSet<>();
          keys.addAll(a.keySet());
          keys.addAll(b.keySet());
          for (String string : keys) {
            if(!a.containsKey(string)){
              a.put(string, 0d);
            }
            if(!b.containsKey(string)){
              b.put(string, 0d);
            }
          }
          Double compare = compare(a, b);
          System.out.println(compare);
        }
      
        public static Double compare(SortedMap<String, Double> a, SortedMap<String, Double> b) {
          //both vectors must be of the same schema (normed prior to this call)
          if (a.keySet().size() != b.keySet().size()) {
            throw new IllegalArgumentException("vectors must be the same length");
          }
          double magA = 0;
          double magB = 0;
          double dotProd = 0;
          for (String key : a.keySet()) {
            Double intA = a.get(key);
            Double intB = b.get(key);
            /*
             * sum of squares calcs
             */
            magA += intA * intA;
            magB += intB * intB;
            /**
             * dot prod calc
             */
            dotProd += intA * intB;
          }
          magA = Math.sqrt(magA);
          magB = Math.sqrt(magB);
          Double similarity = dotProd / (magA * magB);
          return similarity;
      
        }
      
      }
      

      【讨论】:

        猜你喜欢
        • 2020-09-22
        • 2015-09-10
        • 2019-05-04
        • 2021-03-16
        • 1970-01-01
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多