mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	New visualizations for frequencies
This commit is contained in:
		@@ -7,6 +7,8 @@ from app.decorators import content_negotiation
 | 
			
		||||
from app.models import Corpus, CorpusFollowerRole
 | 
			
		||||
from . import bp
 | 
			
		||||
from .decorators import corpus_follower_permission_required, corpus_owner_or_admin_required
 | 
			
		||||
import nltk
 | 
			
		||||
from string import punctuation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/<hashid:corpus_id>', methods=['DELETE'])
 | 
			
		||||
@@ -56,6 +58,27 @@ def build_corpus(corpus_id):
 | 
			
		||||
    }
 | 
			
		||||
    return response_data, 202
 | 
			
		||||
 | 
			
		||||
@bp.route('/stopwords')
 | 
			
		||||
@content_negotiation(produces='application/json')
 | 
			
		||||
def get_stopwords():
 | 
			
		||||
    # data = request.json
 | 
			
		||||
    # if not isinstance(data, dict):
 | 
			
		||||
    #     abort(400)
 | 
			
		||||
    # language = data.get('language')
 | 
			
		||||
    # if not isinstance(language, str):
 | 
			
		||||
    #     abort(400)
 | 
			
		||||
    nltk.download('stopwords')
 | 
			
		||||
    languages = ["german", "english", "catalan", "greek", "spanish", "french", "italian", "russian", "chinese"]
 | 
			
		||||
    stopwords = {}
 | 
			
		||||
    for language in languages:
 | 
			
		||||
        stopwords[language] = nltk.corpus.stopwords.words(language)
 | 
			
		||||
    stopwords['punctuation'] = list(punctuation) + ['—', '|']
 | 
			
		||||
    stopwords['user_stopwords'] = []
 | 
			
		||||
    print(stopwords)
 | 
			
		||||
    response_data = {
 | 
			
		||||
        'stopwords': stopwords
 | 
			
		||||
    }
 | 
			
		||||
    return response_data, 202
 | 
			
		||||
 | 
			
		||||
# @bp.route('/<hashid:corpus_id>/generate-share-link', methods=['POST'])
 | 
			
		||||
# @corpus_follower_permission_required('MANAGE_FOLLOWERS')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user