小编555*_*597的帖子

语音搜索印度语

我想在我的Android应用程序中以语音方式比较字符串.但这里的特例是,我想比较用英语写的印度语单词.例如,我想检查"Edhu""Adhu""Yethu"在语音上是否相等,它们在泰米尔语中都是相同的.但是使用英文脚本来写印度语的人使用不同的拼写来表达这个词.在这种情况下如何比较单词?

我试过了Levenshtein.但我不知道如何将它返回的数字转换为相等.

我尝试了Soundex,当这个词的第一个字母发生变化时,Soundex代码就不一样了.但它能够找出类似的声音部分.我不明白它是如何工作的.

 soundex.encode("Yethu")  (soundex.encode("Edhu"))  (soundex.encode("adhu")) 
 Y300                       E300                       A300
Run Code Online (Sandbox Code Playgroud)

java android soundex apache-commons phonetics

21
推荐指数
1
解决办法
827
查看次数

RecyclerView元素更新+异步网络调用

我有一个按预期工作的recyclerview.我在布局中有一个填充列表的按钮.该按钮应该进行异步调用,结果,我改变按钮的外观.这一切都很好.

但是,当我单击按钮并快速向下滚动列表时,异步调用的结果将更新新视图的按钮(代替旧视图的视图).我该如何处理?我可以处理特定视图何时被重用?

更新:

执行异步调用和ui更新的适配器类的代码段.

@Override
public void onBindViewHolder(CommentsViewHolder holder, int position) {
    try {

        Comments comment = comments.get(position);
        holder.bindView(comment,position);

    }
    catch(Exception ex){ex.printStackTrace();}

}

@Override
public int getItemCount() {
    if(comments==null)
    {return 0;}
    return comments.size();
    //return comments.length();
}



public class CommentsViewHolder extends RecyclerView.ViewHolder {
    TextView score ;

    TextView commentText;
    TextView commentTime;
    TextView avatarId;
    ImageButton minusOne;
    ImageButton plusOne;
    ParseObject model;

    public CommentsViewHolder(View itemView) {
        super(itemView);
        //itemView.setBackgroundColor(Color.DKGRAY);
        minusOne =(ImageButton)itemView.findViewById(R.id.decScore);
        plusOne =(ImageButton)itemView.findViewById(R.id.incScore);
        commentText = (TextView)itemView.findViewById(R.id.comment);
        score = (TextView)itemView.findViewById(R.id.commentScore);
        commentTime =(TextView)itemView.findViewById(R.id.commentTime);
        avatarId = (TextView)itemView.findViewById(R.id.ivUserAvatar);
    }
    public …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

17
推荐指数
2
解决办法
6384
查看次数

Chrome远程桌面和Android模拟器

我远程(chrome远程)到我运行android studio的桌面.当我尝试从android studio运行模拟器时,我看到打开虚拟设备的窗口.但该设备无法启动.当我直接使用桌面来运行android项目时,这不是行为.这种行为可能是因为远程操作吗?如果是这样,我该怎么改呢?

我需要在远程连接上使用android studio,如果有办法实现它,请提出建议.

这是AVD日志

    C:\Users\xxx\AppData\Local\Android\sdk\tools\emulator.exe -avd Nexus_5_API_21 -netspeed full -netdelay none

emulator: device fd:1228

HAX is working and emulator runs in fast virt mode

creating window 61 83 462 820
Run Code Online (Sandbox Code Playgroud)

logcat的

    04-29 12:06:39.077    1966-1966/com.example.xxx.four4 E/libprocessgroup? failed to make and chown /acct/uid_10053: Read-only file system
04-29 12:06:39.077    1966-1966/com.example.xxx.four4 W/Zygote? createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
04-29 12:06:39.078    1966-1966/com.example.xxx.four4 I/art? Not late-enabling -Xcheck:jni (already on)
04-29 12:06:39.183    1966-1986/com.example.xxx.four4 D/OpenGLRenderer? Render dirty regions requested: true
04-29 12:06:39.186    1966-1966/com.example.xxx.four4 D/? HostConnection::get() New Host …
Run Code Online (Sandbox Code Playgroud)

remote-desktop android-studio teamviewer

9
推荐指数
1
解决办法
2154
查看次数

RecyclerView ambiguos setVisibility函数,单击一个视图会影响多个视图

这是我想要运行的项目.这是我在RecyclerView.Adapter类中的onBindViewHolder的代码

@Override
    public void onBindViewHolder(ViewHolder holder, final int position) {

        TextView title = (TextView) holder.view.findViewById(R.id.title);
        final TextView desc = (TextView) holder.view.findViewById(R.id.desc);
        final ImageView imageView = (ImageView) holder.view.findViewById(R.id.imageView);

        title.setText(pojos.get(position).getTitle());
        desc.setText(pojos.get(position).getDesc());

        imageView.setImageResource(pojos.get(position).getImage());

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                desc.setText("clicked");
                desc.setBackgroundColor(Color.BLUE);
                imageView.setImageResource(R.drawable.heart_red);
            }
        });

    }
Run Code Online (Sandbox Code Playgroud)

列表加载正常,问题发生在调用imageView的onclicklistener时.

desc.setText("clicked");
Run Code Online (Sandbox Code Playgroud)

上面的行在单击它的列表项中进行更改.但

 desc.setBackgroundColor(Color.BLUE);
Run Code Online (Sandbox Code Playgroud)

执行此行时,更改将反映在列表中的多个项目中.出了什么问题?在下面显示的图片中,我点击了第0项,文本变为"点击"并设置了颜色.但是当我向下滚动时,项目12也受到了我对项目0的点击的影响.仅反映了背景颜色变化,而不是文本更改.我怎么阻止这个?

在此输入图像描述

在此输入图像描述

我一直试图解决这个问题很长时间,请下载项目并尝试执行代码以了解我的意思,如果我的问题不明确.

android listview textview android-imageview android-recyclerview

9
推荐指数
2
解决办法
6820
查看次数

SaveAllInBackground根据需要在deleteAllInBackground中不起作用

SaveAllInBackground根据需要在deleteAllInBackground中不起作用.

我正在尝试使用后台全部保存来保存一个parseobjects列表.为了避免表中的重复,我正在查询已存在的行并删除它们(如果有)然后保存新副本.因此我在deleteAllInBackground的回调中调用saveAllInBackground.

问题是这样的:

例如:如果要删除的列表包含[a,b,c,d],并且要上传的列表包含[a,b,c,d,e,f],则只有[e,f]才能进行解析.我将[a,b,c,d,e,f]传递给saveAllInBackground但只保留了[e,f].

  • 有什么我想念的吗?怎么解决这个?

  • 我可以使用不同的方法吗?

  • 有没有更好的方法来避免重复?我不想添加一个beforeSave钩子.调用saveAll的全部目的是减少API调用的数量.我想如果我使用beforeSave,我将不得不在云代码中运行一些查询.

这是我的代码

            ParseQuery query = new ParseQuery("PostChoice");

            query.fromPin();
            query.findInBackground(new FindCallback<ParseObject>() {
                @Override
                public void done(final List<ParseObject> localList, ParseException e) {
                    if (localList != null && !localList.isEmpty()) {
                        List<ParseObject> postList = new ArrayList<ParseObject>();
                        for (ParseObject object : localList) {

                            postList.add(object.getParseObject("post"));
                        }
                        ParseQuery query = new ParseQuery("PostChoice");
                        query.whereContainedIn("post", postList);
                        query.whereEqualTo("user", ParseUser.getCurrentUser());
                        query.findInBackground(new FindCallback<ParseObject>() {
                            @Override
                            public void done(List<ParseObject> parseCloudList, ParseException e) {

                                if (parseCloudList != null && !parseCloudList.isEmpty()) {
                                    ParseObject.deleteAllInBackground(parseCloudList, new DeleteCallback() {
                                        @Override
                                        public void …
Run Code Online (Sandbox Code Playgroud)

android parse-platform

7
推荐指数
1
解决办法
331
查看次数

PhoneGap Parse JS注销函数返回404

我正在开发PhoneGap + Parse应用程序.

我有一个登录页面和一个注销按钮.我在注销按钮上单击调用以下代码.

$('#signout').click(function(event){
  $(":mobile-pagecontainer").pagecontainer("change", "#signin", { reload:true, transition:'flow', changeHash:true });

  Parse.User.logOut();
  console.log('logged out');

});
Run Code Online (Sandbox Code Playgroud)

我在浏览器控制台中收到以下消息.

POST http://192.168.2.2:3000/proxy/https%3A%2F%2Fapi.parse.com%2F1%2Flogin 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

这是什么意思?注销功能正常工作应该纠正什么?

javascript cordova parse-platform

6
推荐指数
1
解决办法
191
查看次数

如何以编程方式将文件从内部存储器移动到 android 中的 sdcard?

如何在android中将文件从设备的内部存储器移动到外部存储器?请提供代码示例。我的代码在下面

    private void moveFile(File file, File dir) throws IOException {
    File newFile = new File(dir, file.getName());
    FileChannel outputChannel = null;
    FileChannel inputChannel = null;
    try {
        outputChannel = new FileOutputStream(newFile).getChannel();
        inputChannel = new FileInputStream(file).getChannel();
        inputChannel.transferTo(0, inputChannel.size(), outputChannel);
        inputChannel.close();
        file.delete();
    } finally {
        if (inputChannel != null) inputChannel.close();
        if (outputChannel != null) outputChannel.close();
    }

}
Run Code Online (Sandbox Code Playgroud)

android file move

5
推荐指数
1
解决办法
4034
查看次数

mongodb mongoose连接打开回调没有被调用

我有一个MEAN项目,这是我的server.js的一个片段

var db = require('./config/db');
// url : 'mongodb://localhost/cdnserver'
// results are same for 127.0.0.1 or the machines ip
console.log(mongoose.connect(db.url));

mongoose.set('debug', true);
mongoose.connection.on('connected', function () {
  console.log('Mongoose default connection open to ' + db.url);
});

// If the connection throws an error
mongoose.connection.on('error',function (err) {
  console.log('Mongoose default connection error: ' + err);
});

// When the connection is disconnected
mongoose.connection.on('disconnected', function () {
  console.log('Mongoose default connection disconnected');
});
Run Code Online (Sandbox Code Playgroud)

这个设置现在已经运行了3个多月.现在我将我的整个MEAN堆栈与数据库一起复制到其他机器.我拿了一个mongodump并做了mongorestore.通过终端的mongo恢复数据库设置看起来很好.

但是,启动服务器时,不会调用connection-open回调.如果我停止mongodb服务,则会调用断开连接和错误回调.我该如何进一步调试?

我从两个设置附加控制台输出.

设置1:

    Mongoose {
  connections:
   [ …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb mean-stack

5
推荐指数
1
解决办法
484
查看次数

Python OpenCV cv2绘制带有文本的矩形

我使用以下方法在图像上绘制一个矩形

cv2.rectangle(frame,(x,y),(x1,y1),(0,255,0),2)
Run Code Online (Sandbox Code Playgroud)

我想绘制带有文本信息的矩形。我该怎么做?是否有任何可用的现成实现?还是应该匹配矩形的左上角坐标,并尝试使用cv2 rect元素显示不同的cv2文本元素?

您能指导我执行任何代码实现/解决方法吗?

PS:我不想使用object_detection。TF提供的可视化工具。

在此处输入图片说明

python opencv

3
推荐指数
3
解决办法
2316
查看次数

如何保存和重用语义分割结果?

我使用detectorron2对图像运行语义分割。Detectron2 具有用于可视化结果的预构建函数。我有兴趣保存分割结果并在需要时解析它们。于是我回溯代码,发现instances_to_coco_json函数就是输出分割结果的函数。我尝试保存结果。

结果采用以下格式:

 {
        "image_id": 1, 
        "segmentation": {
            "counts": "R[W<=Sf0001O000000000000000000000000000000000000000^_\\?", 
            "size": [
                720, 
                1280
            ]
        }, 
        "category_id": 1, 
        "score": 0.992115
    }, 
Run Code Online (Sandbox Code Playgroud)

我期望得到分割结果作为分割点的坐标,如下所示:

 "segmentation": [
            [
                662.1764705882352, 
                387, 
                686, 
                386.5882352941176, 
                686, 
                398, 
                662.7647058823529, 
                399
            ]
Run Code Online (Sandbox Code Playgroud)

鉴于输出是 coco 格式,我如何理解它?

computer-vision image-segmentation semantic-segmentation

2
推荐指数
1
解决办法
4416
查看次数