我有一个简单的设置似乎不会在 angular.module('qms').controller('companiesController', ['$scope', '$log', 'companiesService', '$state', '$stateParams', 'uiFactory', '$transitions',
function ($scope, $log, companiesService, $state, $stateParams, uiFactory, $transitions) {
var init = function () {
$transitions.onStart({}, function (trans) {
var toState = trans.$to();
$log.log('transitioning', toState);
uiFactory.setUi(toState, $scope);
});
}
init();
}]);
转换挂钩上触发。
1.0.6
我仔细检查了我的ui路由器版本(1.6.6
)是否与角度版本angular.module('qms', ['ui.router', 'angularValidator'])
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/companies');
var basePath = '/js/angular';
$stateProvider.state('companies', {
url: '/companies',
templateUrl: basePath + '/views/company/home.html',
controller: 'companiesController'
})
.state('company.create', {
url: '/company/create',
templateUrl: basePath + '/views/company/create.html',
controller: 'companiesCreateController'
})
}]);
配合使用。
我还检查过以确保在初始状态加载时触发转换,并根据它们执行的文档here。我没有收到任何错误,我的控制器正在初始化。这也是我的状态设置:
from spacy.en import English
import re
LABELS = {
'ENT': 'ENT',
'PERSON': 'ENT',
'NORP': 'ENT',
'FAC': 'ENT',
'ORG': 'ENT',
'GPE': 'ENT',
'LOC': 'ENT',
'LAW': 'ENT',
'PRODUCT': 'ENT',
'EVENT': 'ENT',
'WORK_OF_ART': 'ENT',
'LANGUAGE': 'ENT',
'DATE': 'DATE',
'TIME': 'TIME',
'PERCENT': 'PERCENT',
'MONEY': 'MONEY',
'QUANTITY': 'QUANTITY',
'ORDINAL': 'ORDINAL',
'CARDINAL': 'CARDINAL'
}
nlp = False;
def tag_words_in_sense2vec_format(passage):
global nlp;
if(nlp == False): nlp = English()
if isinstance(passage, str): passage = passage.decode('utf-8',errors='ignore');
doc = nlp(passage);
return transform_doc(doc);
def transform_doc(doc):
for index, ent in enumerate(doc.ents):
ent.merge(ent.root.tag_, ent.text, LABELS[ent.label_])
#if index % 100 == 0: print ("enumerating at entity index " + str(index));
#for np in doc.noun_chunks:
# while len(np) > 1 and np[0].dep_ not in ('advmod', 'amod', 'compound'):
# np = np[1:]
# np.merge(np.root.tag_, np.text, np.root.ent_type_)
strings = []
for index, sent in enumerate(doc.sents):
if sent.text.strip():
strings.append(' '.join(represent_word(w) for w in sent if not w.is_space))
#if index % 100 == 0: print ("converting at sentence index " + str(index));
if strings:
return '\n'.join(strings) + '\n'
else:
return ''
def represent_word(word):
if word.like_url:
return '%%URL|X'
text = re.sub(r'\s', '_', word.text)
tag = LABELS.get(word.ent_type_, word.pos_)
if not tag:
tag = '?'
return text + '|' + tag
在转换工作中,我还缺少其他任何步骤吗?
似乎转换不会像文档声明那样触发初始应用程序加载。我在这里创建了一个plnkr以显示效果。只需打开一个控制台并查看日志:
https://plnkr.co/edit/OwvQS0nErcCwvWEKbtZc?p=preview
我会看看是否可以解决问题。