为什么我的chdir文件句柄在Perl中不起作用?(Why does my chdir to a filehandle not work in Perl?)
当我以文件句柄作为参数尝试“chdir”时,“chdir”返回0,并且
pwd
仍然返回相同的目录。 应该是这样吗?我试过这个,因为在chdir的文档中我发现:
“在支持fchdir的系统上,可能会传递文件句柄或目录句柄作为参数,在不支持fchdir的系统上,传递句柄会在运行时产生致命错误。”
稍后给出:
#!/usr/bin/perl -w use 5.010; use strict; use Cwd; say cwd(); # /home/mm open( my $fh, '>', '/home/mm/Documents/foto.jpg' ) or die $!; say chdir $fh; # 0 say cwd(); # /home/mm
我认为这可能是chdir到文件的目录 - 但在这里没有DWIM。
When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a
pwd
returns still the same directory. Should that be so?I tried this, because in the documentation to chdir I found:
"On systems that support fchdir, you might pass a file handle or directory handle as argument. On systems that don't support fchdir, passing handles produces a fatal error at run time."
Given later:
#!/usr/bin/perl -w use 5.010; use strict; use Cwd; say cwd(); # /home/mm open( my $fh, '>', '/home/mm/Documents/foto.jpg' ) or die $!; say chdir $fh; # 0 say cwd(); # /home/mm
I thought that this would maybe chdir to the directory of the file - but no DWIM for me here.
原文:https://stackoverflow.com/questions/1730434
满意答案
他们可能会使用信息提取技术。
以下是斯坦福大学SUST工具的演示:
http://nlp.stanford.edu:8080/sutime/process
您将在文档中提取关于n-gram(连续词)的属性:
- numberOfLetters
- numberOfSymbols
- 长度
- previousWord
- nextWord
- nextWordNumberOfSymbols
...然后使用分类算法,并提供正,负的例子:
Observation nLetters nSymbols length prevWord nextWord isPartOfDate "Feb." 3 1 4 "Wed" "29th" TRUE "DEC" 3 0 3 "company" "went" FALSE ...
你可能会有50个例子,但越多越好。 然后,该算法基于这些示例学习,并且可以应用于以前未见过的未来示例。
它可能会学习诸如
- 如果以前的单词只是字符,也可能是...
- 现在的词是“二月”,“马尔”,“...”
- 下一个单词在“第十二”,any_number ...
- 那么是日期
这是Google工程师就此题材播放的体面视频
They likely use Information Extraction techniques for this.
Here is a demo of Stanford's SUTime tool:
http://nlp.stanford.edu:8080/sutime/process
You would extract attributes about n-grams (consecutive words) in a document:
- numberOfLetters
- numberOfSymbols
- length
- previousWord
- nextWord
- nextWordNumberOfSymbols
...And then use a classification algorithm, and feed it positive and negative examples:
Observation nLetters nSymbols length prevWord nextWord isPartOfDate "Feb." 3 1 4 "Wed" "29th" TRUE "DEC" 3 0 3 "company" "went" FALSE ...
You might get away with 50 examples of each, but the more the merrier. Then, the algorithm learns based on those examples, and can apply to future examples that it hasn't seen before.
It might learn rules such as
- if previous word is only characters and maybe periods...
- and current word is in "february", "mar.", "the" ...
- and next word is in "twelfth", any_number ...
- then is date
Here is a decent video by a Google engineer on the subject
相关问答
更多LINUX 如何查看JPG文件
Ruby:Cc地址的电子邮件丢失了(Ruby: Emails go missing for Cc addresses)
苹果如何在电子邮件中找到日期,时间和地址?(How does Apple find dates, times and addresses in emails?)
我应该如何安排我的模型和cron rake任务以不同开始日期的间隔发送电子邮件?(How should I arrange my models and cron rake task to send emails on intervals with different start dates?)
使用scrapy查找正文中的电子邮件地址(Finding email addresses in body using scrapy)
验证多重电子邮件地址(validation for multipe email addresses)
Apple的iCloud阻止来自我网站的电子邮件(Apple's iCloud blocking emails from my website)
从Thunderbird电子邮件中提取电子邮件地址(Extract Email Address from Thunderbird Emails)
Excel查找并替换除电子邮件地址以外的所(Excel find and replace everything except email addresses?)
如何读取传入电子邮件的IP地址(How to read ip address of the incoming emails)
相关文章
更多Script.NET Perl解释器代码已经在GitHub开源发布
RabbitMQ Work模式消息队列
Don’t work. Be hated. Love someone.
[转]So You Want To Be A Producer
Becoming a data scientist
She’s Not Carrying A Handbag
ServletOutputStream cannot be resolved to a type
Book Report: THE SOUL OF A NEW MACHINE
How to Start a Business in 10 Days
Solr: a custom Search RequestHandler
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!