Topic auto tagging

I need one certain category’s (and it’s sub-category’s) to have auto-tagging feature. For example… I set up Tags, which can be used for topics in category (for example: iphone, macbookpro). If topic title has text “iPhone” and “MacBook Pro” in it, the tags “iphone” and “macbookpro” would be automatically selected for this topic.

What is the best strategy to get such feature implemented?

Should I go with a plugin? Is it possible to do with a plugin?

Or should I add feature to topic (and add “Topic auto-tagging” to it’s settings) and create a pull request to have it in main branch?

7 лайков

Create a plugin based on Sam’s Unhandled Tagger.

Alter plugin.rb to scan for title and apply existing tags instead of always applying unhlandled.

9 лайков

Instead of automatically tagging topics, I would like the idea of suggesting tags just as similar topics are suggested, but I imagine this isn’t that cheap to have (because we would need to maintain some sort of model/corpus per tag).

4 лайка

What if tags would populate as you type and before posting you could add/remove tags? Would that be OK?

1 лайк

Would like to see option on the Category>Edit>Tags screen for:

Default tags for this category

below the current options:

This would also help for topics posted via mobile since adding tags is not supported.

My use case is adding an “events” tag so that topics from different event subcategories across the site can get aggregated to one calendar.

1 лайк

A bayesian algorithm would work well here.

To seed it, feed in all the current tagged posts, and let it learn which words in the content of a post correspond (probabilistically) to which tags.

1 лайк

Merged in from a duplicate topic.


Great WP plugin and seems it would be a great Discourse plugin as well if built to the same logic as this one.

Comments?

4 лайка

Yuss! I was hoping for something like this recently when I built a ‘homepage’ that relies on tagging to group content.

2 лайка

See how Wikibots are working at Wikipedia, it is a good reference model… Other important criteria to policy and implementation:

  • to be an assisted agent: never (or very rare) an automatic classification with no human confirming it. Must work “by (assisted) lot” not in a continous (by demand) way.

  • to be specialized: never generic, need a scope and limited (configurable/controlable) range.

  • to be symmetric over validation: an human can be also use the same tag, the robot (software agent) is not the only autorithy to tagging its scope. So two cenarios: 1. robot tagging and human validating/confirming (or warning to vote). 2. human tagging, and robot valiating (or warning to other human confirm).

Whith this basic polices the robot is viable in any community!

Other suggestion: when the scope is specific, or when the “easy to tag” generates “tag pollution”, the best is to use different color to the tags of the bot-scope. EXAMPLE: tagging languages in a multilingual community as https://discuss.okfn.org.

1 лайк

Now that we have watched words that trigger certain actions, wouldn’t it be easy to simply add “tag” as a possible action to perform upon a matched word/regex?

7 лайков

It’s a feature that is closer to being implemented now, yes. “Simply adding tag” isn’t quite the whole story. Each watched word needs to also specify which tag to add, for example.

10 лайков

That would be absolutely awesome! Especially if it’s not just words but also regular expressions. Auto-tagging based on regular expressions would bring tags in discourse to a whole new level!

Yes, and I also realize that the existing actions apply to posts while tags can only be applied to topics. So the question is: will tagging actions only be based on the first post? Or can any reply also trigger the tag? Or will it be a setting, whether it applies to both?..

Did anyone endup building this as a plugin?

@vinothkannans is currently working on something along these lines for PMs. I’m not sure how much extra work there would be to make it fit this brief – can you comment Vinoth?

You can create a plugin with the below simple code. But the difficulty level is fully depends upon your auto tagging logic/requirement.

DiscourseEvent.on(:topic_created) do |topic|
  guardian = Guardian.new(Discourse.system_user)
  DiscourseTagging.tag_topic_by_names(topic, guardian, ["bug"], append: true) if topic.title.match(/bug/)
end
13 лайков

@syl решил это с помощью настраиваемого авто-тегирования в своём плагине Docus. Мне кажется, кто-то мог бы вынести эту функцию, чтобы создать авто-тегирование, если бы он не возражал.

С моей точки зрения, наиболее очевидным решением было бы автоматическое присвоение посту тега(ов), на котором(ых) в данный момент находится пользователь (страница тега или пост). Это делает работу функции визуально понятной для пользователя, если ему потребуется её изменить, и в большинстве случаев это, вероятно, будет верно, так как он будет отвечать на что-то с тегами, на которые он отвечает.

2 лайка

Поправьте меня, если я ошибаюсь, но похоже, что плагин реализовал @pfaffman на GitHub - pfaffman/discourse-topic-default-tag: Allow topics to include default tags · GitHub?

1 лайк

Да. Это просто присваивает тег каждой теме, созданной в категории, но, полагаю, это хороший старт для чего-то, что могло бы назначать теги в зависимости от содержимого темы.

3 лайка

+1 Это была бы очень полезная функция или плагин: автоматическая разметка на основе отслеживаемых слов (каждое с присвоенным тегом), которые встречаются в теме (заголовок/тело).

1 лайк

Это определенно возможно с помощью плагина. Вы можете использовать мой плагин выше как отправную точку или задать вопрос в Marketplace

3 лайка