-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this commit adds some meta data to each word list: the author of the list, the license, the origin etc. the data is also shown in the -dump output. the encoding of the russian word list is converted to utf8.
- Loading branch information
Showing
13 changed files
with
7,943 additions
and
7,872 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package main | ||
|
||
type IndexStringer func(int) string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"io" | ||
"io/ioutil" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
type WordList struct { | ||
Name string | ||
Author string | ||
License string | ||
Origin string | ||
Index IndexStringer | ||
Words string | ||
} | ||
|
||
var internalLists = make(map[string]*WordList) | ||
|
||
func linesFromInternalList(list string) []string { | ||
r := internalListReader(list) | ||
if r == nil { | ||
return nil | ||
} | ||
defer r.Close() | ||
return readerToLines(r) | ||
} | ||
|
||
func readerToLines(r io.Reader) []string { | ||
scanner := bufio.NewScanner(r) | ||
scanner.Split(bufio.ScanLines) | ||
lines := make([]string, 0) | ||
for scanner.Scan() { | ||
lines = append(lines, scanner.Text()) | ||
} | ||
|
||
return lines | ||
} | ||
|
||
func internalListReader(name string) io.ReadCloser { | ||
list, exists := internalLists[name] | ||
if !exists { | ||
return nil | ||
} | ||
|
||
return listReaderFromString(list.Words) | ||
} | ||
|
||
func listReaderFromString(list string) io.ReadCloser { | ||
r := strings.NewReader(strings.TrimSpace(list)) | ||
return ioutil.NopCloser(r) | ||
} | ||
|
||
func internalListNames() []string { | ||
names := make([]string, len(internalLists)) | ||
i := 0 | ||
for name, _ := range internalLists { | ||
names[i] = name | ||
i += 1 | ||
} | ||
sort.Strings(names) | ||
return names | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.