hangar115/hashtagger

此包已被弃用且不再维护。未建议替代包。

根据内容自动添加文章标题的标签,ampersa/hashtagger 的分支

0.4 2017-03-20 08:46 UTC

This package is not auto-updated.

Last update: 2023-09-29 02:13:44 UTC


README

根据内容自动添加文章标题的标签

受以下启发 https://gist.github.com/shlomibabluki/6612871

安装

通过 composer 进行安装

composer require ampersa/hashtagger

使用方法

基本使用

$title = 'An article about PHP and hashtags';
$content = 'PHP is a server-side scripting language designed primarily for web development but also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994,[4] the PHP reference implementation is now produced by The PHP Development Team.[5] PHP originally stood for Personal Home Page,[4] but it now stands for the recursive acronym PHP: Hypertext Preprocessor.[6]

A hashtag is a type of label or metadata tag used on social network and microblogging services which makes it easier for users to find messages with a specific theme or content. Users create and use hashtags by placing the hash character # (also known as the number sign or pound sign) in front of a word or unspaced phrase, either in the main text of a message or at the end. Searching for that hashtag will yield each message that has been tagged with it. A hashtag archive is consequently collected into a single stream under the same hashtag.[1] For example, on the photo-sharing service Instagram, the hashtag #bluesky allows users to find all the posts that have been tagged using that hashtag.';

$tagger = new Hashtagger($title, $content);
$tagged = $tagger->tag();

// Result: An article about #PHP and #hashtags

选项

使用 tag() 的唯一参数调整标题标签的比例

$tagger = new Hashtagger($title, $content);
$tagged = $tagger->tag(0.7);

// Result: An #article about #PHP and #hashtags