// LoadDict is for loading a word list from file
496188
func LoadDict(path string) (*Dict, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	wordWithPayloads := make([]WordWithPayload, 0)
	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		if line := scanner.Text(); len(line) != 0 {
			wordWithPayloads = append(wordWithPayloads,
				WordWithPayload{line, true})
		}
	}
	tree := MakePrefixTree(wordWithPayloads)
	dix := Dict{tree}
	return &dix, nil
}
240867
func LoadYAML(yamlContent []byte) (*Dataset, error) {
	var input []map[string]interface{}
	if err := yaml.Unmarshal(yamlContent, &input); err != nil {
		return nil, err
	}

	return internalLoadFromDict(input)
}
140928
func (KNN *KNNClassifier) LoadWithPrefix(reader *base.ClassifierDeserializer, prefix string) error {

	clsMetadata, err := reader.ReadMetadataAtPrefix(prefix)
	if err != nil {
		return err
	}

	if clsMetadata.ClassifierName != "KNN" {
		return fmt.Errorf("This file doesn't contain a KNN classifier")
	}
	if clsMetadata.ClassifierVersion != "1.0" {
		return fmt.Errorf("Can't understand this file format")
	}

	metadata := clsMetadata.ClassifierMetadata
	KNN.DistanceFunc = metadata["distance_func"].(string)
	KNN.Algorithm = metadata["algorithm"].(string)
	//KNN.NearestNeighbours = metadata["neighbours"].(int)
	KNN.Weighted = metadata["weighted"].(bool)
	KNN.AllowOptimisations = metadata["allow_optimizations"].(bool)

	// 101 on why JSON is a bad serialization format
	floatNeighbours := metadata["neighbours"].(float64)
	KNN.NearestNeighbours = int(floatNeighbours)

	KNN.TrainingData, err = reader.GetInstancesForKey(reader.Prefix(prefix, "TrainingInstances"))

	return err
}
1253239
func Load(r io.Reader) (*MetaInfo, error) {
	var mi MetaInfo
	d := bencode.NewDecoder(r)
	err := d.Decode(&mi)
	if err != nil {
		return nil, err
	}
	return &mi, nil
}
515618
func (k *Keyfile) Load() (err error) {
	if len(k.fname) > 0 {
		var f *os.File
		f, err = os.Open(k.fname)
		if err == nil {
			err = k.read(f)
			f.Close()
		}
	}
	return
}
464152
func LoadJSON(filename string) *Graph {
	js, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil
	}
	return ParseJSON(js)
}
377050
func (f File) Load(in io.Reader) (err error) {
	bufin, ok := in.(*bufio.Reader)
	if !ok {
		bufin = bufio.NewReader(in)
	}
	return parseFile(bufin, f)
}
1108849
func (rt *RandomTree) Load(filePath string) error {
	reader, err := base.ReadSerializedClassifierStub(filePath)
	if err != nil {
		return err
	}
	return rt.LoadWithPrefix(reader, "")
}
604415
func LoadFile(path string) (tree *Tree, err error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer file.Close()
	return LoadReader(file)
}
1144620
func LoadFile(data string) (file *File, err error) {
	file = &File{}
	if err = proto.UnmarshalTextML(data, file); err != nil {
		return
	}
	err = file.Normalize()
	return
}
434074
func (m *dirsMap) Load(key string) (bool, bool) {
	i, ok := m.data.Load(m.normalizeKey(key))
	if !ok {
		return false, false
	}
	s, ok := i.(bool)
	return s, ok
}
542763
func (x *xattr) load(p *search.DescribedPermanode) {
	x.mu.Lock()
	defer x.mu.Unlock()

	*x.xattrs = map[string][]byte{}
	for k, v := range p.Attr {
		if strings.HasPrefix(k, xattrPrefix) {
			name := k[len(xattrPrefix):]
			val, err := base64.StdEncoding.DecodeString(v[0])
			if err != nil {
				Logger.Printf("Base64 decoding error on attribute %v: %v", name, err)
				continue
			}
			(*x.xattrs)[name] = val
		}
	}
}
274302
func (m multiLoader) Load(s interface{}) error {
	for _, loader := range m {
		if err := loader.Load(s); err != nil {
			return err
		}
	}

	return nil
}
333338
func Load(content string) (tree *Tree, err error) {
	return LoadBytes([]byte(content))
}
637739
func DeserializeDictionary(o []byte, m map[uint32]uint32) error {
	buf := bytes.NewBuffer(o)

	for buf.Len() > 0 {
		var k uint32

		if err := binary.Read(buf, binary.LittleEndian, &k); err != nil {
			return err
		}
		var v uint32
		if err := binary.Read(buf, binary.LittleEndian, &v); err != nil {
			return err
		}
		m[k] = v
	}

	return nil
}
1156957
func (rt *RandomTree) LoadWithPrefix(reader *base.ClassifierDeserializer, prefix string) error {
	rt.Root = &DecisionTreeNode{}
	return rt.Root.LoadWithPrefix(reader, prefix)
}
1088862
func LoadFiles(filenames []string, db *sql.DB, driver string) error {
	for _, filename := range filenames {
		if err := LoadFile(filename, db, driver); err != nil {
			return err
		}
	}
	return nil
}