对不起如果我是菜鸟,我有这个疑问,为什么我们使用私有变量并使用属性设置它们?
为什么我们不能单独使用专业人士?
我在谈论这样的情况
private string _testVariable;
public string MyProperty
{
get { return _testVariable;}
set {_testVariable = value;}
}
Run Code Online (Sandbox Code Playgroud)
我在考虑简单地使用
public string MyProperty { get; set; }
Run Code Online (Sandbox Code Playgroud)
为什么冗余私有变量?这两种策略有什么不同?任何人都可以请注意这一点.
谢谢
当我尝试使用GMail SMTP通过Laravel发送电子邮件时,我遇到以下错误:
Swift_TransportException
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
Run Code Online (Sandbox Code Playgroud)
这是错误的痕迹:
...
}
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host ' . $this->_params['host'] .
' [' . $errstr . ' #' . $errno . ']'...
Run Code Online (Sandbox Code Playgroud)
这是我的邮件配置:
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'some@example.ir', 'name' => 'some'),
'encryption' => 'tls',
'username' => 'myemail@gmail.com', …
Run Code Online (Sandbox Code Playgroud) 在C#应用程序中,我需要检查算法的输出,该算法是针对另一个XML树的XML树,以查看它们是如何相似的.(节点顺序很重要,但结构(嵌套节点),节点名称更重要).也许数量adds
,removes
并moves
在一些"发生树编辑距离 "的算法是一个很好的指标.但答案是更多Java或Python包.
所以,我尝试使用XMLDiffPatch,当算法类型设置为时,它运行良好Precise
.但不好的是,它只是生成一个DiffGram
需要分析的文件来查找操作数.此外,它非常多,并OutOfRangeException
为一些XML树生成.为了我的目的,我也找不到更好的软件包.Net.有一些Xml差异包但可能没有或很少有Tree Edit Distance
.
一个例子:
<A>
<B>
<C></C>
<D></D>
<E>
<F>
</F>
</E>
</B>
</A>
Run Code Online (Sandbox Code Playgroud)
至:
<A>
<C></C>
<D></D>
<G></G>
</A>
Run Code Online (Sandbox Code Playgroud)
到第一个XML转换为第二,你需要删除E
和F
(2和成本),那么你需要删除B
(而不是其子树)和补充G
.然后总费用是4.
所以,正如我在这里所知,我不应该要求包和工具,我要求一个简单的算法或(.Net中的树编辑距离算法)来做到这一点.这是我自己的算法,用于检查相似性并忽略次要差异(具有一个或几个嵌套节点),但它是非常主要的,仅用于起点:
public int XMLCompare(XmlNode primary, XmlNode secondary)
{
int x = 0;
if (secondary == null || primary == null)
return 1;
if (secondary.ChildNodes.Count == 1 …
Run Code Online (Sandbox Code Playgroud) 当我尝试在IntelliJ中创建项目时,我在此行收到以下错误:
Sentence sent = new Sentence();
sent.emptySegments();
Run Code Online (Sandbox Code Playgroud)
错误:
Error:(151, 10) java: cannot access javax.xml.bind.RootElement
class file for javax.xml.bind.RootElement not found
Run Code Online (Sandbox Code Playgroud)
Sentence
是一个实现接口的类RootElement
import javax.xml.bind.RootElement;
...
public class Sentence extends MarshallableRootElement implements RootElement {
Run Code Online (Sandbox Code Playgroud)
所有包都存在,我可以跳转到每个接口或类的声明,但我不知道为什么IntellJ说它无法访问或找到它们?然而,它RootElement
是一个接口,而不是一个类
public interface RootElement extends Element {
void validate() throws StructureValidationException;
}
Run Code Online (Sandbox Code Playgroud)
上面的声明位于一个名为的jar文件中jaxb-rt-1.0-ea.jar
,它存在于Project Librarians中.
我正在尝试使用bootstrap Carousel延迟加载.看起来这应该是直截了当的,但我在这里甚至没有任何错误来排除故障.JS:
<script type="text/javascript">
$('#bigCarousel').on("slid", function() {
// load the next image after the current one slid
var $nextImage = $('.active.item', this).next('.item').find('img');
$nextImage.attr('src', $nextImage.data('lazy-load-src'));
});
</script>
Run Code Online (Sandbox Code Playgroud)
然后是html:
<div id="bigCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="assets/bigimage1.jpg" class="img-big">
</div>
<div class="item">
<img data-lazy-load-src="assets/menu-header2.jpg" class="img-big">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在firebug中没有JS错误或其他任何我能弄明白的错误,但我的图像只是没有加载.这可能是一件非常简单的事......
在C#的文本到语音应用程序中,我使用SpeechSynthesizer
类,它有一个名为的事件SpeakProgress
,每个语音都被触发.但是对于某些声音,参数e.AudioPosition
不与输出音频流同步,并且输出波形文件的播放速度比此位置显示的速度快(请参阅此相关问题).
无论如何,我试图找到有关比特率和与所选语音相关的其他信息的确切信息.正如我所经历的那样,如果我可以使用此信息初始化wave文件,则将解决同步问题.但是,如果我找不到这样的信息SupportedAudioFormat
,我知道找不到其他方法.例如,"Microsoft David Desktop"语音不提供支持的格式VoiceInfo
,但它似乎支持PCM 16000 hz,16位格式.
如何找到SpeechSynthesizer所选语音的音频格式
var formats = CurVoice.VoiceInfo.SupportedAudioFormats;
if (formats.Count > 0)
{
var format = formats[0];
reader.SetOutputToWaveFile(CurAudioFile, format);
}
else
{
var format = // How can I find it, if the audio hasn't provided it?
reader.SetOutputToWaveFile(CurAudioFile, format );
}
Run Code Online (Sandbox Code Playgroud) 我ToolStrip
在C#winform应用程序中使用a .
当我将鼠标移到按钮上时,它会突出显示(透明的蓝色),我想改变这种颜色
我尝试使用自定义渲染器类
toolStrip1.Renderer = new MyRenderer();
....
class MyRenderer : ToolStripProfessionalRenderer
{
}
Run Code Online (Sandbox Code Playgroud)
但是,我不知道应该覆盖哪种方法来改变这种颜色.
我尝试创建一个文本视频,其中文本通过文本到语音进行叙述.
要创建的视频文件,我用VideoFileWriter
的Aforge.Net
是以下几点:
VideoWriter = new VideoFileWriter();
VideoWriter.Open(CurVideoFile, (int)(Properties.Settings.Default.VideoWidth),
(int)(Properties.Settings.Default.VideoHeight), 25, VideoCodec.MPEG4, 800000);
Run Code Online (Sandbox Code Playgroud)
要大声朗读文本,我使用SpeechSynthesizer
类并将输出写入波流
AudioStream = new FileStream(CurAudioFile, FileMode.Create);
synth.SetOutputToWaveStream(AudioStream);
Run Code Online (Sandbox Code Playgroud)
我想突出显示视频中的单词,所以我通过SpeakProgress
事件同步它们:
void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)
{
curAuidoPosition = e.AudioPosition;
using (Graphics g = Graphics.FromImage(Screen))
{
g.DrawString(e.Text,....);
}
VideoWriter.WriteVideoFrame(Screen, curAuidoPosition);
}
Run Code Online (Sandbox Code Playgroud)
最后,我使用合并视频和音频 ffmpeg
using (Process process = new Process())
{
process.StartInfo.FileName = exe_path;
process.StartInfo.Arguments =
string.Format(@"-i ""{0}"" -i ""{1}"" -y -acodec copy -vcodec copy ""{2}""", avi_path, mp3_path, output_file);
// ...
}
Run Code Online (Sandbox Code Playgroud)
问题是,对于像微软Hazel,Zira和David这样的声音,在Windows 8.1中,视频与音频不同步,音频比显示的字幕快得多.但是,对于Windows …
我正在尝试加载一个导出的学习器,learn.export()
并且我想针对测试集运行它。我希望我的测试集有标签,以便我可以测量其准确性。
这是我的代码:
test_src = (TextList.from_df(df, path, cols='texts')
.split_by_rand_pct(0.1, seed=42)
.label_from_df(cols='recommend'))
learn_fwd = load_learner(path + '/fwd_learn_c',
test=test_src) #, tfm_y=False)
pred_fwd,lbl_fwd = learn_fwd.get_preds(ds_type=DatasetType.Test,ordered=True)
accuracy(pred_fwd, lbl_fwd)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误,它显然不接受带标签的数据集!
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-22-7f52f2136d8e> in <module>
6
7 learn_fwd = load_learner(path + '/fwd_learn_c',
----> 8 test=test_src) #, tfm_y=False)
9 learn_bwd = load_learner(path + '/bwd_learn_c',
10 test=test_src) #, tfm_y=test_src)
~/miniconda3/lib/python3.7/site-packages/fastai/basic_train.py in load_learner(path, file, test, tfm_y, **db_kwargs)
622 model = state.pop('model')
623 src = LabelLists.load_state(path, state.pop('data'))
--> 624 if test is not …
Run Code Online (Sandbox Code Playgroud) 使用.Net 3.5中的System.Speech.Synthesis.SpeechSynthesizer类,SpeakProgressEventArgs的AudioPosition属性似乎不准确.
以下代码生成以下输出:
码:
using System;
using System.Speech.Synthesis;
using System.Threading;
namespace SpeechTest
{
class Program
{
static ManualResetEvent speechDoneEvent = new ManualResetEvent(false);
static void Main(string[] args)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synthesizer_SpeakProgress);
synthesizer.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synthesizer_SpeakCompleted);
synthesizer.SetOutputToWaveFile("Test.wav");
synthesizer.SpeakAsync("This holiday season, support the music you love by shopping at Made in Washington, online and at one of five local stores. Made in Washington chocolates, bountiful gift baskets and ornaments are the perfect holiday gifts for family, friends …
Run Code Online (Sandbox Code Playgroud)