精华内容
下载资源
问答
  • Python中使用Stanford CoreNLP

    万次阅读 热门讨论 2018-05-25 14:25:06
    Stanford CoreNLP的源代码是使用Java写的,提供了Server方式进行交互。stanfordcorenlp是一个对Stanford CoreNLP进行了封装的Python工具包,GitHub地址,使用非常方便。 安装依赖 1:下载安装JDK 1.8及以上版本。 ...

    前言

    Stanford CoreNLP的源代码是使用Java写的,提供了Server方式进行交互。stanfordcorenlp是一个对Stanford CoreNLP进行了封装的Python工具包,GitHub地址,使用非常方便。
    ***************更新**************
    Stanford 官方发布了python版,直接可以安装。具体参见https://stanfordnlp.github.io/stanfordnlp/。
    pip install stanfordnlp

    安装依赖

    1:下载安装JDK 1.8及以上版本。
    2:下载Stanford CoreNLP文件,解压。
    3:处理中文还需要下载中文的模型jar文件,然后放到stanford-corenlp-full-2018-02-27根目录下即可(注意一定要下载这个文件,否则它默认是按英文来处理的)。

    常用接口

    StanfordCoreNLP官网给出了python调用StanfordCoreNLP的接口。


    Python packages using the Stanford CoreNLP server

    These packages use the Stanford CoreNLP server that we’ve developed over the last couple of years. You should probably use one of them.

    • stanfordcorenlp by Lynten Guo. A Python wrapper to Stanford CoreNLP server, version 3.8.0. Also: PyPI page.
    • pycorenlp, A Python wrapper for Stanford CoreNLP by Smitha Milli that uses the new CoreNLP v3.6+ server. Available on PyPI.
    • corenlp-pywrap by Sherin Thomas also uses the new CoreNLP v3.6+ server. Python 3.x (only). Also: PyPI page.
    • Stanford CoreNLP Python Interface: A reference implementation of a Python interface to the Stanford CoreNLP server. By Arun Chaganty. PyPI page.
    • pynlp ,A (Pythonic) Python wrapper for Stanford CoreNLP by Sina. PyPI page.
    • NLTK since version 3.2.3 has a new interface to Stanford CoreNLP using the StanfordCoreNLPServer. Among other places, see instructions on using the dependency parser and the code for this module, and if you poke around the documentation, you can find equivalent interfaces to other CoreNLP components; for example here is Stanford CoreNLP NER. Much of the work for this was done by Dmitrijs Milajevs.

    补充

    Stanford官方发布了Python版的nlp处理工具,不在纠结使用java了。

    Setup

    StanfordNLP supports Python 3.6 or later. We strongly recommend that you install StanfordNLP from PyPI. If you already have pip installed, simply run

    pip install stanfordnlp
    

    this should also help resolve all of the dependencies of StanfordNLP, for instance PyTorch 1.0.0 or above.
    Alternatively, you can also install from source of this git repository, which will give you more flexibility in developing on top of StanfordNLP and training your own models. For this option, run

    git clone git@github.com:stanfordnlp/stanfordnlp.git
    cd stanfordnlp
    pip install -e .
    
    Running StanfordNLP

    Getting Started with the neural pipeline
    To run your first StanfordNLP pipeline, simply following these steps in your Python interactive interpreter:

    >>> import stanfordnlp
    >>> stanfordnlp.download('en')   # This downloads the English models for the neural pipeline
    >>> nlp = stanfordnlp.Pipeline() # This sets up a default neural pipeline in English
    >>> doc = nlp("Barack Obama was born in Hawaii.  He was elected president in 2008.")
    >>> doc.sentences[0].print_dependencies()
    

    The last command will print out the words in the first sentence in the input string (or Document, as it is represented in StanfordNLP), as well as the indices for the word that governs it in the Universal Dependencies parse of that sentence (its “head”), along with the dependency relation between the words. The output should look like:

    ('Barack', '4', 'nsubj:pass')
    ('Obama', '1', 'flat')
    ('was', '4', 'aux:pass')
    ('born', '0', 'root')
    ('in', '6', 'case')
    ('Hawaii', '4', 'obl')
    ('.', '4', 'punct')
    

    Note: If you are running into issues like OSError: [Errno 22] Invalid argument, it’s very likely that you are affected by a known Python issue, and we would recommend Python 3.6.8 or later and Python 3.7.2 or later.

    We also provide a multilingual demo script that demonstrates how one uses StanfordNLP in other languages than English, for example Chinese (traditional)

    python demo/pipeline_demo.py -l zh
    

    See our getting started guide for more details.


    另外stanfordcorenlp使用教程

    本教程以stanfordcorenlp接口为例(本文所用版本为Stanford CoreNLP 3.9.1),讲解Python调用StanfordCoreNLP的使用方法。

    1.使用pip安装stanfordcorenlp:

    简单使用命令:pip install stanfordcorenlp
    选择USTC镜像安装(安装速度很快,毕竟国内镜像):pip install stanfordcorenlp -i http://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host pypi.mirrors.ustc.edu.cn

    2.在Python环境下调用stanfordcorenlp:

    Simple usage
    from stanfordcorenlp import StanfordCoreNLP
    
    nlp = StanfordCoreNLP(r'G:\JavaLibraries\stanford-corenlp-full-2018-02-27')
    
    sentence = 'Guangdong University of Foreign Studies is located in Guangzhou.'
    print 'Tokenize:', nlp.word_tokenize(sentence)
    print 'Part of Speech:', nlp.pos_tag(sentence)
    print 'Named Entities:', nlp.ner(sentence)
    print 'Constituency Parsing:', nlp.parse(sentence)
    print 'Dependency Parsing:', nlp.dependency_parse(sentence)
    
    nlp.close() # Do not forget to close! The backend server will consume a lot memery.
    

    Output format:

    # Tokenize
    [u'Guangdong', u'University', u'of', u'Foreign', u'Studies', u'is', u'located', u'in', u'Guangzhou', u'.']
    
    #Part of Speech
    
    [(u'Guangdong', u'NNP'), (u'University', u'NNP'), (u'of', u'IN'), (u'Foreign', u'NNP'), (u'Studies', u'NNPS'), (u'is', u'VBZ'), (u'located', u'JJ'), (u'in', u'IN'), (u'Guangzhou', u'NNP'), (u'.', u'.')]
    
    # Named Entities
     [(u'Guangdong', u'ORGANIZATION'), (u'University', u'ORGANIZATION'), (u'of', u'ORGANIZATION'), (u'Foreign', u'ORGANIZATION'), (u'Studies', u'ORGANIZATION'), (u'is', u'O'), (u'located', u'O'), (u'in', u'O'), (u'Guangzhou', u'LOCATION'), (u'.', u'O')]
    
    # Constituency Parsing
     (ROOT
      (S
        (NP
          (NP (NNP Guangdong) (NNP University))
          (PP (IN of)
            (NP (NNP Foreign) (NNPS Studies))))
        (VP (VBZ is)
          (ADJP (JJ located)
            (PP (IN in)
              (NP (NNP Guangzhou)))))
        (. .)))
    
    #Dependency Parsing
    [(u'ROOT', 0, 7), (u'compound', 2, 1), (u'nsubjpass', 7, 2), (u'case', 5, 3), (u'compound', 5, 4), (u'nmod', 2, 5), (u'auxpass', 7, 6), (u'case', 9, 8), (u'nmod', 7, 9), (u'punct', 7, 10)]
    

    Other Human Languages Support

    Note: you must download an additional model file and place it in the …/stanford-corenlp-full-2018-02-27 folder. For example, you should download the stanford-chinese-corenlp-2018-02-27-models.jar file if you want to process Chinese.

    # _*_coding:utf-8_*_
    
    # Other human languages support, e.g. Chinese
    
    sentence = '清华大学位于北京。'
    
    with StanfordCoreNLP(r'G:\JavaLibraries\stanford-corenlp-full-2018-02-27', lang='zh') as nlp:
        print(nlp.word_tokenize(sentence))
        print(nlp.pos_tag(sentence))
        print(nlp.ner(sentence))
        print(nlp.parse(sentence))
        print(nlp.dependency_parse(sentence))
    
    

    General Stanford CoreNLP API

    Since this will load all the models which require more memory, initialize the server with more memory. 8GB is recommended.

    #General json output
    nlp = StanfordCoreNLP(r'path_to_corenlp', memory='8g')
    print nlp.annotate(sentence)
    nlp.close()
    

    You can specify properties:

    annotators: tokenize, ssplit, pos, lemma, ner, parse, depparse, dcoref (See Detail)
    
    pipelineLanguage: en, zh, ar, fr, de, es (English, Chinese, Arabic, French, German, Spanish) (See Annotator Support Detail)
    
    outputFormat: json, xml, text
    
    text = 'Guangdong University of Foreign Studies is located in Guangzhou. ' \
           'GDUFS is active in a full range of international cooperation and exchanges in education. '
    
    props={'annotators': 'tokenize,ssplit,pos','pipelineLanguage':'en','outputFormat':'xml'}
    print nlp.annotate(text, properties=props)
    nlp.close()
    

    Use an Existing Server

    Start a CoreNLP Server with command:

    java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
    And then:
    
    # Use an existing server
    nlp = StanfordCoreNLP('http://localhost', port=9000)
    

    Debug

    import logging
    from stanfordcorenlp import StanfordCoreNLP
    
    # Debug the wrapper
    nlp = StanfordCoreNLP(r'path_or_host', logging_level=logging.DEBUG)
    
    # Check more info from the CoreNLP Server 
    nlp = StanfordCoreNLP(r'path_or_host', quiet=False, logging_level=logging.DEBUG)
    nlp.close()
    

    Build

    We use setuptools to package our project. You can build from the latest source code with the following command:

    • $ python setup.py bdist_wheel --universal
      You will see the .whl file under dist directory.
    展开全文
  • Stanford.NLP.NET:.NET的Stanford NLP
  • stanford dataset

    2020-12-29 13:36:12
    <div><p>Hi, I want to know if you also have the stanford dataset as per the required format for training and testing the model? I have access to the training <a href="http://trajnet.stanford.edu/data....
  • Stanford tregex

    2014-06-22 22:10:34
    stanford tregex 与stanford parser 结合分析做语言处理用
  • Stanford parser

    2016-07-14 18:55:15
    Stanford parser 句法分析器及可视化.如何使用。首先你的电脑需要安装jdk。
  • Chatbot-StanfordNLP 基于StanfordNLP的聊天机器人
  • StanfordPaRser

    2011-10-21 13:58:13
    StanfordPaRser
  • stanfordcs224

    2018-09-29 16:25:50
    stanfordcs224, 想学的同学赶紧来啊,自然语言处理应用仅有
  • stanford machine learning
  • stanford106AAssignments
  • stanford-postagger

    2018-07-31 11:32:17
    stanford-postagger-2018-02-27 官方地址下载,保证来源无病毒。
  • Stanford.NLP.Fsharp:The Stanford.NLP.NET的F#扩展
  • Stanford NLP

    2019-10-29 23:19:58
    Stanford NLP提供了一系列自然语言分析工具。它能够给出基本的 词形,词性,不管是公司名还是人名等,格式化的日期,时间,量词, 并且能够标记句子的结构,语法形式和字词依赖,指明那些名字指向同 样的实体,指明...

    参考:

    • http://www.pianshen.com/article/8433287443/
    • http://nlp.stanford.edu:8080/corenlp/

    Stanford NLP提供了一系列自然语言分析工具。
    它能够给出基本的 词形,词性,不管是公司名还是人名等,格式化的日期,时间,量词, 并且能够标记句子的结构,语法形式和字词依赖,指明那些名字指向同 样的实体,指明情绪,提取发言中的开放关系等。

    1. 一个集成的语言分析工具集;
    2. 进行快速,可靠的任意文本分析;
    3. 整体的高质量的文本分析;
    4. 支持多种主流语言;
    5. 多种编程语言的易用接口;
    6. 方便的简单的部署web服务。

    Stanford NLP安装

    Python 版本stanford nlp 安装
    建议虚拟环境
    • 1)安装stanford nlp自然语言处理包: pip install stanfordcorenlp
    • 2)下载Stanford CoreNLP文件
    https://stanfordnlp.github.io/CoreNLP/download.html
    • 3)下载中文模型jar包, 
    http://nlp.stanford.edu/software/stanford-chinese-corenlp-2018-02-27-models.jar,4)把下载的stanford-chinese-corenlp-2018-02-27-models.jar
    放在解压后的Stanford CoreNLP文件夹中,改Stanford CoreNLP文件夹名为stanfordnlp(可选)
    • 5)在Python中引用模型:
    • from stanfordcorenlp import StanfordCoreNLP
    • nlp = StanfordCoreNLP(r‘path', lang='zh')
    例如:
    nlp = StanfordCoreNLP(r'D:\stanfordnlp', lang='zh')
    

    配置Java jdk环境

    那个jar包1g,不翻墙的下不了的,毛利我真好人,

    翻墙帮你下了

    链接:https://pan.baidu.com/s/1ujAZlHq-yeuEU1YLLMk6cA
    提取码:440e
    复制这段内容后打开百度网盘手机App,操作更方便哦

    测试Stanford NLP

    '''
    @author:毛利
    参考: http://www.pianshen.com/article/8433287443/
    '''
    
    from stanfordcorenlp import StanfordCoreNLP 
    
    nlp = StanfordCoreNLP(r'D:\stanfordnlp', lang='zh')
    
    sentence = '毛利是大帅比,真他妈不要脸'
    
    # 分词
    print(nlp.word_tokenize(sentence))
    # 单词成分
    print(nlp.pos_tag(sentence))
    # 命名实体识别
    print(nlp.ner(sentence))
    # 句法分析
    print(nlp.parse(sentence))
    print(nlp.dependency_parse(sentence))
    
    
    '''
    ['毛利', '是', '大帅', '比', ',', '真', '他妈', '不要脸']
    [('毛利', 'NR'), ('是', 'VC'), ('大帅', 'NN'), ('比', 'P'), (',', 'PU'), ('真', 'AD'), ('他妈', 'AD'), ('不要脸', 'VA')]
    [('毛利', 'PERSON'), ('是', 'O'), ('大帅', 'O'), ('比', 'O'), (',', 'O'), ('真', 'O'), ('他妈', 'O'), ('不要脸', 'O')]
    (ROOT
      (IP
        (NP (NR 毛利))
        (VP (VC 是)
          (IP
            (NP (NN 大帅))
            (DFL (P 比))
            (PU ,)
            (VP
              (ADVP (AD 真))
              (ADVP (AD 他妈))
              (VP (VA 不要脸)))))))
    [('ROOT', 0, 4), ('nsubj', 4, 1), ('cop', 4, 2), ('nsubj', 4, 3), ('punct', 4, 5), ('advmod', 8, 6), ('advmod', 8, 7), ('conj', 4, 8)]
    '''
    
    展开全文
  • 斯坦福大学 stanfordcorenlp是的Python包装器。 它提供了用于文本处理任务的简单API,例如令牌化,语音标记,命名实体重新命名,选区解析,依赖项解析...nlp = StanfordCoreNLP ( r'G:\JavaLibraries\stanford-corenl
  • Stanford下载

    2018-11-15 16:57:42
    Stanford下载下载地址请到官网选择要下载的版本 下载地址请到官网 https://nlp.stanford.edu/software/segmenter.shtml 选择要下载的版本 下拉到底下选择需要下载的版本,点击下载即可 ...

    下载地址请到官网

    https://nlp.stanford.edu/software/segmenter.shtml

    选择要下载的版本

    下拉到底下选择需要下载的版本,点击下载即可
    如图

    展开全文
  • Stanford_rabbit.zip

    2021-02-23 12:02:28
    Stanford_rabbit.zip
  • Stanford STATS 202

    2018-10-06 01:53:31
    Stanford STATS 202 课本 Statistical learning refers to a set of tools for modeling and understanding complex datasets. It is a recently developed area in statistics and blends with parallel ...
  • stanford bunny

    2011-03-14 06:16:18
    用vc 2008写的stanford bunny
  • Algo_stanford 该存储库包含Python中的实现。 课程1:分而治之,排序和搜索以及随机算法 分而治之算法 随机算法 课程2:图搜索,最短路径和数据结构 图搜索和最短路径 数据结构 课程3:贪婪算法,最小生成树和动态...
  • stanford标本

    2019-10-05 23:07:46
    stanford标本 无双科技CEO施侃:想做网红没有捷径_国内_新京报网 posted on 2016-06-02 07:07lexus 阅读(...) 评...

    无双科技CEO施侃:想做网红没有捷径_国内_新京报网

    posted on 2016-06-02 07:07 lexus 阅读(...) 评论(...) 编辑 收藏

    转载于:https://www.cnblogs.com/lexus/p/5551707.html

    展开全文
  • steve jobs stanford speech

    2018-11-08 19:33:25
    steve jobs stanford speech Steve Jobs, CEO of Apple Computer and Pixar addresses the Stanford University graduating class of 2005 at commencement exercises in June.
  • stanford noc RTL

    2016-06-06 20:47:06
    Stanford noc的RTL级代码,对应其booksim2
  • stanfordnlp

    2019-04-29 10:50:55
    from stanfordcorenlp import ...nlp = StanfordCoreNLP(r'/home/lhq/PycharmProjects/untitled/stanfordnlp',lang='zh') fin = open('new.txt','r',encoding='utf8') fner = open('ner.txt','w',enco...
  • Stanford EE214 Lecture 1

    2018-10-12 22:18:39
    stanford online course Stanford EE214 Lecture 1
  • Stanford Dragon Model

    2016-04-06 16:03:15
    Stanford Dragon Model 包括max,ase,dwf,mtl,obj五种格式
  • Stanford OpenIE的Python3包装器 开放信息提取(open IE)指的是从纯文本中提取结构化关系三元组,因此不需要预先指定这些关系的模式。 例如,巴拉克·奥巴马(Barack Obama)出生于夏威夷会创建一个三元组(Barack ...
  • Revised for the Stanford Parser v. 3.7.0 in September 2016 Stanford parser的类型依赖说明
  • 斯坦福汽车 使用Stanford Cars数据集对汽车进行Model Year识别 精度:92.5%精度:92.8%召回率:92.5%f1:92.5%
  • Stanford cs468 课件

    2018-10-19 10:57:52
    斯坦福 stanford CS468 : Machine Learning for 3D Data课件,第一部分。
  • linux 下的Stanford词性标注java -mx1g -cp "/home/hadoop/stanford-corenlp-full-2017-06-09/stanford-postagger.jar:" edu.stanford.nlp.tagger.maxent.MaxentTagger -model "/home/hadoop/stanford-corenlp-full-...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 11,266
精华内容 4,506
关键字:

stanford