小编Rob*_*der的帖子

如何在 Poetry 托管环境中下载 spaCy 模型

我正在编写一个 Python Jupyter 笔记本,它对意大利语文本进行一些 NLP 处理。

我已经通过 Poetry 安装了 spaCy 3.5.3,然后尝试运行以下代码:

import spacy
load_model = spacy.load('it_core_news_sm')
Run Code Online (Sandbox Code Playgroud)

import行按预期工作,但运行spacy.load会产生以下错误:

OSError:[E050]找不到模型“it_core_news_sm”。它似乎不是 Python 包或数据目录的有效路径。模型名称正确,如https://spacy.io/models/it所示

经过网络搜索,我发现解决方案是发出以下命令:

python3 -m spacy download it_core_news_sm
Run Code Online (Sandbox Code Playgroud)

运行此命令后,上面的代码按预期工作,但是,是否有更“犹太”的方式通过 Poetry 来执行此操作?

python nlp spacy virtual-environment python-poetry

5
推荐指数
1
解决办法
2068
查看次数

Github Actions:关于 set-output 的警告,但不使用它

我正在使用 GitHub 操作“构建”Python 应用程序(运行 linting、代码覆盖率和测试)。在操作结束时,我收到以下警告:

1 warning
build
The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Run Code Online (Sandbox Code Playgroud)

但我的python-app.yml不使用 set-output:

name: Python application

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Check out
      uses: actions/checkout@v3

    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: "3.10"

    - name: Install dependencies
      run: |
        python -m …
Run Code Online (Sandbox Code Playgroud)

github github-actions

4
推荐指数
1
解决办法
1618
查看次数

Python:如何将列表列表的元素转换为无向图?

我有一个程序可以检索PubMed出版物的列表,并希望建立共同作者的图表,这意味着我想为每篇文章添加每位作者(如果尚不存在)作为顶点并添加无向边(或增加)它的权重)。

我设法编写了该程序的第一个程序,该程序检索了每个出版物的作者列表,并且了解我可以使用NetworkX库来构建图形(然后将其导出到GraphML for Gephi),但是无法全神贯注于如何转换图形。 “列表列表”到图形。

这是我的代码。非常感谢你。

### if needed install the required modules
### python3 -m pip install biopython
### python3 -m pip install numpy

from Bio import Entrez
from Bio import Medline
Entrez.email = "rja@it.com"
handle = Entrez.esearch(db="pubmed", term='("lung diseases, interstitial"[MeSH Terms] NOT "pneumoconiosis"[MeSH Terms]) AND "artificial intelligence"[MeSH Terms] AND "humans"[MeSH Terms]', retmax="1000", sort="relevance", retmode="xml")
records = Entrez.read(handle)
ids = records['IdList']
h = Entrez.efetch(db='pubmed', id=ids, rettype='medline', retmode='text')
#now h holds all of the articles and their sections
records = …
Run Code Online (Sandbox Code Playgroud)

python graph-theory networkx gephi

2
推荐指数
1
解决办法
415
查看次数