简体   繁体   中英

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. ie Take into consideration a String object of someone's work information

{
Stark Industries
CEO and Founder
Tony Stark
111-222-1234
tonystark@avengers.com
}

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM