0
$\begingroup$

I have to write an algorithm that solves below problem statement -

  1. There is a project requirement which has list of titles:- "JobTitles" : [ "Developer", "Programmer", "Java Developer",
    "Java Software Engineer", "Java Software Developer", "Application Architect", ]
  2. There is a list of applicants who have titles like -

enter image description here

Need to find out which applicant is close to the project requirement based on scoring system.

Current logic that I have implemented is(pseudocode)-

If project_title.eqauls(applicant.split(,).forEach(title)) applicant.score +=4

If project_title.contains(applicant.split(,).forEach(title)) applicant.score +=2

Is there any other method to implement scoring system to find closest possible match based on the keywords of requirement and applicant job title?

Thank you!

$\endgroup$
3
  • $\begingroup$ Welcome to Computer Science! We discourage posts that simply state a problem out of context, and expect the community to solve it. Assuming you tried to solve it yourself and got stuck, it may be helpful if you wrote your thoughts and what you could not figure out. It will definitely draw more answers to your post. Until then, the question will be voted to be closed / downvoted. You may also want to check out these hints, or use the search engine of this site to find similar questions that were already answered. $\endgroup$
    – Raphael
    Apr 23, 2020 at 21:33
  • $\begingroup$ Hi @Raphael , I have updated the description. $\endgroup$ Apr 23, 2020 at 23:48
  • $\begingroup$ Seems like a programming question. Assuming your database is small (can't imagine you having even a thousand applicants), it's not worth it to implement any fancy algorithm. $\endgroup$ Apr 24, 2020 at 6:52

1 Answer 1

1
$\begingroup$

I would go with the following program to achieve what you're looking for:

import java.util.*;

class Applicant {
    public String name = "";
    public List<String> titles = new ArrayList<>();
    public Applicant(String name, String... titles) {
        this.name = name;
        this.titles = Arrays.asList(titles);
    }
}

class Matcher {
    private Applicant ideal;
    
    public Matcher(Applicant ideal) {
        this.ideal = ideal;
    }
    
    private class ApplicantComparator implements Comparator<Applicant> {
        @Override
        public int compare(Applicant a, Applicant b) {
            int x = 0, y = 0;
            for(String t : a.titles) {
                if(ideal.titles.contains(t)) x += 1;    
            }
            for(String t : b.titles) {
                if(ideal.titles.contains(t)) y += 1;   
            }
            return x - y;
        }
    }
    
    public void best(Applicant... applicants) {
        if(this.ideal == null) return;
        Collections.sort(Arrays.asList(applicants), new ApplicantComparator());
        int i = 1;
        System.out.println("Ideal applicant titles: " + ideal.titles.toString().substring(1, ideal.titles.toString().length() - 1));
        System.out.println("\nMost suited in list\n|");
        for(Applicant a : applicants) {
            System.out.println("| " + (i++) + " - " + String.format("%-24s", a.name) + a.titles.toString().substring(1, a.titles.toString().length() - 1));
        }
        System.out.println("|\nLeast suited in list");
    }
}

public class Main {
    public static void main(String[] args) {
        Matcher m = new Matcher(new Applicant("<IDEAL>", "Developer", "Programmer", "Java Developer", "Java Software Engineer", "Java Software Developer", "Application Architect"));
        m.best(
            new Applicant("Shawn", "Java Developer", "Software Developer", "Java Programmer")
            , new Applicant("John", "Application Architect", "Java Programmer", ".NET Developer")
            , new Applicant("Richard", "Software Developer", "Java Programmer")
        );
    }
}

Output:

Ideal applicant titles: Developer, Programmer, Java Developer, Java Software Engineer, Java Software Developer, Application Architect

Most suited in list
|
| 1 - Richard         Software Developer, Java Programmer
| 2 - Shawn           Java Developer, Software Developer, Java Programmer
| 3 - John            Application Architect, Java Programmer, .NET Developer
|
Least suited in list
```
$\endgroup$
1
  • $\begingroup$ We're not a coding site, and we're not looking for answers that consist solely of code. Instead, we're looking for ideas, explanation, and algorithms. Not everyone here knows Java. I encourage you to get rid of the source code and replace it with ideas, pseudo code and arguments of correctness. See here and here for related meta discussions. $\endgroup$
    – D.W.
    Aug 14 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.