Skip to content

Commit

Permalink
Merge pull request #309 from domino14/feature/308/new_lexica
Browse files Browse the repository at this point in the history
adding new lexica
  • Loading branch information
domino14 authored Feb 15, 2019
2 parents 86ffa13 + 3179553 commit 6a6e901
Show file tree
Hide file tree
Showing 27 changed files with 176 additions and 123 deletions.
6 changes: 3 additions & 3 deletions djAerolith/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

def getLexicon(request=None):
if not request:
return Lexicon.objects.get(lexiconName='America')
return Lexicon.objects.get(lexiconName='NWL18')
elif request.LANGUAGE_CODE == 'es':
return Lexicon.objects.get(lexiconName='FISE09')
return Lexicon.objects.get(lexiconName='America')
return Lexicon.objects.get(lexiconName='FISE2')
return Lexicon.objects.get(lexiconName='NWL18')


class AerolithProfile(models.Model):
Expand Down
31 changes: 31 additions & 0 deletions djAerolith/base/management/commands/migrate_list_lexica.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Migrates all lists for users from lexicon1 to lexicon2
"""
from django.core.management.base import BaseCommand, CommandError

from base.models import Lexicon, SavedList


class Command(BaseCommand):

def add_arguments(self, parser):
parser.add_argument('lexicon1', type=str)
parser.add_argument('lexicon2', type=str)

def handle(self, *args, **options):
if 'lexicon1' not in options or 'lexicon2' not in options:
raise CommandError('Lexica must be specified: Old New')
try:
lex1 = Lexicon.objects.get(lexiconName=options['lexicon1'])
lex2 = Lexicon.objects.get(lexiconName=options['lexicon2'])
except Lexicon.DoesNotExist as e:
raise CommandError(e)

count = 0
for word_list in SavedList.objects.filter(lexicon=lex1,
is_temporary=False):
count += 1
word_list.lexicon = lex2
word_list.save()
print('Migrated %s lists from %s to %s' % (count, lex1, lex2))
2 changes: 2 additions & 0 deletions djAerolith/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
'CSW07',
'CSW12',
'America2016',
'FISE09',
# 'America' # Remove this lexicon sometime in March.
]

# XXX: This handles both the Spanish and English case, but alphagrammize
Expand Down
2 changes: 1 addition & 1 deletion djAerolith/base/tests/test_wordlist_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class WordwallsAPITest(TestCase):
fixtures = ['test/lexica.json',
fixtures = ['test/lexica.yaml',
'test/users.json',
'test/profiles.json',
'test/word_lists.json']
Expand Down
2 changes: 1 addition & 1 deletion djAerolith/current_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_VERSION = '1.1.6.0'
CURRENT_VERSION = '1.2.0.0'
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
<label class="col-lg-3 control-label" for="lexicon">Lexicon</label>
<div class="col-lg-9">
<select id="lexicon" class="form-control">
<option>America</option>
<option>NWL18</option>
<option>CSW15</option>
<option>America</option> <!-- DELETE ME ASAP -->
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ const allowedSearchTypes = new Set([
SearchTypesEnum.POINTS,
SearchTypesEnum.NUM_ANAGRAMS,
SearchTypesEnum.NUM_VOWELS,
SearchTypesEnum.NOT_IN_LEXICON,
SearchTypesEnum.PROBABILITY_LIMIT,
SearchTypesEnum.MATCHING_ANAGRAM,
]);

const lexOptions = [{
value: 'America',
displayValue: 'America',
value: 'NWL18',
displayValue: 'NWL18',
}, {
value: 'CSW15',
displayValue: 'CSW15',
}, {
value: 'America', /* DELETE ME ASAP */
displayValue: 'America',
}];

class WordSearchForm extends React.Component {
Expand All @@ -38,7 +44,7 @@ class WordSearchForm extends React.Component {
this.searchSubmit = this.searchSubmit.bind(this);

this.state = {
lexicon: 'America',
lexicon: 'NWL18',
};
}

Expand Down
3 changes: 2 additions & 1 deletion djAerolith/flashcards/templates/flashcards/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ <h4 class="modal-title">Look up Word</h4>
<label class="col-lg-3 control-label" for="word-lookup-lexicon">Lexicon</label>
<div class="col-lg-9">
<select id="word-lookup-lexicon" class="form-control">
<option>America</option>
<option>NWL18</option>
<option>CSW15</option>
<option>FISE2</option>
</select>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions djAerolith/lib/tests/test_word_searches.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class SimpleSearchCase(TestCase):
fixtures = [
'test/lexica.json'
'test/lexica.yaml'
]

def setUp(self):
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_probability_limit_outside_of_range(self):

class TagSearchCase(TestCase):
fixtures = [
'test/lexica.json',
'test/lexica.yaml',
'test/users.json',
'test/profiles.json'
]
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_more_tags(self):

class MassiveTagSearchCase(TestCase):
fixtures = [
'test/lexica.json',
'test/lexica.yaml',
'test/users.json',
'test/profiles.json'
]
Expand Down
2 changes: 0 additions & 2 deletions djAerolith/lib/word_db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from django.conf import settings

from base.models import alphagrammize

from lib.domain import Word, Alphagram, Question, Questions
from lib.query_generator.exceptions import BadInput
from lib.query_generator.gen import QueryGenerator, MAX_CHUNK_SIZE
Expand Down
14 changes: 10 additions & 4 deletions djAerolith/lib/word_searches.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,21 @@ def temporary_list_name(search_descriptions, lexicon_name):
elif sd['condition'] == SearchDescription.NOT_IN_LEXICON:
desc = ''
if sd['lexicon'] == 'other_english':
if lexicon_name == 'America':
if lexicon_name == 'NWL18':
desc = 'CSW15'
elif lexicon_name == 'CSW15':
desc = 'America'
desc = 'NWL18'
# XXX: REMOVE IN MARCH
elif lexicon_name == 'America':
desc = 'CSW15'
elif sd['lexicon'] == 'update':
if lexicon_name == 'America':
desc = 'OWL2'
if lexicon_name == 'NWL18':
desc = 'America'
elif lexicon_name == 'CSW15':
desc = 'CSW12'
# XXX: REMOVE IN MARCH
elif lexicon_name == 'America':
desc = 'OWL2'
tokens.append(f'not in {desc}')
elif sd['condition'] == SearchDescription.MATCHING_ANAGRAM:
tokens.append(f'matching {sd["letters"]}')
Expand Down
56 changes: 0 additions & 56 deletions djAerolith/wordwalls/fixtures/test/lexica.json

This file was deleted.

48 changes: 48 additions & 0 deletions djAerolith/wordwalls/fixtures/test/lexica.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- fields:
lengthCounts: '{"2":92,"3":878,"4":3491,"5":8654,"6":16999,"7":27437,"8":36327,"9":38795,"10":34881,"11":27862,"12":20437,"13":14061,"14":9251,"15":5846}'
lexiconDescription: Collins 2015 International English Word List
lexiconName: CSW15
model: base.lexicon
pk: 1
- fields:
lengthCounts: '{"2":78,"3":765,"4":2844,"5":6797,"6":12932,"7":21063,"8":27962,"9":28773,"10":22739,"11":16769,"12":11958,"13":8210,"14":5380,"15":3371}'
lexiconDescription: I am Trumperica, and so can you.
lexiconName: America2016
model: base.lexicon
pk: 2
- fields:
lengthCounts: '{"2":77,"3":732,"4":2737,"5":6495,"6":12353,"7":20134,"8":26563,"9":27270,"10":21597,"11":15886,"12":11293,"13":7701,"14":5034,"15":3147}'
lexiconDescription: North American 2006 Official Word List 2006
lexiconName: OWL2
model: base.lexicon
pk: 4
- fields:
lengthCounts: '{"2":92,"3":865,"4":3443,"5":8517,"6":16668,"7":26797,"8":35335,"9":37873,"10":34177,"11":27304,"12":20041,"13":13779,"14":9081,"15":5736}'
lexiconDescription: Collins 2012 International English Word List
lexiconName: CSW12
model: base.lexicon
pk: 6
- fields:
lengthCounts: '{"2":78,"3":765,"4":2844,"5":6797,"6":12932,"7":21063,"8":27962,"9":28773,"10":22739,"11":16769,"12":11958,"13":8210,"14":5380,"15":3371}'
lexiconDescription: I am America, and so can you.
lexiconName: America
model: base.lexicon
pk: 7
- fields:
lengthCounts: '{"2":75,"3":411,"4":2030,"5":7204,"6":16339,"7":32154,"8":50756,"9":68345,"10":79948,"11":76024,"12":62015,"13":43101,"14":25338,"15":12788}'
lexiconDescription: "Federaci\xF3n Internacional de Scrabble en Espa\xF1ol"
lexiconName: FISE09
model: base.lexicon
pk: 8
- fields:
lengthCounts: '{"10":23928,"11":17577,"12":12362,"13":8410,"14":5526,"15":3478,"2":79,"3":766,"4":2846,"5":6814,"6":12968,"7":21108,"8":28029,"9":28936}'
lexiconDescription: NASPA Word List 2018 Edition
lexiconName: NWL18
model: base.lexicon
pk: 9
- fields:
lengthCounts: '{"10":79951,"11":76526,"12":63120,"13":44592,"14":26828,"15":13934,"2":76,"3":426,"4":2046,"5":7179,"6":16232,"7":31901,"8":50413,"9":68121}'
lexiconDescription: "Federaci\xF3n Internacional de Scrabble en Espa\xF1ol, 2017 Edition"
lexiconName: FISE2
model: base.lexicon
pk: 10
Loading

0 comments on commit 6a6e901

Please sign in to comment.