Skip to content

Commit

Permalink
Drop similar string page
Browse files Browse the repository at this point in the history
It is obsoleted by new machine translation interface.
  • Loading branch information
nijel committed Apr 11, 2013
1 parent e3df8e7 commit e136e19
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 113 deletions.
9 changes: 0 additions & 9 deletions docs/config.rst
Expand Up @@ -275,14 +275,6 @@ True will be assumed if it is not supplied.

This is actually django-registration settings.

.. setting:: SIMILAR_MESSAGES

SIMILAR_MESSAGES
----------------

Number of similar messages to lookup. This is not a hard limit, just a
number Weblate tries to find if it is possible.

.. setting:: SITE_TITLE

SITE_TITLE
Expand All @@ -296,4 +288,3 @@ WHOOSH_INDEX
------------

Directory where Whoosh fulltext indices will be stored. Defaults to :file:`whoosh-index` subdirectory.

42 changes: 0 additions & 42 deletions trans/models/unit.py
Expand Up @@ -403,48 +403,6 @@ def more_like_this(self, unit):
pk=unit.id
)

def similar(self, unit):
'''
Finds similar units to current unit.
'''
ret = set([unit.checksum])
index = FULLTEXT_INDEX.source_searcher(
not appsettings.OFFLOAD_INDEXING
)
with index as searcher:
# Extract up to 10 terms from the source
key_terms = searcher.key_terms_from_text(
'source',
unit.source,
numterms=10
)
terms = [kw[0] for kw in key_terms if not kw in IGNORE_SIMILAR]
cnt = len(terms)
# Try to find at least configured number of similar strings,
# remove up to 4 words
while (len(ret) < appsettings.SIMILAR_MESSAGES
and cnt > 0
and len(terms) - cnt < 4):
for search in itertools.combinations(terms, cnt):
results = self.fulltext(
' '.join(search),
True,
False,
False,
True
)
ret = ret.union(results)
cnt -= 1

project = unit.translation.subproject.project
return self.filter(
translation__subproject__project=project,
translation__language=unit.translation.language,
checksum__in=ret
).exclude(
target__in=['', unit.target]
)

def same(self, unit):
'''
Units with same source withing same project.
Expand Down
7 changes: 0 additions & 7 deletions trans/tests/js_views.py
Expand Up @@ -40,13 +40,6 @@ def test_get_string(self):
self.assertContains(response, 'Hello')
self.assertEquals(response.content, unit.get_source_plurals()[0])

def test_get_similar(self):
unit = self.get_unit()
response = self.client.get(
reverse('js-similar', kwargs={'unit_id': unit.id}),
)
self.assertContains(response, 'No similar strings found')

def test_translate(self):
unit = self.get_unit()
response = self.client.get(
Expand Down
25 changes: 0 additions & 25 deletions trans/views/js.py
Expand Up @@ -46,31 +46,6 @@ def get_string(request, checksum):
return HttpResponse(units[0].get_source_plurals()[0])


def get_similar(request, unit_id):
'''
AJAX handler for getting similar strings.
'''
unit = get_object_or_404(Unit, pk=int(unit_id))
unit.check_acl(request)

similar_units = Unit.objects.similar(unit)

# distinct('target') works with Django 1.4 so let's emulate that
# based on presumption we won't get too many results
targets = {}
res = []
for similar in similar_units:
if similar.target in targets:
continue
targets[similar.target] = 1
res.append(similar)
similar = res

return render_to_response('js/similar.html', RequestContext(request, {
'similar': similar,
}))


@login_required
def translate(request, unit_id):
'''
Expand Down
21 changes: 0 additions & 21 deletions weblate/html/js/similar.html

This file was deleted.

1 change: 0 additions & 1 deletion weblate/html/translate.html
Expand Up @@ -162,7 +162,6 @@ <h2>{% trans "Translation context" %}</h2>
<div id="translate-tabs">
<ul>
<li><a href="#tab-nearby" title="{% trans "Messages placed around this one" %}">{% trans "Nearby messages" %}</a></li>
<li><a href="{% url 'js-similar' unit_id=unit.id %}" title="{% trans "Similar messages" %}">{% trans "Similar messages" %}</a></li>
<li><a href="{% url 'js-other' unit_id=unit.id %}?type={{ type }}&amp;offset={{ offset }}&amp;sid={{ search_id }}" title="{% trans "Same message used in different subprojects" %}">{% trans "All locations" %}</a></li>
<li><a href="{% url 'js-dictionary' unit_id=unit.id %}" title="{% trans "Words extracted from glossary" %}">{% trans "Glossary" %}</a></li>
{% if mt_enabled %}
Expand Down
3 changes: 0 additions & 3 deletions weblate/settings_example.py
Expand Up @@ -319,9 +319,6 @@
# Number of nearby messages to show in each direction
NEARBY_MESSAGES = 5

# Minimal number of similar messages to show
SIMILAR_MESSAGES = 5

# Enable lazy commits
LAZY_COMMITS = True

Expand Down
5 changes: 0 additions & 5 deletions weblate/urls.py
Expand Up @@ -523,11 +523,6 @@
'trans.views.js.js_config',
name='js-config',
),
url(
r'^js/similar/(?P<unit_id>[0-9]+)/$',
'trans.views.js.get_similar',
name='js-similar',
),
url(
r'^js/translate/(?P<unit_id>[0-9]+)/$',
'trans.views.js.translate',
Expand Down

0 comments on commit e136e19

Please sign in to comment.