<commit_before>// (c) Copyright 2015-2017 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package flow

import (
	"database/sql"
	"errors"
	"fmt"
	"math"
	"strings"
)

// WorkflowID is the type of unique workflow identifiers.
type WorkflowID int64

// Workflow represents the entire life cycle of a single document.
//
// A workflow begins with the creation of a document, and drives its
// life cycle through a sequence of responses to user actions or other
// system events.
//
// The engine in `flow` is visible primarily through workflows,
// documents and their behaviour.
//
// Currently, the topology of workflows is a graph, and is determined
// by the node definitions herein.
//
// N.B. It is highly recommended, but not necessary, that workflow
// names be defined in a system of hierarchical namespaces.
type Workflow struct {
	id     WorkflowID // Globally-unique identifier of this workflow
	name   string     // Globally-unique name of this workflow
	dtype  DocTypeID  // Document type of which this workflow defines the life cycle
	bstate DocStateID // Where this flow begins
}

// ID answers the unique identifier of this workflow.
func (w *Workflow) ID() WorkflowID {
	return w.id
}

// Name answers the globally-unique name of this workflow.
func (w *Workflow) Name() string {
	return w.name
}

// DocType answers the document type for which this defines the
// workflow.
func (w *Workflow) DocType() DocTypeID {
	return w.dtype
}

// BeginState answers the document state in which the execution of
// this workflow begins.
func (w *Workflow) BeginState() DocStateID {
	return w.bstate
}
<commit_msg>Add a method to `Workflow` to answers its nodes<commit_after>// (c) Copyright 2015-2017 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package flow

import (
	"database/sql"
	"errors"
	"fmt"
	"math"
	"strings"
)

// WorkflowID is the type of unique workflow identifiers.
type WorkflowID int64

// Workflow represents the entire life cycle of a single document.
//
// A workflow begins with the creation of a document, and drives its
// life cycle through a sequence of responses to user actions or other
// system events.
//
// The engine in `flow` is visible primarily through workflows,
// documents and their behaviour.
//
// Currently, the topology of workflows is a graph, and is determined
// by the node definitions herein.
//
// N.B. It is highly recommended, but not necessary, that workflow
// names be defined in a system of hierarchical namespaces.
type Workflow struct {
	id     WorkflowID // Globally-unique identifier of this workflow
	name   string     // Globally-unique name of this workflow
	dtype  DocTypeID  // Document type of which this workflow defines the life cycle
	bstate DocStateID // Where this flow begins
	nodes  []*Node    // Nodes comprising this workflow
}

// ID answers the unique identifier of this workflow.
func (w *Workflow) ID() WorkflowID {
	return w.id
}

// Name answers the globally-unique name of this workflow.
func (w *Workflow) Name() string {
	return w.name
}

// DocType answers the document type for which this defines the
// workflow.
func (w *Workflow) DocType() DocTypeID {
	return w.dtype
}

// BeginState answers the document state in which the execution of
// this workflow begins.
func (w *Workflow) BeginState() DocStateID {
	return w.bstate
}

// Nodes answers a list of the nodes comprising this workflow.
func (w *Workflow) Nodes(refresh bool) ([]*Node, error) {
	if len(w.nodes) == 0 {
		refresh = true
	}

	if refresh {
		ns, err := _workflows.Nodes(w.id)
		if err != nil {
			return nil, err
		}
		w.nodes = ns
	}

	ary := make([]*Node, len(w.nodes))
	copy(ary, w.nodes)
	return ary, nil
}

{'fraction_non_alphanumeric': 0.08890303416083174, 'fraction_numerical': 0.0061531932951410994, 'mean_word_length': 3.360777058279371, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2789530', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1301, 'n_words': 635}