V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
python30
V2EX  ›  Python

django 结巴分词,和现有的 tag 取交集后得出来的词怎么添加到文章的 tags 里?

  •  
  •   python30 · 2019-08-24 15:55:05 +08:00 · 1543 次点击
    这是一个创建于 1678 天前的主题,其中的信息可能已经有所发展或是发生改变。



    问题主要在这里,pctaglist 是在后台添加的 标签 tags,
    用 jieba 分词分析文章内容后得出来的词与这个后台添加的标签取交集。如果有就添加到这个文章的标签里!
    这里不知道怎么在这里添加,
    用 t.tags.add(word) 出错:'decimal' codec can't encode characters in position 0-1: invalid decimal Unicode string 我也觉得这里这样操作有问题.但是一时不知道怎么改.知识不够....

    要想实现 结巴分词,和现有的 tag 取交集后得出来的词怎么添加到文章的 tags 里?
    或者有其它的好办法实现这一步?

    谢谢~
    2 条回复    2019-08-25 03:23:15 +08:00
    python30
        1
    python30  
    OP
       2019-08-24 19:58:19 +08:00
    这里贴代码不方便
    有空的朋友可以看看这贴里详细说明:
    https://segmentfault.com/q/1010000020173427
    指导一下。谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5415 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:47 · PVG 16:47 · LAX 01:47 · JFK 04:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.