예제 #1
0
 def setUpClass(self):
     # Fake models! Only made so we can do unittests
     vm = shVM('tests/w2vModels/*.w2v', useCache=False)
     results, links = vm.trackClouds('x')
     agg = shVA(yearsInInterval=1)
     aggResults, aggMetadata = agg.aggregate(results)
     self.embedded = doSpaceEmbedding(vm, results, aggMetadata)
예제 #2
0
파일: app.py 프로젝트: NLeSC/ShiCo
def trackWord(terms):
    '''VocabularyMonitor.trackClouds service. Expects a list of terms to be
    sent to the Vocabulary monitor, and returns a JSON representation of the
    response.'''
    params = app.config['trackParser'].parse_args()
    termList = terms.split(',')
    termList = [ term.strip() for term in termList ]
    termList = [ term.lower() for term in termList ]
    results, links = \
        app.config['vm'].trackClouds(termList, maxTerms=params['maxTerms'],
                        maxRelatedTerms=params['maxRelatedTerms'],
                        startKey=params['startKey'],
                        endKey=params['endKey'],
                        minSim=params['minSim'],
                        wordBoost=params['wordBoost'],
                        forwards=params['forwards'],
                        sumSimilarity=params['boostMethod'],
                        algorithm=params['algorithm'],
                        cleaningFunction=app.config['cleaningFunction'] if params[
                            'doCleaning'] else None
                        )
    agg = VocabularyAggregator(weighF=params['aggWeighFunction'],
                               wfParam=params['aggWFParam'],
                               yearsInInterval=params['aggYearsInInterval'],
                               nWordsPerYear=params['aggWordsPerYear']
                               )

    aggResults, aggMetadata = agg.aggregate(results)
    embedded = doSpaceEmbedding(app.config['vm'], results, aggMetadata)
    networks = yearlyNetwork(aggMetadata, aggResults, results, links)
    return jsonify(stream=yearTuplesAsDict(aggResults),
                   networks=networks,
                   embedded=embedded,
                   vocabs=links)
예제 #3
0
파일: app.py 프로젝트: JosedeKruif/ShiCo
def trackWord(terms):
    '''VocabularyMonitor.trackClouds service. Expects a list of terms to be
    sent to the Vocabulary monitor, and returns a JSON representation of the
    response.'''
    params = app.config['trackParser'].parse_args()
    termList = terms.split(',')
    termList = [term.strip() for term in termList]
    termList = [term.lower() for term in termList]
    results, links = \
        app.config['vm'].trackClouds(termList, maxTerms=params['maxTerms'],
                        maxRelatedTerms=params['maxRelatedTerms'],
                        startKey=params['startKey'],
                        endKey=params['endKey'],
                        minSim=params['minSim'],
                        wordBoost=params['wordBoost'],
                        forwards=params['forwards'],
                        sumSimilarity=params['boostMethod'],
                        algorithm=params['algorithm'],
                        cleaningFunction=app.config['cleaningFunction'] if params[
                            'doCleaning'] else None
                        )
    agg = VocabularyAggregator(weighF=params['aggWeighFunction'],
                               wfParam=params['aggWFParam'],
                               yearsInInterval=params['aggYearsInInterval'],
                               nWordsPerYear=params['aggWordsPerYear'])

    aggResults, aggMetadata = agg.aggregate(results)
    embedded = doSpaceEmbedding(app.config['vm'], results, aggMetadata)
    networks = yearlyNetwork(aggMetadata, aggResults, results, links)
    return jsonify(stream=yearTuplesAsDict(aggResults),
                   networks=networks,
                   embedded=embedded,
                   vocabs=links)
예제 #4
0
 def setUpClass(self):
     # Fake models! Only made so we can do unittests
     vm = shVM('tests/w2vModels/*.w2v', useCache=False)
     results, links = vm.trackClouds('x')
     agg = shVA(yearsInInterval=1)
     aggResults, aggMetadata = agg.aggregate(results)
     self.embedded = doSpaceEmbedding(vm, results, aggMetadata)