Comments (6)
Вот в этой опубликованной папке в архиве NMT1.7z лежат некоторые скрипты.
Вроде как главный из них это train.sh
#!/bin/bash
if [ "$#" -ne 4 ]; then
echo "Illegal number of parameters"
fi
MSGVSIZE=$1
DIFFVSIZE=$2
VALIDSIZE=$3
TRAINSIZE=$4
echo "dictionaries data/vocab.diff.$DIFFVSIZE.json data/vocab.msg.$MSGVSIZE.json"
echo "model models/model.$TRAINSIZE.$MSGVSIZE.$DIFFVSIZE.npz"
echo "train datasets: data/train.$TRAINSIZE.diff data/train.$TRAINSIZE.msg"
echo "valid datasets: data/valid.$VALIDSIZE.diff data/valid.$VALIDSIZE.msg"
# check https://github.com/rsennrich/wmt16-scripts/tree/master/sample
python ../nematus/nmt.py \
--model models/model.$TRAINSIZE.$MSGVSIZE.$DIFFVSIZE.npz \
--dim_word 512 \
--dim 1024 \
--n_words_src $DIFFVSIZE \
--n_words $MSGVSIZE \
--decay_c 0 \
--clip_c 1 \
--lrate 0.0001 \
--optimizer adadelta \
--maxlen 400 \
--batch_size 80 \
--valid_batch_size 80 \
--datasets data/train.$TRAINSIZE.diff data/train.$TRAINSIZE.msg \
--valid_datasets data/valid.$VALIDSIZE.diff data/valid.$VALIDSIZE.msg \
--dictionaries data/vocab.diff.$DIFFVSIZE.json data/vocab.msg.$MSGVSIZE.json \
--validFreq 10000 \
--dispFreq 1000 \
--saveFreq 30000 \
--sampleFreq 10000 \
--dropout_embedding 0.2 \
--dropout_hidden 0.2 \
--dropout_source 0.1 \
--dropout_target 0.1 \
--no_shuffle \
--external_validation_script "./validate.sh $VALIDSIZE $TRAINSIZE $MSGVSIZE $DIFFVSIZE"
который просто вызывает nematus/nmt.py со своими параметрами.
Нашла этот репозиторий, в котором есть папка нематус с файлом nmt.py (линкой на файл train.py)
from gcm.
Как они обрабатывают данные:
не поняла, как именно нужно подавать данные в сеть, судя по всему source и target лежат в разных файлах.
Вот здесь лежат данные статьи, здесь в папочке logs/generated_data лежат данные предшественника.
Messages
почему-то в msg нет какого-либо препроцессинга данных, специфичного для кода (сплитинг camelCase-a)
Diffs
простой токенизатор всего, что только можно
переход на новую строчку обозначается <nl>
Код для обработки git diff
:
import re
import sys
def tokenize_line(line):
line = re.sub(r'(\w)(?=[^a-zA-Z0-9_ ])', r'\1 ', line)
line = re.sub(r'([^a-zA-Z0-9_ ])(?=\w)', r'\1 ', line)
line = re.sub(r'([^a-zA-Z0-9_ ])(?=[^a-zA-Z0-9_ ])', r'\1 ', line)
tokens = line.split()
line = ' '.join(tokens)
return line, len(tokens)
def tokenize(buffer):
too_long_diff_threshold = 100
too_long_line_threshold = 200
if (len(buffer) > too_long_diff_threshold):
return '\n'
res = ''
tokens = 0
for line in buffer:
if (re.match(r'diff --git', line) is not None):
continue
if (re.match(r'index \w{12}\.\.\w{12} \d{6}', line) is not None):
continue
line = re.sub(r'@@.*?@@', r'', line)
line = re.sub(r'---', r'mmm', line)
line = re.sub(r'\+\+\+', r'ppp', line)
line, token_cnt = tokenize_line(line)
tokens += token_cnt
if (line != ''):
res += line
res += ' <nl> '
if (tokens > too_long_line_threshold):
return '\n'
res += '\n'
return res
from gcm.
Прогон данных через скрипт:
Был такой diff
diff --git a/Aurora/tools/parserGen/source/com/intellij/parserGen/rules/PhantomRule.java b/Aurora/tools/parserGen/source/com/intellij/parserGen/rules/PhantomRule.java
index 3c425ca..c19a620 100644
--- a/Aurora/tools/parserGen/source/com/intellij/parserGen/rules/PhantomRule.java
+++ b/Aurora/tools/parserGen/source/com/intellij/parserGen/rules/PhantomRule.java
@@ -6,7 +6,6 @@ import com.intellij.parserGen.generator.GeneratorHelper;
import org.apache.velocity.VelocityContext;
import java.util.Set;
-import java.util.List;
import java.util.Stack;
/**
@@ -37,6 +36,7 @@ public class PhantomRule extends RoledRule {
for (int i = context.size () - 1; i >= 0; i--) {
NonterminalRule currRule = context.get (i);
currParam = context.get (i).getParameter(currParamPos); // rule argument
+ if (currParam.equals ("null")) return null;
currParamPos = currRule.getOwner().getParameterPosition(currParam); // nonterminal parameter
if (currParamPos == -1) {
if (currRule.getOwner().isLabelDefined(currParam)) break;
После прогона (изменив трешхолды) получили:
index 3c425ca . . c19a620 100644 mmm a / Aurora / tools / parserGen / source / com / intellij / parserGen / rules / PhantomRule . java ppp b / Aurora / tools / parserGen / source / com / intellij / parserGen / rules / PhantomRule . java import com . intellij . parserGen . generator . GeneratorHelper ; import org . apache . velocity . VelocityContext ; import java . util . Set ; - import java . util . List ; import java . util . Stack ; / * * public class PhantomRule extends RoledRule { for ( int i = context . size ( ) - 1 ; i > = 0 ; i - - ) { NonterminalRule currRule = context . get ( i ) ; currParam = context . get ( i ) . getParameter ( currParamPos ) ; / / rule argument + if ( currParam . equals ( " null " ) ) return null ; currParamPos = currRule . getOwner ( ) . getParameterPosition ( currParam ) ; / / nonterminal parameter if ( currParamPos = = - 1 ) { if ( currRule . getOwner ( ) . isLabelDefined ( currParam ) ) break ;
from gcm.
У автора статьи есть еще два vocab-а: для diff и для msg.
- Пример vocab-a для diff-a:
{
"eos": 0,
"UNK": 1,
"<nl>": 2,
"/": 3,
".": 4,
"b": 5,
"a": 6,
"mmm": 7,
"ppp": 8,
"-": 9,
"+": 10,
"=": 11,
"{": 12,
"(": 13,
")": 14,
":": 15,
";": 16,
"}": 17,
- Пример vocab-a для msg-a
{
"eos": 0,
"UNK": 1,
".": 2,
"-": 3,
"to": 4,
"Update": 5,
"'": 6,
"for": 7,
"/": 8,
"LPS": 9,
"the": 10,
"ignore": 11,
"in": 12,
"modules": 13,
"apps": 14,
"version": 15,
"0": 16,
"1": 17,
")": 18,
"(": 19,
from gcm.
Пример diff-a авторов статьи:
Два пути для файла, так же все в одной куче. Просто появляются +
/-
mmm a / core / java / android / database / CursorToBulkCursorAdaptor . java ppp b / core / java / android / database / CursorToBulkCursorAdaptor . java public final class CursorToBulkCursorAdaptor extends BulkCursorNative public void close ( ) { maybeUnregisterObserverProxy ( ) ; - mCursor . deactivate ( ) ; - + mCursor . close ( ) ; } public int requery ( IContentObserver observer , CursorWindow window ) {
from gcm.
пример хранения нескольких строк в json-e:
from gcm.
Related Issues (20)
- [dataset] анализ сообщений HOT 3
- [baseline] naive HOT 1
- [articles] metrics table HOT 3
- [baseline] naive message generation based on gumtree diff HOT 3
- [baseline] naive bayes HOT 4
- [baseline] code2seq HOT 1
- [code2seq] train on method diff until reasonable BLEU @natalymr
- [code2seq] add rnn in training pipeline HOT 1
- [merge messages] HOT 4
- [code2seq] new dataset HOT 5
- [code2seq] commits with 1, 2, 3 etc changed functions HOT 2
- [code2seq] repeat "perfect storm" HOT 3
- [scores] оценить качество данных - ранжирующая функция HOT 6
- [scores] хватит смотреть в один bleu score, надо что-нибудь визуализировать, чтобы лучше понимать, что происходит HOT 2
- [dataset] гипотезы HOT 2
- [seim] выступление HOT 2
- [diploma] Текст диплома HOT 2
- [nmt-2.0] HOT 8
- [code2seq] 2 inputs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gcm.