Movatterモバイル変換


[0]ホーム

URL:


Title:Crossword, Scrabble and Anagram Solver
Version:0.1.0
Date:2016-07-02
Description:Provides a large English words list and tools to find words by patterns. In particular, anagram finder and scrabble word finder.
URL:https://github.com/idmn/wfindr
BugReports:https://github.com/idmn/wfindr/issues
License:GPL-2
LazyData:true
Depends:R (≥ 3.1.2)
Imports:dplyr, magrittr
RoxygenNote:5.0.1
NeedsCompilation:no
Packaged:2016-07-03 10:24:44 UTC; Jaroslav
Author:Iaroslav Domin [aut, cre]
Maintainer:Iaroslav Domin <ya.domin@gmail.com>
Repository:CRAN
Date/Publication:2016-07-03 17:58:53

Characters count

Description

Calculates character frequencies in a vector.

Usage

char_count(x)

Arguments

x

character vector, or a list that can be unlisted to a charactervector.

Value

data.frame with two columns:char - character andcount- number of it's occurencies.

Examples

char_count("character")char_count(words.eng)

Find words that fit the chosen parameters.

Description

Uses regex constructed bymodel_to_regex to searchwords. By default the search is done amongwords.eng.
find_word returns a vector of found words,find_word_lreturns a logical vector that can be used for subsetting.

Usage

find_word(model = "*", allow = letters, ban = character(0),  type = "usual", words = wfindr::words.eng)find_word_l(model = "*", allow = letters, ban = character(0),  type = "usual", words = wfindr::words.eng)

Arguments

model

pattern that a word should match. Consists of letters andunknown characters specifications. Dot. stands for unknowncharacter. It may be followed by{...} repetition quantifier (i.e..{n},.{n,},.{n,m}). Asterisk* standsfor unknown number of unknown characters. See examples.
By defaultmodel is set to"*".

allow

characters allowed to fill gaps in a word. Can be listed in asingle string or in a vector. By default is set toletters.

ban

characters not allowed to fill gaps in a word.

type

can be"usual","scrabble", or"anagram".Abbreviated input is allowed: e.g."u","s", or"a".
type defines how often allowed characters can be usedto fill the gaps. Say, character appearsn times inallow andm times inban. Ifd = n - m is less or equal to zero,whatever thetype is, this character won't be used to fill the gaps.For the case whend > 0:

  • Iftype is"usual" then the character is allowed to fill the gapsunlimited number of times.

  • Iftype is"scrabble" then the character is allowed to fill the gapsnomore than d times.

  • Iftype is"anagram" then thecharacter should be usedexactly d times.

words

vector of words to search within. By default is set towords.eng.

See Also

scrabble,anagram

Examples

## Search 4-letter words starting with "c".find_word("c.{3}")## Disallow "a" and "b".find_word("c.{3}", ban = "ab")## Allow only "a" and "b" to fill the gap.find_word("c.{3}", allow = "ab")## Allow "a", "b", and "c", but then ban "c"## result is the same as in the previous examplefind_word("c.{3}", allow = "abc", ban = "c")## Find no more than 4-letter words that have "th" bigramlibrary(magrittr)find_word(".{0,4}") %>% find_word("*th*", words = .)## count words that start with "th"sum(find_word_l("th*"))length(find_word("th*"))## Find words that can be constructed of the "thing" word's letters.find_word(allow = "thing", type = "scrabble")## Get at lest 4-letter words.find_word(".{4,}", allow = "thing", type = "scrabble")## Find anagrams of the word "thing"find_word(allow = "thing", type = "anagram")

Build a regular expression to fit chosen parameters

Description

Build a regular expression to fit chosen parameters

Usage

model_to_regex(model = "*", allow = letters, ban = character(0),  type = "usual")

Arguments

model

pattern that a word should match. Consists of letters andunknown characters specifications. Dot. stands for unknowncharacter. It may be followed by{...} repetition quantifier (i.e..{n},.{n,},.{n,m}). Asterisk* standsfor unknown number of unknown characters. See examples.
By defaultmodel is set to"*".

allow

characters allowed to fill gaps in a word. Can be listed in asingle string or in a vector. By default is set toletters.

ban

characters not allowed to fill gaps in a word.

type

can be"usual","scrabble", or"anagram".Abbreviated input is allowed: e.g."u","s", or"a".
type defines how often allowed characters can be usedto fill the gaps. Say, character appearsn times inallow andm times inban. Ifd = n - m is less or equal to zero,whatever thetype is, this character won't be used to fill the gaps.For the case whend > 0:

  • Iftype is"usual" then the character is allowed to fill the gapsunlimited number of times.

  • Iftype is"scrabble" then the character is allowed to fill the gapsnomore than d times.

  • Iftype is"anagram" then thecharacter should be usedexactly d times.

Warning

Iftype = "scrabble" or"anagram", outputregex will contain perl-like syntax. So, to use it ingrep orgsub for example, setperl parameter toTRUE.

See Also

find_word,scrabble,anagram

Examples

## Regular expression to match all the 5-letter words starting with "c".model_to_regex("c.{4}")## Disallow "a" and "b".model_to_regex("c.{4}", ban = "ab")## Allow only "a" and "b" to fill the gap.model_to_regex("c.{4}", allow = "ab")## Allow "a", "b", and "c", but then ban "c" (result is the same as the previous example)model_to_regex("c.{4}", allow = "abc", ban = "c")## Regex to match all words that start with "p" and end with "zed".model_to_regex("p*zed")## Regex to match all the words that can be constructed of the word "thing".model_to_regex(allow = "thing", type = "scrabble")## Get at lest 4-letter words.model_to_regex(".{4,}", allow = "thing", type = "scrabble")## Regex to match anagrams of the word "thing"model_to_regex(allow = "thing", type = "anagram")

Find words that can be constructed from the specified letters

Description

scrabble finds words that can be constructed from thespecified set of letters.
anagram finds words that arepermutations of the specified set of letters. Usually this set of lettersis a word itself.

Usage

scrabble(allow, model = "*", ban = character(0),  words = wfindr::words.eng)anagram(allow, model = "*", ban = character(0), words = wfindr::words.eng)

Arguments

allow

characters allowed to use to construct words.

model

pattern that a word should match. Consists of letters andunknown characters specifications. Dot. stands for unknowncharacter. It may be followed by{...} repetition quantifier (i.e..{n},.{n,},.{n,m}). Asterisk* standsfor unknown number of unknown characters. See examples.
By defaultmodel is set to"*".

ban

characters not allowed to fill gaps in a word.

words

vector of words to search within. By default is set towords.eng.

Details

scrabble andanagram are functions built on top of thefind_word function with parametertype set to"scrabble" or"anagram" respectively andallowparameter moved to the first place to simplify usage (see the firstexample).

See Also

find_word

Examples

## Find all words that can be constructed of the "thing" word's lettersscrabble("thing")## same asfind_word(allow = "thing", type = "s")## take at least 4-letter wordsscrabble("thing", ".{4,}")## same asfind_word(".{4,}", "thing", type = "s")## Pick 8 random letters and find words that can be constructed of them.library(magrittr)sample(letters, 8, TRUE) %>% list(letters = ., words = scrabble(.))## Find anagrams of the word "thing"anagram("thing")

English words list

Description

263,533 english words list took fromhttp://norvig.com/ngrams/(Seeword.list file).

Format

An object of classcharacter of length 263533.


[8]ページ先頭

©2009-2025 Movatter.jp