如何从NLTK调用NER以获取位于同一目录中的每个TXT文件的前200个字符的所有结果?
当我尝试这段代码时:
for filename in os.listdir(ebooksFolder):
fname, fextension = os.path.splitext(filename)
if (fextension == '.txt'):
newName = 'ner_' + filename
file = open(ebooksFolder + '\\' + filename)
rawFile = file.read()
partToUse = rawFile[:50]
segmentedSentences = nltk.sent_tokenize(partToUse)
tokenizedSentences = [nltk.word_tokenize(sent) for sent in segmentedSentences]
posTaggedSentences = [nltk.pos_tag(sent) for sent in tokenizedSentences]
nerResult = nltk.ne_chunk(posTaggedSentences)
pathToCopy = 'C:\\Users\\Felipe\\Desktop\\books_txt\\'
nameToSave = os.path.join(pathToCopy, newName + '.txt')
newFile = open(nameToSave, 'w')
newFile.write(nerResult)
newFile.close()
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
Traceback (most recent call last):
File …Run Code Online (Sandbox Code Playgroud) 我在以下结构的模块中有一个图像:vendor/myvendorname/mymodulename/assets/img/delete-icon.png
我需要<img>通过JavaScript向页面添加一个,并且它可能具有src指向该属性的属性delete-icon.png.
$("#delete").attr("src", "?");
Run Code Online (Sandbox Code Playgroud)
如果将图像放入Yii创建的资产目录中,如何引用该图像?获得这条道路的方法是什么?
现在我按如下方式访问CRM SDK
IServiceManagement<IDiscoveryService> serviceManagement =
ServiceConfigurationFactory.CreateManagement<IDiscoveryService>(discoveryUri);
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(userName, password, domain);
using (DiscoveryServiceProxy serviceProxy = new DiscoveryServiceProxy(new DiscoveryServiceProxy(serviceManagement, credentials))
{
RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
RetrieveOrganizationsResponse orgResponse =
(RetrieveOrganizationsResponse)service.Execute(orgRequest);
// do something with organisations
}
Run Code Online (Sandbox Code Playgroud)
但是,如果域凭据不正确,则会出现Windows登录提示(位于其中service.Execute).我不想要登录提示.我已经解决了这个问题,通过验证凭证,PrincipalContext然后再将它们传递给DiscoveryServiceProxy,但我对此并不完全满意.
有没有办法禁用登录提示?
public static void main(String[] args) {
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
String fileName = "C:/Users/Felipe/Desktop/workspace/JenaTutorial/ontrdf.rdf";
try {
InputStream inputStream = new FileInputStream(fileName);
model.read(inputStream, "RDF/XML");
inputStream.close();
} catch (Exception e) {
System.out.println(e.getClass());
System.out.println(e.getMessage());
}
ExtendedIterator<OntClass> it = model.listClasses();
while (itI.hasNext()) {
OntClass ontclass = it.next();
System.out.println(ontclass.getLocalName());
}
}
Run Code Online (Sandbox Code Playgroud)
我想仅列出我在本体上插入的真正的六个类(年份,出版商,语言,国家,书籍和作者).我不知道前六个意味着什么后面的那些线.有人知道如何过滤输出吗?
控制台显示:
Year
Publisher
Language
Country
Book
Author
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null …Run Code Online (Sandbox Code Playgroud) 我试图调用find()加载模型的函数,我得到以下错误:调用未定义函数find()
如果我可以打电话create()和save(),为什么find()不确定?
public function admin_upload() {
$this->layout = 'ajax';
$this->loadModel('TempImage');
$uploadedFileName = $_FILES['data']['name']['Staticpage']['main_image'];
$uploadedType = $_FILES['data']['type']['Staticpage']['main_image'];
$uploadedTmpFileName = $_FILES['data']['tmp_name']['Staticpage']['main_image'];
$uploadedError = $_FILES['data']['error']['Staticpage']['main_image'];
$uploadedSize = $_FILES['data']['size']['Staticpage']['main_image'];
$this->TempImage->create();
$imageData = array(
'name' => $uploadedFileName,
'type' => $uploadedType,
'tmp_name' => $uploadedTmpFileName,
'error' => $uploadedError,
'size' => $uploadedSize
);
$temporaryData = array(
'path' => $imageData
);
$this->TempImage->save($temporaryData);
$lastTempImageThumbPath = $this->TempImage-find(
'first',
array(
'conditions' => array(
'id' => $this->TempImage->getLastInsertID()
)
)
);
$this->set('thumb', $lastTempImageThumbPath['TempImage']['thumb_path']);
}
Run Code Online (Sandbox Code Playgroud) 有人知道如何<input type="file">通过Ajax调用获得价值吗?
代替:
// more...
function uploadFile(event) {
var file = event.target.files;
event.stopPropagation();
event.preventDefault();
var data = new FormData();
$.each(
file,
function(key, value) {
data.append(key, value);
}
);
$.ajax({
url: 'site/upload',
type: 'POST',
data: data,
// more...
Run Code Online (Sandbox Code Playgroud)
在uploadFile()被称为输入文件的变化.使用FormData对象的问题在于它在IE 10中不受支持.
我想删除产品名称上的链接,当单击购物车页面时该链接会重定向到产品页面。我尝试修改cart.php文件,但没有成功。我尝试修改这些行:
<td class="product-name">
<?php
if (! $_product->is_visible())
echo apply_filters('woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key);
else
echo apply_filters('woocommerce_cart_item_name', sprintf('<a href="%s">%s</a>', $_product->get_permalink(), $_product->get_title()), $cart_item, $cart_item_key);
// Meta data
echo WC()->cart->get_item_data($cart_item);
// Backorder notification
if ($_product->backorders_require_notification() && $_product->is_on_backorder($cart_item['quantity']))
echo '<p class="backorder_notification">' . __('Available on backorder', 'woocommerce') . '</p>';
?>
</td>
Run Code Online (Sandbox Code Playgroud)
对此代码进行正确修改以删除产品名称上的链接是什么?
php ×3
ajax ×1
c# ×1
cakephp ×1
html ×1
java ×1
javascript ×1
jena ×1
jquery ×1
nltk ×1
python-2.7 ×1
rdf ×1
wcf ×1
woocommerce ×1
yii-modules ×1
yii2 ×1