Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
deeplearning, dcp (2972240286315620591)
Browse files Browse the repository at this point in the history
Reviewed By: r-barnes

Differential Revision: D49677606

fbshipit-source-id: ec5b375177586c76ecccb83a29b562bc6e9961f6
  • Loading branch information
generatedunixname89002005287564 authored and facebook-github-bot committed Oct 4, 2023
1 parent 166ce2c commit 789e328
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion python/fasttext_module/fasttext/pybind/fasttext_pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ std::pair<std::vector<py::str>, std::vector<py::str>> getLineText(
} else if (type == fasttext::entry_type::label && wid >= 0) {
labels.push_back(castToPythonString(token, onUnicodeError));
}
if (token == fasttext::Dictionary::EOS)
if (token == fasttext::Dictionary::EOS) {
break;
}
}
return std::pair<std::vector<py::str>, std::vector<py::str>>(words, labels);
}
Expand Down
12 changes: 6 additions & 6 deletions src/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "args.h"

#include <stdlib.h>
#include <cstdlib>

#include <iostream>
#include <stdexcept>
Expand Down Expand Up @@ -106,7 +106,7 @@ std::string Args::metricToString(metric_name mn) const {
}

void Args::parseArgs(const std::vector<std::string>& args) {
std::string command(args[1]);
const std::string& command(args[1]);
if (command == "supervised") {
model = model_name::sup;
loss = loss_name::softmax;
Expand Down Expand Up @@ -401,13 +401,13 @@ metric_name Args::getAutotuneMetric() const {
} else if (autotuneMetric == "f1") {
return metric_name::f1score;
} else if (autotuneMetric.substr(0, 18) == "precisionAtRecall:") {
size_t semicolon = autotuneMetric.find(":", 18);
size_t semicolon = autotuneMetric.find(':', 18);
if (semicolon != std::string::npos) {
return metric_name::precisionAtRecallLabel;
}
return metric_name::precisionAtRecall;
} else if (autotuneMetric.substr(0, 18) == "recallAtPrecision:") {
size_t semicolon = autotuneMetric.find(":", 18);
size_t semicolon = autotuneMetric.find(':', 18);
if (semicolon != std::string::npos) {
return metric_name::recallAtPrecisionLabel;
}
Expand All @@ -424,7 +424,7 @@ std::string Args::getAutotuneMetricLabel() const {
} else if (
metric == metric_name::precisionAtRecallLabel ||
metric == metric_name::recallAtPrecisionLabel) {
size_t semicolon = autotuneMetric.find(":", 18);
size_t semicolon = autotuneMetric.find(':', 18);
label = autotuneMetric.substr(semicolon + 1);
} else {
return label;
Expand All @@ -444,7 +444,7 @@ double Args::getAutotuneMetricValue() const {
metric == metric_name::recallAtPrecisionLabel ||
metric == metric_name::recallAtPrecision) {
size_t firstSemicolon = 18; // semicolon position in "precisionAtRecall:"
size_t secondSemicolon = autotuneMetric.find(":", firstSemicolon);
size_t secondSemicolon = autotuneMetric.find(':', firstSemicolon);
const std::string valueStr =
autotuneMetric.substr(firstSemicolon, secondSemicolon - firstSemicolon);
value = std::stof(valueStr) / 100.0;
Expand Down

0 comments on commit 789e328

Please sign in to comment.