<commit_before>/*                          _       _
 *__      _____  __ ___   ___  __ _| |_ ___
 *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
 * \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
 *  \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
 *
 * Copyright © 2016 - 2018 Weaviate. All rights reserved.
 * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md
 * AUTHOR: <NAME> (<EMAIL>)
 * See www.creativesoftwarefdn.org for details
 * Contact: @CreativeSofwFdn / <EMAIL>
 */
package aggregate

import (
	"fmt"
	"strings"

	"github.com/creativesoftwarefdn/weaviate/database/schema"
	"github.com/creativesoftwarefdn/weaviate/database/schema/kind"
	"github.com/creativesoftwarefdn/weaviate/graphqlapi/descriptions"
	"github.com/creativesoftwarefdn/weaviate/graphqlapi/local/common_filters"
	"github.com/creativesoftwarefdn/weaviate/models"
	"github.com/graphql-go/graphql"
)

//func Build(dbSchema *schema.Schema, weaviate string) (*graphql.Field, error) {
//	getKinds := graphql.Fields{}
//
//	if len(dbSchema.Actions.Classes) == 0 && len(dbSchema.Things.Classes) == 0 {
//		return nil, fmt.Errorf("There are no Actions or Things classes defined yet.")
//	}
//
//	knownClasses := map[string]*graphql.Object{}
//
//	if len(dbSchema.Actions.Classes) > 0 {
//		networkAggregateActions, err := buildAggregateClasses(dbSchema, kind.ACTION_KIND, dbSchema.Actions, &knownClasses, weaviate)
//		if err != nil {
//			return nil, err
//		}
//
//		getKinds["Actions"] = &graphql.Field{
//			Name:        fmt.Sprintf("WeaviateNetworkAggregate%sActions", weaviate),
//			Description: descriptions.NetworkAggregateActionsDesc,
//			Type:        networkAggregateActions,
//			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
//				return nil, fmt.Errorf("not supported")
//			},
//		}
//	}
//
//	if len(dbSchema.Things.Classes) > 0 {
//		networkAggregateThings, err := buildAggregateClasses(dbSchema, kind.THING_KIND, dbSchema.Things, &knownClasses)
//		if err != nil {
//			return nil, err
//		}
//
//		getKinds["Things"] = &graphql.Field{
//			Name:        fmt.Sprintf("WeaviateNetworkAggregate%sThings", weaviate),
//			Description: descriptions.NetworkAggregateThingsDesc,
//			Type:        networkAggregateThings,
//			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
//				return nil, fmt.Errorf("not supported")
//			},
//		}
//	}
//
//	field := graphql.Field{
//		Name:        "WeaviateNetworkAggregate",
//		Description: descriptions.NetworkAggregateWhereDesc,
//		Type: graphql.NewObject(graphql.ObjectConfig{
//			Name:        "WeaviateNetworkAggregateObj",
//			Fields:      getKinds,
//			Description: descriptions.NetworkAggregateObjDesc,
//		}),
//		Resolve: func(p graphql.ResolveParams) (interface{}, error) {
//			return nil, fmt.Errorf("not supported")
//		},
//	}
//
//	return &field, nil
//}

// Builds the classes below a Network -> Aggregate -> (k kind.Kind)
func BuildAggregateClasses(dbSchema *schema.Schema, k kind.Kind, semanticSchema *models.SemanticSchema, knownClasses *map[string]*graphql.Object, weaviate string) (*graphql.Object, error) {
	classFields := graphql.Fields{}

	var kindName string
	switch k {
	case kind.THING_KIND:
		kindName = "Thing"
	case kind.ACTION_KIND:
		kindName = "Action"
	}

	for _, class := range semanticSchema.Classes {
		classField, err := buildAggregateClass(dbSchema, k, class, knownClasses, kindName, weaviate)
		if err != nil {
			return nil, fmt.Errorf("Could not build class for %s", class.Class)
		}
		classFields[class.Class] = classField
	}

	classes := graphql.NewObject(graphql.ObjectConfig{
		Name:        fmt.Sprintf("WeaviateNetworkAggregate%s%ssObj", weaviate, kindName),
		Fields:      classFields,
		Description: fmt.Sprintf(descriptions.NetworkAggregateThingsActionsObjDesc, kindName),
	})

	return classes, nil
}
<commit_msg>gh-662: wip<commit_after>/*                          _       _
 *__      _____  __ ___   ___  __ _| |_ ___
 *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
 * \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
 *  \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
 *
 * Copyright © 2016 - 2018 Weaviate. All rights reserved.
 * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md
 * AUTHOR: <NAME> (<EMAIL>)
 * See www.creativesoftwarefdn.org for details
 * Contact: @CreativeSofwFdn / <EMAIL>
 */
package aggregate

import (
	"fmt"
	"strings"

	"github.com/creativesoftwarefdn/weaviate/database/schema"
	"github.com/creativesoftwarefdn/weaviate/database/schema/kind"
	"github.com/creativesoftwarefdn/weaviate/graphqlapi/descriptions"
	"github.com/creativesoftwarefdn/weaviate/graphqlapi/local/common_filters"
	"github.com/creativesoftwarefdn/weaviate/models"
	"github.com/graphql-go/graphql"
)

// Builds the classes below a Network -> Aggregate -> (k kind.Kind)
func BuildAggregateClasses(dbSchema *schema.Schema, k kind.Kind, semanticSchema *models.SemanticSchema, knownClasses *map[string]*graphql.Object, weaviate string) (*graphql.Object, error) {
	classFields := graphql.Fields{}

	var kindName string
	switch k {
	case kind.THING_KIND:
		kindName = "Thing"
	case kind.ACTION_KIND:
		kindName = "Action"
	}

	for _, class := range semanticSchema.Classes {
		classField, err := buildAggregateClass(dbSchema, k, class, knownClasses, kindName, weaviate)
		if err != nil {
			return nil, fmt.Errorf("Could not build class for %s", class.Class)
		}
		classFields[class.Class] = classField
	}

	classes := graphql.NewObject(graphql.ObjectConfig{
		Name:        fmt.Sprintf("WeaviateNetworkAggregate%s%ssObj", weaviate, kindName),
		Fields:      classFields,
		Description: fmt.Sprintf(descriptions.NetworkAggregateThingsActionsObjDesc, kindName),
	})

	return classes, nil
}

{'fraction_non_alphanumeric': 0.15075201119272472, 'fraction_numerical': 0.004022385449457853, 'mean_word_length': 3.4925373134328357, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '2545518', 'n_tokens_mistral': 2088, 'n_tokens_neox': 2016, 'n_words': 345}