简体   繁体   English

解析名称的字符串对象(Java)

[英]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即考虑某人工作信息的 String 对象

{
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 ?是否有可能创建一个方法findName()可以将字符串Tony Stark作为名称与其他对象内容(如Stark Industries findName()区分开来,这样返回的字符串就是: 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.我知道 getNumber 或 email 之类的东西会使用正则表达式,但我不确定找到给定对象名称的最佳方法。

Thanks!谢谢!

Try to answer this question:试着回答这个问题:

How would the tool know that the name is Tony Stark and not Founder Tony Stark ?该工具如何知道名字是Tony Stark而不是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. TL;DR:不可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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