Skip to content

Commit

Permalink
Merge pull request #55 from 10up/fix/cli-comma-delimeted-ids
Browse files Browse the repository at this point in the history
CLI: enable comma delimited list of post ids to classifai
  • Loading branch information
helen committed Sep 24, 2019
2 parents 56ca22c + 5986d06 commit 1f7bc76
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Build Status](https://travis-ci.com/10up/classifai.svg?token=Jy6DFK4YVZbgtyNHcjm5&branch=develop)](https://travis-ci.com/10up/classifai) [![Release Version](https://img.shields.io/github/release/10up/classifai.svg)](https://github.com/10up/classifai/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v5.2%20tested-success.svg) [![MIT License](https://img.shields.io/github/license/10up/classifai.svg)](https://github.com/10up/classifai/blob/develop/LICENSE.md)

## Table of Contents
## Table of Contents
* [Features](#features)
* [Requirements](#requirements)
* [Installation](#installation)
Expand Down Expand Up @@ -72,7 +72,7 @@ Note that [Computer Vision](https://docs.microsoft.com/en-us/azure/cognitive-ser
- The file size of the image must be less than 4 megabytes (MB)
- The dimensions of the image must be greater than 50 x 50 pixels

Note that Computer Vision has a [free pricing tier](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/computer-vision/) that offers 20 transactions per minute and 5,000 transactions per month.
Note that Computer Vision has a [free pricing tier](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/computer-vision/) that offers 20 transactions per minute and 5,000 transactions per month.

#### 1. Sign up for Azure services
- [Register for a Microsoft Azure account](https://azure.microsoft.com/en-us/free/) or sign into your existing one.
Expand All @@ -96,20 +96,28 @@ Note that Computer Vision has a [free pricing tier](https://azure.microsoft.com/

`--post_type=post_type`

Batch classify posts belonging to this post type. If `false` or absent relies on `post_ids` in args
Batch classify posts belonging to this post type. If `false` or absent relies on `post_ids`.

default: `false`
options:
- any post type name
default: `false`
options:
- any post type name
- `false`, if args contains `post_ids`


`{ post_ids }`

A comma delimited list of post ids to classify. Used if `post_type` is false or absent.

default: `true`


`--limit=limit`

Limit classification to N posts.

default: `false`
options:
- `false`, no limit
default: `false`
options:
- `false`, no limit
- `N`, max number of posts to classify

`--link=link`
Expand All @@ -130,13 +138,13 @@ Directly classify text using Watson NLU.

Enables NLU category feature

default: `true`
default: `true`

`--keyword=bool`

Enables NLU keyword feature

default: `true`
default: `true`

`--concept=bool`

Expand All @@ -154,10 +162,10 @@ default: `true`

Path to input file or URL

default: `false`
options:
- path to local file
- path to remote URL
default: `false`
options:
- path to local file
- path to remote URL
- `false`, uses args[0] instead

`--only-normalize=<bool>`
Expand Down
4 changes: 2 additions & 2 deletions includes/Classifai/Command/ClassifaiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClassifaiCommand extends \WP_CLI_Command {
* ## Options
*
* [<post_ids>]
* : Post IDs to classify
* : Comma-delimited list of post IDs to classify
*
* [--post_type=<post_type>]
* : Batch classify posts belonging to this post type. If false relies on post_ids in args
Expand All @@ -45,7 +45,7 @@ public function post( $args = [], $opts = [] ) {
$opts = wp_parse_args( $opts, $defaults );

if ( empty( $opts['post_type'] ) ) {
$post_ids = $args;
$post_ids = explode( ',', $args[0] );
} else {
$post_ids = $this->get_posts_to_classify( $opts );
}
Expand Down

0 comments on commit 1f7bc76

Please sign in to comment.