danipa
danipa

Reputation: 37

Parsing String Object for Name (Java)

I'm looking for the best way to take a block of string and parse the information for specifically a name in the object. i.e. Take into consideration a String object of someone's work information

{
Stark Industries
CEO and Founder
Tony Stark
111-222-1234
[email protected]
}

Is it possible to create a method findName() that can distinguish the String Tony Stark as the name from the rest of the object contents like Stark Industries such that the return String is just: Name: Tony Stark?

I know something like getNumber or email would use regex, but I was unsure of the best way to find the name given the object.

Thanks!

Upvotes: 1

Views: 95

Answers (1)

rzwitserloot
rzwitserloot

Reputation: 102832

Try to answer this question:

How would the tool know that the name is Tony Stark and not Founder Tony Stark? There are a lot more questions but even if you work your way around most of them by trying to identify the email and phone number and going off the end, you're still stuck on that.

You can try to write code to specifically go, well, okay words like 'Founder' or 'Chief' or 'Chairman of the Board' don't count, but you're now writing a tool that tries to analyse the english language like a human does. You're effectively writing software that is as smart as you are to pick 'Tony Stark' from that mess, which involves encoding a metric tonne of life experience (such as the experience that Founder is a description of a role and unlikely to be someone's name, and probably that Tony Stark is a very familiar name from pop culture). So, AI then, many man years and lots of research.

TL;DR: Not possible.

Upvotes: 1

Related Questions