为什么我的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文件[2022-06-13]
find -
你最好使用“actionmailer”或“mail”宝石。 两者都有很好的文档。 https://github.com/rails/rails/tree/master/actionmailer https://github.com/mikel/mail I ended up dropping the use of mailfactory to try mail instead, but I hit an issue not covered in the documentation. The doc-base ...
-
他们可能会使用信息提取技术。 以下是斯坦福大学SUST工具的演示: http://nlp.stanford.edu:8080/sutime/process 您将在文档中提取关于n-gram(连续词)的属性: numberOfLetters numberOfSymbols 长度 previousWord nextWord nextWordNumberOfSymbols ... 然后使用分类算法,并提供正,负的例子: Observation nLetters nSymbols length prevWo ...
-
我还建议使用delayed_job来处理电子邮件的发送。 通过delayed_job,您将拥有一个包含相关时间的任务队列。 它允许您在将来的特定时间安排任务。 这可能比使用cron更方便。 就调度而言,它看起来像电子邮件在电话完成之前不会被发送,因此队列中的电子邮件条目应该在应用程序被通知完成呼叫时创建。 日期计算应该像Time.now + 4.days一样简单。 如果在电子邮件发送前有多个电话需要完成,那么在将电子邮件发送到队列中之前,您只需检查是否已完成所有呼叫。 I would also sugges ...
-
您可以在response.body上使用正则表达式搜索来查找电子邮件ID。 emails = re.findall(r'[\w\.-]+@[\w\.-]+', response.body) You can use a regular expression search on the response.body to find email ids. emails = re.findall(r'[\w\.-]+@[\w\.-]+', response.body)
-
1)您可以使用简单的正则表达式来检查电子邮件字段的值。 有许多正则表达式可以起作用,从最宽松的到最复杂的。 人们通常倾向于使用这样的东西: unless email =~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/ puts "Your email address does not appear to be valid") 这个正则表达式可能会传递一些无效的电子 ...
-
为我们服务器的IP地址添加了反向DNS条目,并从Apple的黑名单中取出服务器的IP地址。 Had a reverse DNS entry added for our server's IP address, and got the server's IP address taken off of Apple's blacklist.
-
正则表达式诞生于此类工作。 这是一个最小的控制台应用程序,它显示了如何使用RegEx从一个长文本块中提取所有电子邮件地址: program Project25; {$APPTYPE CONSOLE} uses SysUtils, PerlRegex; var PR: TPerlRegEx; TestString: string; begin // Initialize a test string to include some email addresses. This would ...
-
你可以使用这个公式: =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),FIND("@",SUBSTITUTE(A1," ",REPT(" ",99)))-99,198)) You could use this formula: =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),FIND("@",SUBSTITUTE(A1," ",REPT(" ",99)))-99,198))
-
$mailinfo = imap_headerinfo($inbox, $emails[$x]); print_r($mailinfo->from); 应该给你: personal, adl, mailbox, and host 以下任何一项应该可以帮助你$ mailinfo - > ... : (如需完整参考,请查看http://php.net/manual/en/function.imap-headerinfo.php ) ->to - an array of objects from the To: ...