nus-yam/ex-repair huggingface dataset:
Program: 20137
Project: 20137
Buggy source:
/** 
 * Method used to extract log entry from card
 * @param pProvider provider to used
 * @param pCard card data
 * @param pLogEntry log entry position
 */
private void extractLogEntry(final IProvider pProvider,final EMVCard pCard,final byte[] pLogEntry) throws CommunicationException {
  if (pLogEntry != null) {
    List<EMVPaymentRecord> listRecord=new ArrayList<EMVPaymentRecord>();
    for (int rec=1; rec < pLogEntry[1]; rec++) {
      byte[] response=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,rec,pLogEntry[0] << 3 | 4,0).toBytes());
      if (ResponseApdu.isSucceed(response) && response.length >= EMVPaymentRecord.DEFAULT_SIZE / BitUtils.BYTE_SIZE) {
        EMVPaymentRecord record=new EMVPaymentRecord();
        record.parse(response);
        listRecord.add(record);
      }
    }
    pCard.setListPayment(listRecord);
  }
}

Fixed version (ground truth):
/** 
 * Method used to extract log entry from card
 * @param pProvider provider to used
 * @param pCard card data
 * @param pLogEntry log entry position
 */
private void extractLogEntry(final IProvider pProvider,final EMVCard pCard,final byte[] pLogEntry) throws CommunicationException {
  if (pLogEntry != null) {
    List<EMVPaymentRecord> listRecord=new ArrayList<EMVPaymentRecord>();
    for (int rec=1; rec < pLogEntry[1]; rec++) {
      byte[] response=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,rec,pLogEntry[0] << 3 | 4,0).toBytes());
      if (ResponseApdu.isSucceed(response) && response.length >= EMVPaymentRecord.DEFAULT_SIZE / BitUtils.BYTE_SIZE) {
        EMVPaymentRecord record=new EMVPaymentRecord();
        record.parse(response);
        if (record != null) {
          if (record.getCurrency() == null) {
            record.setCurrency(CurrencyEnum.XXX);
          }
          listRecord.add(record);
        }
      }
    }
    pCard.setListPayment(listRecord);
  }
}
Program: 20139
Project: 20139
Buggy source:
@Override protected void onPostExecute(final Object result){
  if (mDialog != null) {
    mDialog.cancel();
  }
  if (!mException) {
    if (mCard != null && StringUtils.isNotBlank(mCard.getAid())) {
      if (!mList.contains(mCard)) {
        mList.add(mCard);
        mAdapter.notifyDataSetChanged();
        display(getText(R.string.card_added),true);
      }
 else {
        display(getText(R.string.error_card_already_added),false);
      }
    }
 else {
      display(getText(R.string.error_card_unknown),false);
    }
  }
 else {
    display(getResources().getText(R.string.error_communication_nfc),false);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(final Object result){
  if (mDialog != null) {
    mDialog.cancel();
  }
  if (!mException) {
    if (mCard != null && StringUtils.isNotBlank(mCard.getCardNumber())) {
      if (!mList.contains(mCard)) {
        mList.add(mCard);
        mAdapter.notifyDataSetChanged();
        display(getText(R.string.card_added),true);
      }
 else {
        display(getText(R.string.error_card_already_added),false);
      }
    }
 else {
      display(getText(R.string.error_card_unknown),false);
    }
  }
 else {
    display(getResources().getText(R.string.error_communication_nfc),false);
  }
}
Program: 20140
Project: 20140
Buggy source:
@Override public View getView(final int position,final View pConvertView,final ViewGroup parent){
  View v=pConvertView;
  if (pConvertView == null) {
    v=View.inflate(mContext,R.layout.event_item,null);
  }
  TextView date=ViewHolder.get(v,R.id.event_date);
  TextView amount=ViewHolder.get(v,R.id.event_price);
  TextView symbol=ViewHolder.get(v,R.id.event_symbol);
  EMVPaymentRecord event=(EMVPaymentRecord)getItem(position);
  SimpleDateFormat format=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  date.setText(format.format(event.getTransactionDate()));
  Currency currency=Currency.getInstance(event.getCurrency().getCode());
  if (currency != null) {
    symbol.setText(currency.getSymbol(Locale.getDefault()));
    amount.setText(event.getCurrency().format(event.getAmount().longValue()));
  }
 else {
    amount.setText(String.valueOf(event.getAmount().longValue()));
  }
  ViewUtils.setTypeFace(EmvApplication.sTypeface,date,amount,symbol);
  return v;
}

Fixed version (ground truth):
@Override public View getView(final int position,final View pConvertView,final ViewGroup parent){
  View v=pConvertView;
  if (pConvertView == null) {
    v=View.inflate(mContext,R.layout.event_item,null);
  }
  TextView date=ViewHolder.get(v,R.id.event_date);
  TextView amount=ViewHolder.get(v,R.id.event_price);
  TextView symbol=ViewHolder.get(v,R.id.event_symbol);
  EMVPaymentRecord event=(EMVPaymentRecord)getItem(position);
  SimpleDateFormat format=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
  date.setText(format.format(event.getTransactionDate()));
  if (event.getCurrency() != CurrencyEnum.XXX) {
    Currency currency=Currency.getInstance(event.getCurrency().getCode());
    if (currency != null) {
      symbol.setText(currency.getSymbol(Locale.getDefault()));
      amount.setText(event.getCurrency().format(event.getAmount().longValue()));
    }
 else {
      amount.setText(String.valueOf(event.getAmount().longValue()));
    }
  }
 else {
    amount.setText(event.getCurrency().format(event.getAmount().longValue()));
  }
  ViewUtils.setTypeFace(EmvApplication.sTypeface,date,amount,symbol);
  return v;
}
Program: 20141
Project: 20141
Buggy source:
/** 
 * Extract card data (card number + expire date)
 * @param pCard card object
 * @param pData
 */
protected void extractCardData(final EMVCard pCard,final byte[] pData){
  byte[] track2=TLVUtil.getValue(pData,EMVTags.TRACK_2_EQV_DATA);
  if (track2 != null) {
    BitUtils bit=new BitUtils(track2);
    pCard.setCardNumber(bit.getNextHexaString(64));
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
    try {
      String date=bit.getNextHexaString(5 * 4);
      if (date.length() > 5) {
        date=date.substring(0,5);
      }
      pCard.setExpireDate(DateUtils.truncate(sdf.parse(date),Calendar.MONTH));
    }
 catch (    ParseException e) {
      LOGGER.error("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Extract card data (card number + expire date)
 * @param pCard card object
 * @param pData
 */
protected boolean extractCardData(final EMVCard pCard,final byte[] pData){
  boolean ret=false;
  byte[] track2=TLVUtil.getValue(pData,EMVTags.TRACK_2_EQV_DATA);
  if (track2 != null) {
    BitUtils bit=new BitUtils(track2);
    pCard.setCardNumber(bit.getNextHexaString(64));
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
    try {
      String date=bit.getNextHexaString(5 * 4);
      if (date.length() > 5) {
        date=date.substring(0,5);
      }
      pCard.setExpireDate(DateUtils.truncate(sdf.parse(date),Calendar.MONTH));
      ret=true;
    }
 catch (    ParseException e) {
      LOGGER.error("String_Node_Str");
    }
  }
  return ret;
}
Program: 20142
Project: 20142
Buggy source:
/** 
 * Method used to extract commons card data
 * @param pProvider provider
 * @param pCard Card data
 * @param pGpo global processing options response
 */
private void extractCommonsCardData(final IProvider pProvider,final EMVCard pCard,final byte[] pGpo) throws CommunicationException {
  byte data[]=TLVUtil.getValue(pGpo,EMVTags.APPLICATION_FILE_LOCATOR);
  if (TLVUtil.startWith(pGpo,EMVTags.RESPONSE_MESSAGE_TEMPLATE_1) || data != null) {
    if (data == null) {
      data=pGpo;
    }
    List<Afl> listAfl=extractAfl(data);
    boolean found=false;
    for (    Afl afl : listAfl) {
      int sfi=afl.getSfi();
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,index << 3 | 4,0).toBytes());
        if (info[info.length - 2] == (byte)0x6C) {
          info=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,index << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          try {
            extractCardData(pCard,info);
            found=true;
            break;
          }
 catch (          Exception e) {
          }
        }
      }
      if (found) {
        break;
      }
    }
  }
 else {
    try {
      extractCardData(pCard,pGpo);
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Method used to extract commons card data
 * @param pProvider provider
 * @param pCard Card data
 * @param pGpo global processing options response
 */
private void extractCommonsCardData(final IProvider pProvider,final EMVCard pCard,final byte[] pGpo) throws CommunicationException {
  byte data[]=TLVUtil.getValue(pGpo,EMVTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    data=TLVUtil.getValue(pGpo,EMVTags.APPLICATION_FILE_LOCATOR);
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    boolean found=false;
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (info[info.length - 2] == (byte)0x6C) {
          info=pProvider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          try {
            if (found=extractCardData(pCard,info)) {
              break;
            }
          }
 catch (          Exception e) {
          }
        }
      }
      if (found) {
        break;
      }
    }
  }
 else {
    try {
      extractCardData(pCard,pGpo);
    }
 catch (    Exception e) {
    }
  }
}
Program: 20143
Project: 20143
Buggy source:
/** 
 * Extract list of application file locator from GPO response
 * @param pGpo GPO response
 * @return list of AFL
 */
protected List<Afl> extractAfl(final byte[] pGpo){
  List<Afl> list=new ArrayList<Afl>();
  if (pGpo.length - 4 > 0) {
    for (int i=0; i < (pGpo.length - 4) / 4; i++) {
      Afl afl=new Afl();
      afl.setSfi(pGpo[4 + i * 4] >> 3);
      afl.setFirstRecord(pGpo[5 + i * 4]);
      afl.setLastRecord(pGpo[6 + i * 4]);
      afl.setOfflineAuthentication(pGpo[7 + i * 4] == 1);
      list.add(afl);
    }
  }
  return list;
}

Fixed version (ground truth):
/** 
 * Extract list of application file locator from Afl response
 * @param pAfl AFL data
 * @return list of AFL
 */
protected List<Afl> extractAfl(final byte[] pAfl){
  List<Afl> list=new ArrayList<Afl>();
  ByteArrayInputStream bai=new ByteArrayInputStream(pAfl);
  while (bai.available() >= 4) {
    Afl afl=new Afl();
    afl.setSfi(bai.read() >> 3);
    afl.setFirstRecord(bai.read());
    afl.setLastRecord(bai.read());
    afl.setOfflineAuthentication(bai.read() == 1);
    list.add(afl);
  }
  return list;
}
Program: 20144
Project: 20144
Buggy source:
private static String getTagValueAsString(final ITag tag,final byte[] value){
  StringBuilder buf=new StringBuilder();
switch (tag.getTagValueType()) {
case TEXT:
    buf.append("String_Node_Str");
  buf.append(new String(value));
break;
case NUMERIC:
buf.append("String_Node_Str");
break;
case BINARY:
buf.append("String_Node_Str");
break;
case MIXED:
buf.append("String_Node_Str");
buf.append(getSafePrintChars(value));
break;
case DOL:
buf.append("String_Node_Str");
break;
}
return buf.toString();
}

Fixed version (ground truth):
private static String getTagValueAsString(final ITag tag,final byte[] value){
  StringBuilder buf=new StringBuilder();
switch (tag.getTagValueType()) {
case TEXT:
    buf.append("String_Node_Str");
  buf.append(new String(value));
break;
case NUMERIC:
buf.append("String_Node_Str");
break;
case BINARY:
buf.append("String_Node_Str");
break;
case MIXED:
buf.append("String_Node_Str");
buf.append(getSafePrintChars(value));
break;
case DOL:
buf.append("String_Node_Str");
break;
default :
break;
}
return buf.toString();
}
Program: 20145
Project: 20145
Buggy source:
public static int getLength(final List<TagAndLength> pList){
  int ret=0;
  if (pList != null) {
    for (    TagAndLength tl : pList) {
      ret+=tl.getLength();
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to get length of all Tags
 * @param pList tag length list
 * @return the sum of tag length
 */
public static int getLength(final List<TagAndLength> pList){
  int ret=0;
  if (pList != null) {
    for (    TagAndLength tl : pList) {
      ret+=tl.getLength();
    }
  }
  return ret;
}
Program: 20146
Project: 20146
Buggy source:
@Test public void testAfl() throws Exception {
  @SuppressWarnings("String_Node_Str") List<Afl> list=(List<Afl>)Whitebox.invokeMethod(DefaultEmvParser.getInstance(),DefaultEmvParser.class,"String_Node_Str",BytesUtils.fromString("String_Node_Str"));
  Assertions.assertThat(list.size()).isEqualTo(3);
  Assertions.assertThat(list.get(0).getSfi()).isEqualTo(1);
  Assertions.assertThat(list.get(0).getFirstRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(0).getLastRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(0).isOfflineAuthentication()).isEqualTo(false);
  Assertions.assertThat(list.get(1).getSfi()).isEqualTo(2);
  Assertions.assertThat(list.get(1).getFirstRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(1).getLastRecord()).isEqualTo(5);
  Assertions.assertThat(list.get(1).isOfflineAuthentication()).isEqualTo(false);
  Assertions.assertThat(list.get(2).getSfi()).isEqualTo(3);
  Assertions.assertThat(list.get(2).getFirstRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(2).getLastRecord()).isEqualTo(2);
  Assertions.assertThat(list.get(2).isOfflineAuthentication()).isEqualTo(true);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Test public void testAfl() throws Exception {
  List<Afl> list=(List<Afl>)Whitebox.invokeMethod(DefaultEmvParser.getInstance(),DefaultEmvParser.class,"String_Node_Str",BytesUtils.fromString("String_Node_Str"));
  Assertions.assertThat(list.size()).isEqualTo(3);
  Assertions.assertThat(list.get(0).getSfi()).isEqualTo(2);
  Assertions.assertThat(list.get(0).getFirstRecord()).isEqualTo(2);
  Assertions.assertThat(list.get(0).getLastRecord()).isEqualTo(3);
  Assertions.assertThat(list.get(0).isOfflineAuthentication()).isEqualTo(true);
  Assertions.assertThat(list.get(1).getSfi()).isEqualTo(3);
  Assertions.assertThat(list.get(1).getFirstRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(1).getLastRecord()).isEqualTo(5);
  Assertions.assertThat(list.get(1).isOfflineAuthentication()).isEqualTo(false);
  Assertions.assertThat(list.get(2).getSfi()).isEqualTo(4);
  Assertions.assertThat(list.get(2).getFirstRecord()).isEqualTo(1);
  Assertions.assertThat(list.get(2).getLastRecord()).isEqualTo(2);
  Assertions.assertThat(list.get(2).isOfflineAuthentication()).isEqualTo(false);
}
Program: 20147
Project: 20147
Buggy source:
@Test public void tesCardType() throws Exception {
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.VISA);
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.MASTER_CARD1);
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.UNIONPAY);
}

Fixed version (ground truth):
@Test public void tesCardType() throws Exception {
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.VISA);
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.MASTER_CARD1);
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber("String_Node_Str")).isEqualTo(EMVCardTypeEnum.UNIONPAY);
  Assertions.assertThat(EMVCardTypeEnum.getCardTypeByCardNumber(null)).isEqualTo(null);
}
Program: 20148
Project: 20148
Buggy source:
@Override protected void doInBackground(){
  mTag=intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  mTagcomm=IsoDep.get(mTag);
  if (mTagcomm == null) {
    display(getText(R.string.error_communication_nfc),false);
    return;
  }
  mException=false;
  try {
    mTagcomm.connect();
    IProvider prov=new Provider(mTagcomm);
    EMVParser parser=new EMVParser(prov,true);
    mCard=parser.readEmvCard();
  }
 catch (  IOException e) {
    mException=true;
  }
 finally {
    if (mTagcomm != null) {
      try {
        mTagcomm.close();
      }
 catch (      IOException e) {
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void doInBackground(){
  mTagcomm=IsoDep.get(mTag);
  if (mTagcomm == null) {
    display(getText(R.string.error_communication_nfc),false);
    return;
  }
  mException=false;
  try {
    mTagcomm.connect();
    IProvider prov=new Provider(mTagcomm);
    EMVParser parser=new EMVParser(prov,true);
    mCard=parser.readEmvCard();
  }
 catch (  IOException e) {
    mException=true;
  }
 finally {
    if (mTagcomm != null) {
      try {
        mTagcomm.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 20150
Project: 20150
Buggy source:
/** 
 * Method used to get the resource Id for card type
 * @param pEnum card enum
 * @return resource id
 */
public static int getResourceIdCardType(final EMVCardTypeEnum pEnum){
  int ret=0;
switch (pEnum) {
case AMERICAN_EXPRESS:
    ret=R.drawable.amex;
  break;
case MASTER_CARD1:
case MASTER_CARD2:
ret=R.drawable.mastercard;
break;
case VISA:
ret=R.drawable.visa;
break;
default :
break;
}
return ret;
}

Fixed version (ground truth):
/** 
 * Method used to get the resource Id for card type
 * @param pEnum card enum
 * @return resource id
 */
public static int getResourceIdCardType(final EMVCardTypeEnum pEnum){
  int ret=0;
  if (pEnum != null) {
switch (pEnum) {
case AMERICAN_EXPRESS:
      ret=R.drawable.amex;
    break;
case MASTER_CARD1:
case MASTER_CARD2:
  ret=R.drawable.mastercard;
break;
case VISA:
ret=R.drawable.visa;
break;
default :
break;
}
}
return ret;
}
Program: 20151
Project: 20151
Buggy source:
/** 
 * Method used to format card number
 * @param pCardNumber card number to display
 * @param pType card type
 * @return the card number formated
 */
public static String formatCardNumber(final String pCardNumber,final EMVCardTypeEnum pType){
  String ret=StringUtils.EMPTY;
  if (StringUtils.isNotBlank(pCardNumber)) {
    if (pType != null && pType == EMVCardTypeEnum.AMERICAN_EXPRESS) {
      ret=StringUtils.deleteWhitespace(pCardNumber).replaceFirst("String_Node_Str","String_Node_Str").replaceFirst("String_Node_Str","String_Node_Str").replaceFirst("String_Node_Str","String_Node_Str").trim();
    }
 else {
      ret=StringUtils.deleteWhitespace(pCardNumber).replaceAll("String_Node_Str","String_Node_Str").trim();
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to format card number
 * @param pCardNumber card number to display
 * @param pType card type
 * @return the card number formated
 */
public static String formatCardNumber(final String pCardNumber,final EMVCardTypeEnum pType){
  String ret=StringUtils.EMPTY;
  if (StringUtils.isNotBlank(pCardNumber)) {
    if (pType != null && pType == EMVCardTypeEnum.AMERICAN_EXPRESS) {
      ret=StringUtils.deleteWhitespace(pCardNumber).replaceFirst("String_Node_Str","String_Node_Str").replaceFirst("String_Node_Str","String_Node_Str").replaceFirst("String_Node_Str","String_Node_Str").trim();
    }
 else {
      ret=StringUtils.deleteWhitespace(pCardNumber).replaceAll("String_Node_Str","String_Node_Str").trim();
    }
  }
 else {
    ret="String_Node_Str";
  }
  return ret;
}
Program: 20161
Project: 20161
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  requestWindowFeature(Window.FEATURE_PROGRESS);
  setContentView(R.layout.main_activity);
  View v=findViewById(R.id.currentWeatherFrag);
  if (v != null)   isThereForecast=true;
  client=WeatherClientDefault.getInstance();
  client.init(getApplicationContext());
  Log.d("String_Node_Str","String_Node_Str" + client + "String_Node_Str");
  config=new WeatherConfig();
  config.unitSystem=WeatherConfig.UNIT_SYSTEM.M;
  IWeatherProvider provider=null;
  try {
    provider=WeatherProviderFactory.createProvider(new OpenweathermapProviderType(),config);
    client.setProvider(provider);
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  requestWindowFeature(Window.FEATURE_PROGRESS);
  setContentView(R.layout.main_activity);
  View v=findViewById(R.id.currentWeatherFrag);
  if (v != null)   isThereForecast=true;
  client=WeatherClientDefault.getInstance();
  client.init(getApplicationContext());
  Log.d("String_Node_Str","String_Node_Str" + client + "String_Node_Str");
  config=new WeatherConfig();
  config.unitSystem=WeatherConfig.UNIT_SYSTEM.M;
  IWeatherProvider provider=null;
  try {
    provider=WeatherProviderFactory.createProvider(new OpenweathermapProviderType(),config);
    client.setProvider(provider);
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
  setProgressBarIndeterminate(true);
  setProgressBarVisibility(true);
  if (!isThereForecast) {
    ActionBar bar=getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    createTab(R.string.tab_current,bar);
    createTab(R.string.tab_forecast,bar);
  }
 else {
    FragmentTransaction ft=getFragmentManager().beginTransaction();
    ft.setTransitionStyle(R.style.fragmentAnim);
    CurrentWeatherFragment cf=CurrentWeatherFragment.newInstance();
    ft.add(R.id.currentWeatherFrag,cf,"String_Node_Str");
    ft.commit();
    FragmentTransaction ft1=getFragmentManager().beginTransaction();
    ft1.setTransitionStyle(R.style.fragmentAnim);
    ForecastWeatherFragment ff=ForecastWeatherFragment.newInstance();
    ft1.add(R.id.forecastWeatherFrag,ff,"String_Node_Str");
    ft1.commit();
  }
}
Program: 20164
Project: 20164
Buggy source:
private SerialPipes createPipes(){
  List<Pipe> pipes=new ArrayList<>();
  pipes.add(new CharSequenceLowercase());
  pipes.add(new CharSequence2TokenSequence(CharSequenceLexer.LEX_WORDS));
  pipes.add(new TokenSequence2PorterStems());
  return new SerialPipes(pipes);
}

Fixed version (ground truth):
private SerialPipes createPipes(){
  List<Pipe> pipes=new ArrayList<Pipe>();
  pipes.add(new CharSequenceLowercase());
  pipes.add(new CharSequence2TokenSequence(CharSequenceLexer.LEX_WORDS));
  pipes.add(new TokenSequence2PorterStems());
  return new SerialPipes(pipes);
}
Program: 20165
Project: 20165
Buggy source:
public Alphabet getAlphabet(){
  return (Alphabet)instancePipe.getDataAlphabet();
}

Fixed version (ground truth):
@Override public Alphabet getAlphabet(){
  return (Alphabet)instancePipe.getDataAlphabet();
}
Program: 20166
Project: 20166
Buggy source:
public Alphabet[] getAlphabets(){
  return new Alphabet[]{getAlphabet(),getLabelAlphabet()};
}

Fixed version (ground truth):
@Override public Alphabet[] getAlphabets(){
  return new Alphabet[]{getAlphabet(),getLabelAlphabet()};
}
Program: 20167
Project: 20167
Buggy source:
public void write(PrintWriter out){
  for (int word=0; word < numWords; word++) {
    Formatter buffer=new Formatter();
    buffer.format("String_Node_Str",vocabulary.lookupObject(word));
    for (int col=0; col < numColumns; col++) {
      buffer.format("String_Node_Str",weights[word * stride + col]);
    }
    out.println(buffer);
  }
}

Fixed version (ground truth):
public void write(PrintWriter out){
  for (int word=0; word < numWords; word++) {
    Formatter buffer=new Formatter(Locale.US);
    buffer.format("String_Node_Str",vocabulary.lookupObject(word));
    for (int col=0; col < numColumns; col++) {
      buffer.format("String_Node_Str",weights[word * stride + col]);
    }
    out.println(buffer);
  }
}
Program: 20168
Project: 20168
Buggy source:
public static void main(String[] args) throws Exception {
  InstanceList instances=InstanceList.load(new File(inputFile.value));
  WordEmbeddings matrix=new WordEmbeddings(instances.getDataAlphabet(),numDimensions.value,windowSizeOption.value);
  matrix.queryWord=exampleWord.value;
  matrix.countWords(instances);
  matrix.train(instances,numThreads.value,numSamples.value);
  PrintWriter out=new PrintWriter(outputFile.value);
  matrix.write(out);
  out.close();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  CommandOption.setSummary(WordEmbeddings.class,"String_Node_Str");
  CommandOption.process(WordEmbeddings.class,args);
  InstanceList instances=InstanceList.load(new File(inputFile.value));
  WordEmbeddings matrix=new WordEmbeddings(instances.getDataAlphabet(),numDimensions.value,windowSizeOption.value);
  matrix.queryWord=exampleWord.value;
  matrix.countWords(instances);
  matrix.train(instances,numThreads.value,numSamples.value);
  PrintWriter out=new PrintWriter(outputFile.value);
  matrix.write(out);
  out.close();
}
Program: 20172
Project: 20172
Buggy source:
public static ParallelTopicModel read(File f) throws Exception {
  ParallelTopicModel topicModel=null;
  ObjectInputStream ois=new ObjectInputStream(new FileInputStream(f));
  topicModel=(ParallelTopicModel)ois.readObject();
  ois.close();
  return topicModel;
}

Fixed version (ground truth):
public static ParallelTopicModel read(File f) throws Exception {
  ParallelTopicModel topicModel=null;
  ObjectInputStream ois=new ObjectInputStream(new FileInputStream(f));
  topicModel=(ParallelTopicModel)ois.readObject();
  ois.close();
  topicModel.initializeHistograms();
  return topicModel;
}
Program: 20176
Project: 20176
Buggy source:
@Override public Instance pipe(Instance carrier){
  String dataStr=(String)carrier.getData();
  if (dataStr.contains("String_Node_Str")) {
    dataStr=dataStr.substring(0,dataStr.indexOf('#'));
  }
  String[] terms=dataStr.split("String_Node_Str");
  String classStr=terms[0];
  if (classStr.equals("String_Node_Str")) {
    classStr="String_Node_Str";
  }
  Label label=((LabelAlphabet)getTargetAlphabet()).lookupLabel(classStr,true);
  carrier.setTarget(label);
  int numFeatures=terms.length - 1;
  int[] indices=new int[numFeatures];
  double[] values=new double[numFeatures];
  for (int termIndex=1; termIndex < terms.length; termIndex++) {
    if (!terms[termIndex].equals("String_Node_Str")) {
      String[] s=terms[termIndex].split("String_Node_Str");
      if (s.length != 2) {
        throw new RuntimeException("String_Node_Str" + terms[termIndex] + "String_Node_Str");
      }
      String feature=s[0];
      indices[termIndex - 1]=getDataAlphabet().lookupIndex(feature,true);
      values[termIndex - 1]=Double.parseDouble(s[1]);
    }
  }
  FeatureVector fv=new FeatureVector(getDataAlphabet(),indices,values);
  carrier.setData(fv);
  return carrier;
}

Fixed version (ground truth):
@Override public Instance pipe(Instance carrier){
  String dataStr=(String)carrier.getData();
  if (dataStr.contains("String_Node_Str")) {
    dataStr=dataStr.substring(0,dataStr.indexOf('#'));
  }
  String[] terms=dataStr.split("String_Node_Str");
  String classStr=terms[0];
  if (classStr.equals("String_Node_Str")) {
    classStr="String_Node_Str";
  }
  Label label=((LabelAlphabet)getTargetAlphabet()).lookupLabel(classStr,true);
  carrier.setTarget(label);
  ArrayList<Integer> indices=new ArrayList<Integer>();
  ArrayList<Double> values=new ArrayList<Double>();
  for (int termIndex=1; termIndex < terms.length; termIndex++) {
    if (!terms[termIndex].equals("String_Node_Str")) {
      String[] s=terms[termIndex].split("String_Node_Str");
      if (s.length != 2) {
        throw new RuntimeException("String_Node_Str" + terms[termIndex] + "String_Node_Str");
      }
      String feature=s[0];
      int index=getDataAlphabet().lookupIndex(feature,true);
      if (index >= 0) {
        indices.add(index);
        values.add(Double.parseDouble(s[1]));
      }
    }
  }
  assert(indices.size() == values.size());
  int[] indicesArr=new int[indices.size()];
  double[] valuesArr=new double[values.size()];
  for (int i=0; i < indicesArr.length; i++) {
    indicesArr[i]=indices.get(i);
    valuesArr[i]=values.get(i);
  }
  FeatureVector fv=new FeatureVector(getDataAlphabet(),indicesArr,valuesArr);
  carrier.setData(fv);
  return carrier;
}
Program: 20177
Project: 20177
Buggy source:
/** 
 * @param trainingList List with unlabeled training instances.
 * @param constraints Feature expectation constraints.
 * @param initClassifier Initial classifier.
 */
public MaxEntOptimizableByGE(InstanceList trainingList,HashMap<Integer,double[]> constraints,MaxEnt initClassifier){
  useValues=false;
  temperature=1.0;
  objWeight=1.0;
  gaussianPriorVariance=1.0;
  this.trainingList=trainingList;
  int numFeatures=trainingList.getDataAlphabet().size();
  defaultFeatureIndex=numFeatures;
  int numLabels=trainingList.getTargetAlphabet().size();
  parameters=new double[(numFeatures + 1) * numLabels];
  cachedGradient=new double[(numFeatures + 1) * numLabels];
  cachedValue=0;
  if (classifier != null) {
    this.classifier=initClassifier;
  }
 else {
    this.classifier=new MaxEnt(trainingList.getPipe(),parameters);
  }
  this.constraints=constraints;
}

Fixed version (ground truth):
/** 
 * @param trainingList List with unlabeled training instances.
 * @param constraints Feature expectation constraints.
 * @param initClassifier Initial classifier.
 */
public MaxEntOptimizableByGE(InstanceList trainingList,HashMap<Integer,double[]> constraints,MaxEnt initClassifier){
  useValues=false;
  temperature=1.0;
  objWeight=1.0;
  gaussianPriorVariance=1.0;
  this.trainingList=trainingList;
  int numFeatures=trainingList.getDataAlphabet().size();
  defaultFeatureIndex=numFeatures;
  int numLabels=trainingList.getTargetAlphabet().size();
  cachedGradient=new double[(numFeatures + 1) * numLabels];
  cachedValue=0;
  if (initClassifier != null) {
    this.parameters=initClassifier.parameters;
    this.classifier=initClassifier;
  }
 else {
    this.parameters=new double[(numFeatures + 1) * numLabels];
    this.classifier=new MaxEnt(trainingList.getPipe(),parameters);
  }
  this.constraints=constraints;
}
Program: 20178
Project: 20178
Buggy source:
private void setProbs(double[] probArray){
  if (probArray.length != probs.numLocations()) {
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + probs.numLocations() + "String_Node_Str"+ probArray.length);
  }
  for (int i=0; i < probArray.length; i++) {
    probs.setValueAtLocation(i,probArray[i]);
  }
}

Fixed version (ground truth):
private void setProbs(double[] probArray){
  if (probArray.length != probs.numLocations()) {
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + probs.numLocations() + "String_Node_Str"+ probArray.length);
  }
  for (int i=0; i < probArray.length; i++) {
    int[] indicesAsPassed=new int[sizesAsPassed.length];
    Matrixn.singleToIndices(i,indicesAsPassed,sizesAsPassed);
    int[] indicesAsSorted=new int[sizesAsPassed.length];
    for (int j=0; j < sizesAsPassed.length; j++) {
      indicesAsSorted[j]=indicesAsPassed[reorderingMap[j]];
    }
    int singleIndexAsSorted=Matrixn.singleIndex(sizesAsSorted,indicesAsSorted);
    probs.setValueAtLocation(singleIndexAsSorted,probArray[i]);
  }
}
Program: 20180
Project: 20180
Buggy source:
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  int version=in.readInt();
  sgmlPattern=(Pattern)in.readObject();
  lexer=(CharSequenceLexer)in.readObject();
  backgroundTag=(String)in.readObject();
  if (version == 0)   saveSource=true;
}

Fixed version (ground truth):
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  int version=in.readInt();
  sgmlPattern=(Pattern)in.readObject();
  lexer=(CharSequenceLexer)in.readObject();
  backgroundTag=(String)in.readObject();
  if (version == 0) {
    saveSource=true;
  }
 else {
    saveSource=in.readBoolean();
  }
}
Program: 20181
Project: 20181
Buggy source:
public Instance pipe(Instance carrier){
  if (carrier.getData() instanceof CharSequence)   carrier.setData(new TokenSequence(ngramify((CharSequence)carrier.getData())));
 else   if (carrier.getData() instanceof TokenSequence) {
    TokenSequence ts=(TokenSequence)carrier.getData();
    TokenSequence ret=new TokenSequence();
    for (int i=0; i < ts.size(); i++)     ret.add(ngramify(ts.get(i).getText()));
    carrier.setData(ret);
  }
 else   throw new IllegalArgumentException("String_Node_Str" + carrier.getData().getClass());
  return carrier;
}

Fixed version (ground truth):
public Instance pipe(Instance carrier){
  if (carrier.getData() instanceof CharSequence)   carrier.setData(new TokenSequence(ngramify((CharSequence)carrier.getData())));
 else   if (carrier.getData() instanceof TokenSequence) {
    TokenSequence ts=(TokenSequence)carrier.getData();
    TokenSequence ret=new TokenSequence();
    for (int i=0; i < ts.size(); i++)     ret.add(ngramify(ts.get(i).getText()).toString());
    carrier.setData(ret);
  }
 else   throw new IllegalArgumentException("String_Node_Str" + carrier.getData().getClass());
  return carrier;
}
Program: 20182
Project: 20182
Buggy source:
public void add(Object o){
  if (o instanceof Token)   add((Token)o);
 else   if (o instanceof TokenSequence)   add((TokenSequence)o);
 else   add(new Token(o.toString()));
}

Fixed version (ground truth):
public void add(String string){
  add(new Token(string));
}
Program: 20184
Project: 20184
Buggy source:
public boolean alphabetsMatch(AlphabetCarrying object){
  Alphabet[] oas=object.getAlphabets();
  return oas.length == 2 && oas[0].equals(getDataAlphabet()) && oas[1].equals(getDataAlphabet());
}

Fixed version (ground truth):
public boolean alphabetsMatch(AlphabetCarrying object){
  Alphabet[] oas=object.getAlphabets();
  return oas.length == 2 && oas[0].equals(getDataAlphabet()) && oas[1].equals(getTargetAlphabet());
}
Program: 20185
Project: 20185
Buggy source:
public TransitionIterator(State source,FeatureSequence inputSeq,int inputPosition,String output,HMM hmm){
  this.source=source;
  this.hmm=hmm;
  this.inputSequence=inputSeq;
  this.inputFeature=new Integer(inputSequence.getIndexAtPosition(inputPosition));
  this.inputPos=inputPosition;
  this.weights=new double[source.destinations.length];
  for (int transIndex=0; transIndex < source.destinations.length; transIndex++) {
    if (output == null || output.equals(source.labels[transIndex])) {
      weights[transIndex]=0;
      double logEmissionProb=hmm.emissionMultinomial[transIndex].logProbability(inputSeq.get(inputPosition));
      double logTransitionProb=hmm.transitionMultinomial[source.getIndex()].logProbability(source.destinationNames[transIndex]);
      weights[transIndex]=(logEmissionProb + logTransitionProb);
      assert(!Double.isNaN(weights[transIndex]));
    }
 else     weights[transIndex]=IMPOSSIBLE_WEIGHT;
  }
  nextIndex=0;
  while (nextIndex < source.destinations.length && weights[nextIndex] == IMPOSSIBLE_WEIGHT)   nextIndex++;
}

Fixed version (ground truth):
public TransitionIterator(State source,FeatureSequence inputSeq,int inputPosition,String output,HMM hmm){
  this.source=source;
  this.hmm=hmm;
  this.inputSequence=inputSeq;
  this.inputFeature=new Integer(inputSequence.getIndexAtPosition(inputPosition));
  this.inputPos=inputPosition;
  this.weights=new double[source.destinations.length];
  for (int transIndex=0; transIndex < source.destinations.length; transIndex++) {
    if (output == null || output.equals(source.labels[transIndex])) {
      weights[transIndex]=0;
      int destIndex=source.getDestinationState(transIndex).getIndex();
      double logEmissionProb=hmm.emissionMultinomial[destIndex].logProbability(inputSeq.get(inputPosition));
      double logTransitionProb=hmm.transitionMultinomial[source.getIndex()].logProbability(source.destinationNames[transIndex]);
      weights[transIndex]=(logEmissionProb + logTransitionProb);
      assert(!Double.isNaN(weights[transIndex]));
    }
 else     weights[transIndex]=IMPOSSIBLE_WEIGHT;
  }
  nextIndex=0;
  while (nextIndex < source.destinations.length && weights[nextIndex] == IMPOSSIBLE_WEIGHT)   nextIndex++;
}
Program: 20187
Project: 20187
Buggy source:
/** 
 * Convert the data in the given <tt>Instance</tt> from a <tt>CharSequence</tt>  of sparse feature-value pairs to a <tt>FeatureVector</tt>
 * @throws IllegalStateException If <CODE>Instance.getTarget()</CODE> isnot a Labeling
 */
public Instance pipe(Instance carrier) throws IllegalStateException {
  CharSequence c=(CharSequence)carrier.getData();
  String[] pairs=c.toString().trim().split("String_Node_Str");
  String[] keys=new String[pairs.length];
  double[] values=new double[pairs.length];
  for (int i=0; i < pairs.length; i++) {
    int delimIndex=pairs[i].lastIndexOf("String_Node_Str");
    if (delimIndex <= 0 || delimIndex == (pairs[i].length() - 1))     throw new IllegalStateException("String_Node_Str" + pairs[i] + "String_Node_Str"+ carrier.getName());
    keys[i]=pairs[i].substring(0,delimIndex);
    values[i]=Double.parseDouble(pairs[i].substring(delimIndex + 1));
    dataAlphabet.lookupIndex(keys[i],true);
  }
  int[] keyIndices=FeatureVector.getObjectIndices(keys,dataAlphabet,true);
  java.util.Arrays.sort(keyIndices);
  FeatureVector fv=new FeatureVector(dataAlphabet,keyIndices,values);
  if (targetAlphabet == null) {
    if (carrier.getTarget() instanceof Labeling)     targetAlphabet=((Labeling)carrier.getTarget()).getLabelAlphabet();
 else     throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + carrier.getTarget().getClass().getName());
  }
  carrier.setData(fv);
  return carrier;
}

Fixed version (ground truth):
/** 
 * Convert the data in the given <tt>Instance</tt> from a <tt>CharSequence</tt>  of sparse feature-value pairs to a <tt>FeatureVector</tt>
 */
public Instance pipe(Instance carrier){
  CharSequence c=(CharSequence)carrier.getData();
  String[] pairs=c.toString().trim().split("String_Node_Str");
  int[] keys=new int[pairs.length];
  double[] values=new double[pairs.length];
  for (int i=0; i < pairs.length; i++) {
    int delimIndex=pairs[i].lastIndexOf("String_Node_Str");
    if (delimIndex <= 0 || delimIndex == (pairs[i].length() - 1)) {
      keys[i]=dataAlphabet.lookupIndex(pairs[i],true);
      values[i]=1.0;
    }
 else {
      keys[i]=dataAlphabet.lookupIndex(pairs[i].substring(0,delimIndex),true);
      values[i]=Double.parseDouble(pairs[i].substring(delimIndex + 1));
    }
  }
  FeatureVector fv=new FeatureVector(dataAlphabet,keys,values);
  carrier.setData(fv);
  return carrier;
}
Program: 20188
Project: 20188
Buggy source:
/** 
 * Only gets the parameter from the first group of parameters. 
 */
public double getParameter(int sourceStateIndex,int destStateIndex,int featureIndex){
  State source=(State)getState(sourceStateIndex);
  State dest=(State)getState(destStateIndex);
  int rowIndex;
  for (rowIndex=0; rowIndex < source.destinationNames.length; rowIndex++)   if (source.destinationNames[rowIndex].equals(dest.name))   break;
  if (rowIndex == source.destinationNames.length)   throw new IllegalArgumentException("String_Node_Str" + sourceStateIndex + "String_Node_Str"+ destStateIndex+ "String_Node_Str");
  int weightsIndex=source.weightsIndices[rowIndex][0];
  if (featureIndex < 0)   return parameters.defaultWeights[weightsIndex];
  return parameters.weights[weightsIndex].value(featureIndex);
}

Fixed version (ground truth):
public double getParameter(int sourceStateIndex,int destStateIndex,int featureIndex,int weightIndex){
  State source=(State)getState(sourceStateIndex);
  State dest=(State)getState(destStateIndex);
  int rowIndex;
  for (rowIndex=0; rowIndex < source.destinationNames.length; rowIndex++)   if (source.destinationNames[rowIndex].equals(dest.name))   break;
  if (rowIndex == source.destinationNames.length)   throw new IllegalArgumentException("String_Node_Str" + sourceStateIndex + "String_Node_Str"+ destStateIndex+ "String_Node_Str");
  int weightsIndex=source.weightsIndices[rowIndex][weightIndex];
  if (featureIndex < 0)   return parameters.defaultWeights[weightsIndex];
  return parameters.weights[weightsIndex].value(featureIndex);
}
Program: 20189
Project: 20189
Buggy source:
/** 
 * Only sets the parameter from the first group of parameters. 
 */
public void setParameter(int sourceStateIndex,int destStateIndex,int featureIndex,double value){
  weightsValueChanged();
  State source=(State)getState(sourceStateIndex);
  State dest=(State)getState(destStateIndex);
  int rowIndex;
  for (rowIndex=0; rowIndex < source.destinationNames.length; rowIndex++)   if (source.destinationNames[rowIndex].equals(dest.name))   break;
  if (rowIndex == source.destinationNames.length)   throw new IllegalArgumentException("String_Node_Str" + sourceStateIndex + "String_Node_Str"+ destStateIndex+ "String_Node_Str");
  int weightsIndex=source.weightsIndices[rowIndex][0];
  if (featureIndex < 0)   parameters.defaultWeights[weightsIndex]=value;
 else {
    parameters.weights[weightsIndex].setValue(featureIndex,value);
  }
}

Fixed version (ground truth):
public void setParameter(int sourceStateIndex,int destStateIndex,int featureIndex,int weightIndex,double value){
  weightsValueChanged();
  State source=(State)getState(sourceStateIndex);
  State dest=(State)getState(destStateIndex);
  int rowIndex;
  for (rowIndex=0; rowIndex < source.destinationNames.length; rowIndex++)   if (source.destinationNames[rowIndex].equals(dest.name))   break;
  if (rowIndex == source.destinationNames.length)   throw new IllegalArgumentException("String_Node_Str" + sourceStateIndex + "String_Node_Str"+ destStateIndex+ "String_Node_Str");
  int weightsIndex=source.weightsIndices[rowIndex][weightIndex];
  if (featureIndex < 0)   parameters.defaultWeights[weightsIndex]=value;
 else {
    parameters.weights[weightsIndex].setValue(featureIndex,value);
  }
}
Program: 20191
Project: 20191
Buggy source:
public InvertedIndex(InstanceList ilist){
  int numFeatures=ilist.getDataAlphabet().size();
  ii=new ArrayList[numFeatures];
  for (int i=0; i < ilist.size(); i++) {
    Instance inst=ilist.get(i);
    if (!(inst.getData() instanceof FeatureVector))     throw new IllegalArgumentException(this.getClass().getName() + "String_Node_Str");
    FeatureVector fv=(FeatureVector)inst.getData();
    for (int fl=0; fl < fv.numLocations(); fl++) {
      if (fv.valueAtLocation(fl) != 0)       addEntry(fv.indexAtLocation(fl),inst);
    }
  }
}

Fixed version (ground truth):
public InvertedIndex(InstanceList ilist){
  this.ilist=ilist;
  int numFeatures=ilist.getDataAlphabet().size();
  ii=new ArrayList[numFeatures];
  for (int i=0; i < ilist.size(); i++) {
    Instance inst=ilist.get(i);
    if (!(inst.getData() instanceof FeatureVector))     throw new IllegalArgumentException(this.getClass().getName() + "String_Node_Str");
    FeatureVector fv=(FeatureVector)inst.getData();
    for (int fl=0; fl < fv.numLocations(); fl++) {
      if (fv.valueAtLocation(fl) != 0)       addEntry(fv.indexAtLocation(fl),inst);
    }
  }
}
Program: 20193
Project: 20193
Buggy source:
public double getInstanceWeight(int index){
  if (index > this.size())   throw new IllegalArgumentException("String_Node_Str" + index + "String_Node_Str"+ this.size());
  if (instWeights == null)   return 1.0;
  return instWeights.get(get(index));
}

Fixed version (ground truth):
public double getInstanceWeight(int index){
  if (index > this.size()) {
    throw new IllegalArgumentException("String_Node_Str" + index + "String_Node_Str"+ this.size());
  }
  if (instWeights != null) {
    Double value=instWeights.get(get(index));
    if (value != null) {
      return value;
    }
  }
  return 1.0;
}
Program: 20194
Project: 20194
Buggy source:
public void setInstanceWeight(int index,double weight){
  if (weight != getInstanceWeight(index)) {
    if (instWeights == null)     instWeights=new HashMap<Instance,Double>();
    instWeights.put(get(index),weight);
  }
}

Fixed version (ground truth):
public void setInstanceWeight(int index,double weight){
  if (weight == 1.0) {
    if (instWeights == null) {
      return;
    }
    Instance instance=get(index);
    Double value=instWeights.get(instance);
    if (value == null || value.doubleValue() == weight) {
      return;
    }
    instWeights.remove(instance);
  }
 else {
    if (instWeights == null) {
      instWeights=new HashMap<Instance,Double>();
    }
    instWeights.put(get(index),weight);
  }
}
Program: 20195
Project: 20195
Buggy source:
/** 
 * Select top features in LDA topics.
 * @param numSelFeatures Number of features to select.
 * @param ldaEst LDAEstimatePr which provides an interface to an LDA model.
 * @param seqAlphabet The alphabet for the sequence dataset, which may be different from the vector dataset alphabet.
 * @param alphabet The vector dataset alphabet.
 * @return ArrayList with the int indices of the selected features.
 */
public static ArrayList<Integer> selectTopLDAFeatures(int numSelFeatures,ParallelTopicModel lda,Alphabet alphabet){
  ArrayList<Integer> features=new ArrayList<Integer>();
  Alphabet seqAlphabet=lda.getAlphabet();
  int numTopics=lda.getNumTopics();
  Object[][] sorted=lda.getTopWords(seqAlphabet.size());
  for (int pos=0; pos < seqAlphabet.size(); pos++) {
    for (int ti=0; ti < numTopics; ti++) {
      Object feat=sorted[ti][pos].toString();
      int fi=alphabet.lookupIndex(feat,false);
      if ((fi >= 0) && (!features.contains(fi))) {
        System.err.println(feat);
        features.add(fi);
        if (features.size() == numSelFeatures) {
          return features;
        }
      }
    }
  }
  return features;
}

Fixed version (ground truth):
/** 
 * Select top features in LDA topics.
 * @param numSelFeatures Number of features to select.
 * @param ldaEst LDAEstimatePr which provides an interface to an LDA model.
 * @param seqAlphabet The alphabet for the sequence dataset, which may be different from the vector dataset alphabet.
 * @param alphabet The vector dataset alphabet.
 * @return ArrayList with the int indices of the selected features.
 */
public static ArrayList<Integer> selectTopLDAFeatures(int numSelFeatures,ParallelTopicModel lda,Alphabet alphabet){
  ArrayList<Integer> features=new ArrayList<Integer>();
  Alphabet seqAlphabet=lda.getAlphabet();
  int numTopics=lda.getNumTopics();
  Object[][] sorted=lda.getTopWords(seqAlphabet.size());
  for (int pos=0; pos < seqAlphabet.size(); pos++) {
    for (int ti=0; ti < numTopics; ti++) {
      Object feat=sorted[ti][pos].toString();
      int fi=alphabet.lookupIndex(feat,false);
      if ((fi >= 0) && (!features.contains(fi))) {
        System.err.println("String_Node_Str" + feat);
        features.add(fi);
        if (features.size() == numSelFeatures) {
          return features;
        }
      }
    }
  }
  return features;
}
Program: 20197
Project: 20197
Buggy source:
private static void writeConstraints(HashMap<Integer,double[]> constraints,File constraintsFile,Alphabet dataAlphabet,Alphabet targetAlphabet){
  try {
    FileWriter writer=new FileWriter(constraintsFile);
    for (    int fi : constraints.keySet()) {
      writer.write(dataAlphabet.lookupObject(fi) + "String_Node_Str");
      double[] p=constraints.get(fi);
      if (p != null) {
        for (int li=0; li < p.length; li++) {
          writer.write(targetAlphabet.lookupObject(li) + "String_Node_Str" + p[li]+ "String_Node_Str");
        }
      }
      writer.write("String_Node_Str");
    }
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    System.exit(1);
  }
}

Fixed version (ground truth):
private static void writeConstraints(HashMap<Integer,double[]> constraints,File constraintsFile,Alphabet dataAlphabet,Alphabet targetAlphabet){
  if (constraints.size() == 0) {
    System.err.println("String_Node_Str");
    return;
  }
  try {
    FileWriter writer=new FileWriter(constraintsFile);
    for (    int fi : constraints.keySet()) {
      writer.write(dataAlphabet.lookupObject(fi) + "String_Node_Str");
      double[] p=constraints.get(fi);
      if (p != null) {
        for (int li=0; li < p.length; li++) {
          writer.write(targetAlphabet.lookupObject(li) + "String_Node_Str" + p[li]+ "String_Node_Str");
        }
      }
      writer.write("String_Node_Str");
    }
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    System.exit(1);
  }
}