【问题标题】:Date -> Concept/Word Association in Paragraph. JAVA日期 -> 段落中的概念/单词关联。 JAVA
【发布时间】:2018-08-02 15:50:59
【问题描述】:

我正在调用一项服务来分析段落并突出显示我以这种格式提供的概念/单词

{
"paragraph": "My dog got sick on 12/13/2010. Then he died on 01/13/2011."
"concept":[
    {
    "start": "6",
    "end": "9",
    "word": "sick"
    },
    {
    "start": "35",
    "end": "38",
    "word": "died"
    }]
}

将日期与单词/概念联系起来的最佳方式是什么?

我尝试过解析句子并使用正则表达式,它取得了一些成功,但对于更复杂的段落和句子结构,它失败了。

如果有人有建议或推荐某种类型的 NLP 框架,将不胜感激。

我的最终结果可能是这样的示例:

    {
"paragraph": "My dog got sick on 12/13/2010. Then he died on 01/13/2011."
"concept":[
    {
    "start": "6",
    "end": "9",
    "word": "sick",
    "date" 12/13/2010"
    },
    {
    "start": "35",
    "end": "38",
    "word": "died",
    "date" 01/13/2011"
    }]
}

我正在使用 STS、JAVA 8、Spring 框架

【问题讨论】:

    标签: java regex spring parsing nlp


    【解决方案1】:

    自然语言处理 (NLP) 框架的选择取决于各种标准,例如问题领域、应用程序类型、您想要执行的流程、性能、选择的语言、您希望如何使用 NLP 软件 - 作为一个库,独立工具或完整系统等等。

    您应该建立一个标准列表,以帮助您最好地为您的场景确定语言处理工具。

    这些是一些广泛使用的 Java NLP 软件:

    1. Apache OpenNLP(库)
    2. Stanford CoreNLP(完整系统)
    3. UMASS 槌(包)
    4. Natty(日期解析器)

    如果您专门寻找自然语言日期解析器,您可以使用 Natty。

    import com.joestelmach.natty.*;
    
    Parser parser = new Parser();
    List groups = parser.parse("the day before next thursday");
    
    for(DateGroup group:groups) {
       List dates = group.getDates();
       int line = group.getLine();
       int column = group.getPosition();
       String matchingValue = group.getText();
       String syntaxTree = group.getSyntaxTree().toStringTree();
       Map> parseMap = group.getParseLocations();
       boolean isRecurreing = group.isRecurring();
       Date recursUntil = group.getRecursUntil();
    }
    

    代码来源:Natty

    其他有用的链接:

    1. Natural Language date and time parser for java

    2. Algorithm to detect time, date and place from invitation text

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多